void (final RestRole node) { RestFile file = (RestFile)node.getContainingFile(); if (PsiTreeUtil.getParentOfType(node, RestDirectiveBlock.class) != null) return; final PsiElement sibling = node.getNextSibling(); if (sibling == null || sibling.getNode().getElementType() != RestTokenTypes.INTERPRETED) return; if (RestUtil.PREDEFINED_ROLES.contains(node.getText()) || myIgnoredRoles.contains(node.getRoleName())) return; if (RestUtil.SPHINX_ROLES.contains(node.getText()) || RestUtil.SPHINX_ROLES.contains(":py"+node.getText()) || mySphinxRoles.contains(node.getRoleName())) return; Set<String> definedRoles = new HashSet<>(); RestDirectiveBlock[] directives = PsiTreeUtil.getChildrenOfType(file, RestDirectiveBlock.class); if (directives != null) { for (RestDirectiveBlock block : directives) { if (block.getDirectiveName().equals("role::")) { PsiElement role = block.getFirstChild().getNextSibling(); if (role != null) { String roleName = role.getText().trim(); int index = roleName.indexOf('('); if (index != -1) roleName = roleName.substring(0, index); definedRoles.add(roleName); } } } } if (definedRoles.contains(node.getRoleName())) return; registerProblem( node, PythonRestBundle.message("python.rest.inspection.message.not.defined.role", node.getRoleName()), new AddIgnoredRoleFix(node.getRoleName(), RestRoleInspection.this)); }