PsiElement (@NotNull PsiElement element) { if (!element.getLanguage().isKindOf(JavaLanguage.INSTANCE) || !element.isPhysical()) { return null; } if (element instanceof PsiAnonymousClass) { return ((PsiAnonymousClass)element).getBaseClassReference().getReferenceNameElement(); } if (element instanceof PsiClass || element instanceof PsiMethod || (element instanceof PsiVariable && !(element instanceof PsiLocalVariable))) { return ((PsiNameIdentifierOwner)element).getNameIdentifier(); } if (element instanceof PsiImportList) { return element.getContainingFile(); } return null; }