Commits

Jan Lahoda committed 5081048

Use QualIdent only for static elements.

  • Participants
  • Parent commits 6171124

Comments (0)

Files changed (2)

File api/src/org/netbeans/modules/jackpot30/spi/JavaFix.java

 import java.util.logging.Logger;
 import javax.lang.model.element.Element;
 import javax.lang.model.element.ElementKind;
+import javax.lang.model.element.Modifier;
 import javax.lang.model.element.TypeElement;
 import javax.lang.model.type.TypeKind;
 import javax.lang.model.type.TypeMirror;
                         //check correct dependency:
                         checkDependency(wc, e, callback);
                         
-                        if (Utilities.isPureMemberSelect(node, false)) {
+                        if (isStaticElement(e)) {
                             wc.rewrite(node, wc.getTreeMaker().QualIdent(e));
 
                             return null;
         return SourceUtils.getFile(e, copy.getClasspathInfo());
     }
 
+    private static boolean isStaticElement(Element el) {
+        if (el == null) return false;
+
+        return el.getModifiers().contains(Modifier.STATIC);
+    }
+
     public interface UpgradeUICallback {
         public boolean shouldUpgrade(String comment);
     }

File api/test/unit/src/org/netbeans/modules/jackpot30/impl/hints/HintsInvokerTest.java

                        "}\n").replaceAll("[ \t\n]+", " "));
     }
 
+    public void testMultiStatementVariables3() throws Exception {
+        performFixTest("test/Test.java",
+                       "|package test;\n" +
+                       "\n" +
+                       "public class Test {\n" +
+                       "     private int test() {\n" +
+                       "         System.err.println();\n" +
+                       "         System.err.println();\n" +
+                       "         int i = 3;\n" +
+                       "         System.err.println(i);\n" +
+                       "         System.err.println(i);\n" +
+                       "         return i;\n" +
+                       "     }\n" +
+                       "}\n",
+                       "3:24-10:6:verifier:HINT",
+                       "FixImpl",
+                       ("package test;\n" +
+                       "\n" +
+                       "public class Test {\n" +
+                       "     private int test() {\n" +
+                       "         System.err.println();\n" +
+                       "         System.err.println();\n" +
+                       "         float i = 3;\n" +
+                       "         System.err.println(i);\n" +
+                       "         System.err.println(i);\n" +
+                       "         return i;\n" +
+                       "     }\n" +
+                       "}\n").replaceAll("[ \t\n]+", " "));
+    }
+
     private static final Map<String, HintDescription> test2Hint;
 
     static {
         test2Hint.put("testStatementVariables2", test2Hint.get("testStatementVariables1"));
         test2Hint.put("testMultiStatementVariables1", HintDescriptionFactory.create().setTriggerPattern(PatternDescription.create("{ $pref$; int $i = 3; $inf$; return $i; }", Collections.<String, String>emptyMap())).setWorker(new WorkerImpl("{ $pref$; float $i = 3; $inf$; return $i; }")).produce());
         test2Hint.put("testMultiStatementVariables2", test2Hint.get("testMultiStatementVariables1"));
+        test2Hint.put("testMultiStatementVariables3", test2Hint.get("testMultiStatementVariables1"));
     }
 
     @Override