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

arusinha 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 bf3927d  [NETBEANS-1251] nb-javac 11 testcase failure : Compound var 
declaration
     new 2d76c29  Merge pull request #1131 from vikasprabhakar/netbeans-1251
bf3927d is described below

commit bf3927d1cab680a5cbc7eaa1c3f6091b4024f00c
Author: Vikas Prabhakar <[email protected]>
AuthorDate: Tue Feb 12 02:49:29 2019 -0800

    [NETBEANS-1251] nb-javac 11 testcase failure : Compound var declaration
---
 .../java/hints/errors/VarCompDeclaration.java      |  4 ++++
 .../java/hints/errors/VarCompDeclarationTest.java  | 24 ++++++++++++++++++++--
 .../hints/infrastructure/ErrorHintsTestBase.java   |  3 ++-
 3 files changed, 28 insertions(+), 3 deletions(-)

diff --git 
a/java/java.hints/src/org/netbeans/modules/java/hints/errors/VarCompDeclaration.java
 
b/java/java.hints/src/org/netbeans/modules/java/hints/errors/VarCompDeclaration.java
index 9706480..aa7170b 100644
--- 
a/java/java.hints/src/org/netbeans/modules/java/hints/errors/VarCompDeclaration.java
+++ 
b/java/java.hints/src/org/netbeans/modules/java/hints/errors/VarCompDeclaration.java
@@ -123,6 +123,10 @@ public class VarCompDeclaration implements ErrorRule<Void> 
{
             int pos = statements.indexOf(statementPath.getLeaf());
             List<StatementTree> newStatements = new ArrayList<>();
             if (pos > 0) {
+                
if(info.getTreeUtilities().isPartOfCompoundVariableDeclaration(statements.get(pos
 - 1))
+                        && 
!info.getTreeUtilities().isEndOfCompoundVariableDeclaration(statements.get(pos 
- 1))){
+                    pos--;
+                }
                 newStatements.addAll(statements.subList(0, pos));
             }
 
diff --git 
a/java/java.hints/test/unit/src/org/netbeans/modules/java/hints/errors/VarCompDeclarationTest.java
 
b/java/java.hints/test/unit/src/org/netbeans/modules/java/hints/errors/VarCompDeclarationTest.java
index 6851b7d..a882087 100644
--- 
a/java/java.hints/test/unit/src/org/netbeans/modules/java/hints/errors/VarCompDeclarationTest.java
+++ 
b/java/java.hints/test/unit/src/org/netbeans/modules/java/hints/errors/VarCompDeclarationTest.java
@@ -68,7 +68,7 @@ public class VarCompDeclarationTest extends 
ErrorHintsTestBase {
                        "package test; \n" +
                        "public class Test {\n" +
                        "    private void test() { \n" +
-                       "        var v = 1, /*comment*/ v1 = 10;\n" +
+                       "        var v = 1, v1 = 10, v2 = 100;\n" +
                        "    } \n" +
                        "}",
                        -1,
@@ -76,8 +76,9 @@ public class VarCompDeclarationTest extends 
ErrorHintsTestBase {
                        ("package test; \n" +
                        "public class Test {\n" +
                        "    private void test() { \n" +
-                       "        var v = 1; /*comment*/ \n" +
+                       "        var v = 1;\n" +
                        "        var v1 = 10;\n" +
+                       "        var v2 = 100;\n" +
                        "    } \n" +
                        "}").replaceAll("[\\s]+", " "));
     }
@@ -259,6 +260,25 @@ public class VarCompDeclarationTest extends 
ErrorHintsTestBase {
                        "}").replaceAll("[\\s]+", " "));
     }
     
+    public void testCase11() throws Exception {
+        performFixTest("test/Test.java",
+                       "package test; \n" +
+                       "public class Test {\n" +
+                       "    private void test() { \n" +
+                       "        var v = {1, 2}, w = 2;\n" +
+                       "    } \n" +
+                       "}",
+                       -1,
+                       NbBundle.getMessage(VarCompDeclarationTest.class, 
"FIX_VarCompDeclaration"),
+                       ("package test; \n" +
+                       "public class Test {\n" +
+                       "    private void test() { \n" +
+                       "        var v = {1, 2};\n" +
+                       "        var w = 2;\n" +
+                       "    } \n" +
+                       "}").replaceAll("[\\s]+", " "));
+    }
+
     @Override
     protected List<Fix> computeFixes(CompilationInfo info, int pos, TreePath 
path) throws Exception {
         return new VarCompDeclaration().run(info, null, pos, path, null);
diff --git 
a/java/java.hints/test/unit/src/org/netbeans/modules/java/hints/infrastructure/ErrorHintsTestBase.java
 
b/java/java.hints/test/unit/src/org/netbeans/modules/java/hints/infrastructure/ErrorHintsTestBase.java
index 00783ee..1ca6c49 100644
--- 
a/java/java.hints/test/unit/src/org/netbeans/modules/java/hints/infrastructure/ErrorHintsTestBase.java
+++ 
b/java/java.hints/test/unit/src/org/netbeans/modules/java/hints/infrastructure/ErrorHintsTestBase.java
@@ -337,6 +337,7 @@ public abstract class ErrorHintsTestBase extends NbTestCase 
{
             if (d.getKind() == Diagnostic.Kind.ERROR && (supportedErrorKeys == 
null || supportedErrorKeys.contains(d.getCode()))) {
                 if (found == null) {
                     found = d;
+                } else if (found.getCode().equals(d.getCode())) {
                 } else {
                     throw new IllegalStateException("More than one error: " + 
diagnosticsToString(info.getDiagnostics()));
                 }
@@ -345,7 +346,7 @@ public abstract class ErrorHintsTestBase extends NbTestCase 
{
         if (found == null) {
             throw new IllegalStateException("No error found: " + 
diagnosticsToString(info.getDiagnostics()));
         }
-        
+
         return found;
     }
     


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

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

Reply via email to