PsiClass (PsiElement element, PsiMember resolved) { PsiClass aClass = resolved.getContainingClass(); if (aClass != null && !PsiUtil.isAccessible(aClass.getProject(), aClass, element, null)) { final PsiElement qualifier = ((PsiJavaCodeReferenceElement)element.getParent()).getQualifier(); if (qualifier instanceof PsiReferenceExpression) { final PsiElement qResolved = ((PsiReferenceExpression)qualifier).resolve(); if (qResolved instanceof PsiVariable) { aClass = PsiUtil.resolveClassInClassTypeOnly(((PsiVariable)qResolved).getType()); } else if (qResolved instanceof PsiClass) { aClass = (PsiClass)qResolved; } } } return aClass; }