StringBuilder (PsiElement element, Collection<PsiJavaCodeReferenceElement> references, PsiClass aClass, StringBuilder out) { if (element == null) { return out; } if (references.contains(element)) { final String shortClassName = getShortClassName(aClass, new StringBuilder()).toString(); if (isReferenceToTargetClass(shortClassName, aClass, element)) { out.append(shortClassName); } else { out.append(aClass.getQualifiedName()); } out.append('.'); return out.append(element.getText()); } final PsiElement[] children = element.getChildren(); if (children.length == 0) { return out.append(element.getText()); } for (PsiElement child : children) { buildNewText(child, references, aClass, out); } return out; }