RestElement () { String name = getReferenceText(); PsiFile file = getContainingFile(); RestReferenceTarget[] elements = PsiTreeUtil.getChildrenOfType(file, RestReferenceTarget.class); if (elements != null) { if (name.equals("__") || name.equals("[*]") || name.equals("[#]")) return findAnonimousTarget(file, elements); for (RestReferenceTarget element : elements) { if (element.getReferenceName().equalsIgnoreCase(name) || element.getReferenceName(false).equalsIgnoreCase(name)) { return element; } } } //TODO[catherine]: targets are not better than titles for resolving // they should have the same ancestor RestTitle[] titles = PsiTreeUtil.getChildrenOfType(file, RestTitle.class); if (titles != null) { for (RestTitle element : titles) { if (name.equalsIgnoreCase(element.getName())) { return element; } } } return null; }