String (Project project, PsiManager manager, String refText, PsiElement context) { PsiElement refElement = null; try { refElement = findReferenceTarget(manager, refText, context, false); } catch (IndexNotReadyException e) { LOG.debug(e); } if (refElement == null) { return refText.replaceFirst("^#", "").replaceAll("#", "."); } int poundIndex = refText.indexOf('#'); if (poundIndex < 0) { if (refElement instanceof PsiClass) { return getShortestClassName((PsiClass)refElement, context); } else { return refText; } } else { PsiClass aClass = null; if (refElement instanceof PsiField) { aClass = ((PsiField)refElement).getContainingClass(); } else if (refElement instanceof PsiMethod) { aClass = ((PsiMethod)refElement).getContainingClass(); } else if (refElement instanceof PsiClass){ return refText.replaceAll("#", "."); } if (aClass == null) return refText; String classRef = refText.substring(0, poundIndex).trim(); String memberText = refText.substring(poundIndex + 1); String memberLabel = getMemberLabelText(project, manager, memberText, context); if (!classRef.isEmpty()) { PsiElement refClass = null; try { refClass = findReferenceTarget(manager, classRef, context); } catch (IndexNotReadyException e) { LOG.debug(e); } if (refClass instanceof PsiClass) { PsiElement scope = context; while (scope != null && !(scope instanceof PsiFile)) { if (scope.equals(refClass)) { return memberLabel; } scope = scope.getParent(); } } return getLabelText(project, manager, classRef, context) + "." + memberLabel; } else { return memberLabel; } } }