boolean (PsiElement refElement, PsiElement elementToHighlight) { PsiClass outermostClass = CachedValuesManager.getCachedValue( refElement, () -> new CachedValueProvider.Result<>(PsiUtil.getTopLevelClass(refElement), PsiModificationTracker.MODIFICATION_COUNT) ); return outermostClass != null && outermostClass == PsiUtil.getTopLevelClass(elementToHighlight); }