String (final PsiElement element) { if (element instanceof PsiNamedElement) { String name = ((PsiNamedElement)element).getName(); if (name != null) { return name; } } PsiFile file = element.getContainingFile(); if (file == null) { PsiUtilCore.ensureValid(element); LOG.error("No file for " + element.getClass()); return element.toString(); } return file.getName(); }