boolean (Object element, PsiElement context) { if (myCurrentContext.get() != context) { myCurrentContext = new SoftReference<>(context); myCachedClass = new SoftReference<>(PsiTreeUtil.getContextOfType(context, false, PsiClass.class)); } PsiClass curClass = myCachedClass.get(); if (curClass == null) return false; PsiClass candidate = tryCast(element, PsiClass.class); if (candidate == null) return false; return checkInheritance(curClass, candidate); }