String (@NotNull final PsiElement element, @NotNull final ElementDescriptionLocation location) { if (!(location instanceof NonCodeSearchDescriptionLocation ncdLocation)) return null; if (element instanceof PsiPackage pkg) { return ncdLocation.isNonJava() ? pkg.getQualifiedName() : StringUtil.notNullize(pkg.getName()); } if (element instanceof PsiClass cls) { return ncdLocation.isNonJava() ? cls.getQualifiedName() : cls.getName(); } if (element instanceof PsiMember member) { String name = member.getName(); if (name == null) return null; if (ncdLocation.isNonJava()) { PsiClass containingClass = member.getContainingClass(); if (containingClass == null || containingClass.getQualifiedName() == null) return null; return containingClass.getQualifiedName() + "." + name; } return name; } return null; }