This is an automated email from the ASF dual-hosted git repository.

geertjan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-netbeans.git


The following commit(s) were added to refs/heads/master by this push:
     new 125510a  netbeans-480: ConvertToDiamondBulkHint disabled for var type 
variable initialization (#487)
125510a is described below

commit 125510a0b4acd6c92aeab6a1d91b3394e17cc19a
Author: Arunava Sinha <arunava.si...@oracle.com>
AuthorDate: Tue Apr 10 17:00:11 2018 +0530

    netbeans-480: ConvertToDiamondBulkHint disabled for var type variable 
initialization (#487)
---
 .../modules/java/hints/jdk/ConvertToDiamondBulkHint.java   |  9 +++++++++
 .../java/hints/jdk/ConvertToDiamondBulkHintTest.java       | 14 ++++++++++++++
 2 files changed, 23 insertions(+)

diff --git 
a/java.hints/src/org/netbeans/modules/java/hints/jdk/ConvertToDiamondBulkHint.java
 
b/java.hints/src/org/netbeans/modules/java/hints/jdk/ConvertToDiamondBulkHint.java
index 57049ee..1991e5f 100644
--- 
a/java.hints/src/org/netbeans/modules/java/hints/jdk/ConvertToDiamondBulkHint.java
+++ 
b/java.hints/src/org/netbeans/modules/java/hints/jdk/ConvertToDiamondBulkHint.java
@@ -95,6 +95,15 @@ public class ConvertToDiamondBulkHint {
         @TriggerPattern("new $clazz<$tparams$>($params$)")
     })
     public static ErrorDescription compute(HintContext ctx) {
+        // hint disabled for var type variable initialization.
+        TreePath parentPath = ctx.getPath().getParentPath();
+        boolean isVarInit = MatcherUtilities.matches(ctx, parentPath, "$mods$ 
$type $name = $init;");   //NOI18N
+        if (isVarInit) {
+            if (ctx.getInfo().getTreeUtilities().isVarType(parentPath)) {
+                return null;
+            }
+        }
+
         if (ctx.getMultiVariables().get("$tparams$").isEmpty()) return null;
         
         TreePath clazz = ctx.getVariables().get("$clazz");
diff --git 
a/java.hints/test/unit/src/org/netbeans/modules/java/hints/jdk/ConvertToDiamondBulkHintTest.java
 
b/java.hints/test/unit/src/org/netbeans/modules/java/hints/jdk/ConvertToDiamondBulkHintTest.java
index dbf7a66..3305cc7 100644
--- 
a/java.hints/test/unit/src/org/netbeans/modules/java/hints/jdk/ConvertToDiamondBulkHintTest.java
+++ 
b/java.hints/test/unit/src/org/netbeans/modules/java/hints/jdk/ConvertToDiamondBulkHintTest.java
@@ -290,6 +290,20 @@ public class ConvertToDiamondBulkHintTest extends 
NbTestCase {
                 .assertWarnings();
     }
     
+    public void testConfiguration9() throws Exception {
+        HintTest
+                .create()
+                .input("package test;\n" +
+                       "public class Test {\n" +
+                       "    {\n" +
+                       "        var list = new 
java.util.LinkedList<String>();\n" +
+                       "    }\n" +
+                       "}\n")
+                .sourceLevel("1.10")
+                .run(ConvertToDiamondBulkHint.class)
+                .assertWarnings();
+    }
+
     static {
         TestCompilerSettings.commandLine = "-XDfind=diamond";
     }

-- 
To stop receiving notification emails like this one, please contact
geert...@apache.org.

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@netbeans.apache.org
For additional commands, e-mail: commits-h...@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to