boolean (PsiElement qualifier) { if (isThisReference(qualifier)) { GrReferenceExpression ref = (GrReferenceExpression)qualifier; PsiElement resolved = ref.resolve(); if (!(resolved instanceof PsiClass)) return false; return hasEnclosingInstanceInScope((PsiClass)resolved, qualifier, false); } return false; }