allow new expressions qualifications to be shortened anyway
authorAnna Kozlova <anna.kozlova@jetbrains.com>
Wed, 25 Jan 2012 12:51:37 +0000 (16:51 +0400)
committerAnna Kozlova <anna.kozlova@jetbrains.com>
Wed, 25 Jan 2012 12:52:28 +0000 (16:52 +0400)
java/java-impl/src/com/intellij/psi/impl/source/codeStyle/ReferenceAdjuster.java

index f223dd2262193f922492233e6ab963953aa02cea..5e079580c74aa7f293cddf52a4c700416410adf7 100644 (file)
@@ -222,7 +222,12 @@ public class ReferenceAdjuster {
     final PsiManager manager = refClass.getManager();
     final JavaPsiFacade facade = JavaPsiFacade.getInstance(manager.getProject());
     final PsiResolveHelper helper = facade.getResolveHelper();
-    return manager.areElementsEquivalent(refClass, helper.resolveReferencedClass(referenceText, psiReference)) && helper.resolveReferencedVariable(referenceText, psiReference) == null;
+    if (manager.areElementsEquivalent(refClass, helper.resolveReferencedClass(referenceText, psiReference))) {
+      PsiElement parent = psiReference.getParent();
+      if (parent instanceof PsiJavaCodeReferenceElement && parent.getParent() instanceof PsiNewExpression) return true;
+      return helper.resolveReferencedVariable(referenceText, psiReference) == null;
+    }
+    return false;
   }
 
   @NotNull