boolean (PsiExpression expression) { PsiClass type = PsiUtil.resolveClassInClassTypeOnly(expression.getType()); JBIterable<PsiClass> typeContainers = JBIterable.generate(type, PsiClass::getContainingClass).takeWhile(c -> !c.hasModifierProperty(PsiModifier.STATIC)); return typeContainers.contains(containingClass); }