boolean (PsiNewExpression expression) { if (expression.getQualifier() != null) { return true; } PsiJavaCodeReferenceElement classReference = expression.getClassOrAnonymousClassReference(); if (classReference != null && classReference.isQualified()) { PsiJavaCodeReferenceElement containerReference = ObjectUtils.tryCast(classReference.getQualifier(), PsiJavaCodeReferenceElement.class); if (containerReference != null) { PsiElement targetClass = containerReference.resolve(); return !(targetClass instanceof PsiClass) || !InheritanceUtil.hasEnclosingInstanceInScope((PsiClass)targetClass, expression, true, true); } return true; } return false; }