String (PsiElement element) { VirtualFile file = element instanceof PsiFile ? PsiUtilCore.getVirtualFile(element) : element instanceof VirtualFile ? (VirtualFile)element : null; if (file != null) { return VfsPresentationUtil.getPresentableNameForUI(element.getProject(), file); } if (element instanceof NavigationItem) { String name = Optional.ofNullable(((NavigationItem)element).getPresentation()) .map(presentation -> presentation.getPresentableText()) .orElse(null); if (name != null) return name; } String name = element instanceof PsiNamedElement ? ((PsiNamedElement)element).getName() : null; return StringUtil.notNullize(name, "<unnamed>"); }