PsiClass (PsiElement element) { if (element instanceof PsiReferenceExpression) { PsiElement target = ((PsiReferenceExpression)element).resolve(); if (target instanceof PsiClass) { return (PsiClass)target; } } if (element instanceof PsiExpression) { PsiClass psiClass = PsiUtil.resolveClassInClassTypeOnly(((PsiExpression)element).getType()); return psiClass instanceof PsiAnonymousClass ? psiClass.getSuperClass() : psiClass; } return null; }