boolean (PsiThisExpression expression, PsiNewExpression newExpression) { final PsiClass containingClass = ClassUtils.getContainingClass(expression); final PsiJavaCodeReferenceElement referenceElement = newExpression.getClassReference(); if (referenceElement == null) { return false; } final PsiElement element = referenceElement.resolve(); if (!(element instanceof PsiClass constructorClass)) { return false; } return !PsiTreeUtil.isAncestor(containingClass, constructorClass, false) || constructorClass.hasModifierProperty(PsiModifier.STATIC); }