String (final @NotNull PsiElement element, final @NotNull ElementDescriptionLocation location) { if (!(location instanceof NonCodeSearchDescriptionLocation ncdLocation)) return null; if (element instanceof PsiDirectory) { if (ncdLocation.isNonJava()) { final String qName = PsiDirectoryFactory.getInstance(element.getProject()).getQualifiedName((PsiDirectory)element, false); if (qName.length() > 0) return qName; return null; } return ((PsiDirectory) element).getName(); } if (element instanceof PsiMetaOwner psiMetaOwner) { final PsiMetaData metaData = psiMetaOwner.getMetaData(); if (metaData != null) { return metaData.getName(); } } if (element instanceof PsiNamedElement) { return ((PsiNamedElement)element).getName(); } return null; }