String (boolean annotated, PsiAnnotation @Nullable [] annotations) { String text = getCanonicalText(); if (!annotated || annotations == null) return text; StringBuilder sb = new StringBuilder(); String prefix = PsiNameHelper.getOuterClassReference(text); int simpleNamePos = 0; if (!StringUtil.isEmpty(prefix)) { if (myQualifier != null) { sb.append(myQualifier.getCanonicalText(true, myQualifier.myAnnotations.getProvider(myQualifier).getAnnotations())); } else { sb.append(prefix); } sb.append('.'); simpleNamePos = prefix.length() + 1; } PsiNameHelper.appendAnnotations(sb, Arrays.asList(annotations), true); int typeArgPos = text.indexOf('<', simpleNamePos); if (typeArgPos == -1) { sb.append(text, simpleNamePos, text.length()); } else { sb.append(text, simpleNamePos, typeArgPos); PsiNameHelper.appendTypeArgs(sb, getTypeParameters(), true, true); } return sb.toString(); }