You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@netbeans.apache.org by jl...@apache.org on 2018/06/18 04:39:08 UTC

[incubator-netbeans] 16/20: hide hint for anonymous class array

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

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

commit d1ad4fa8c4b1ca41ae8a8c8712732291d141d6b7
Author: rtaneja <re...@oracle.com>
AuthorDate: Fri Jun 1 01:04:45 2018 -0700

    hide hint for anonymous class array
---
 .../java/hints/errors/ConvertInvalidVarToExplicitArrayType.java     | 4 ++--
 .../java/hints/errors/ConvertInvalidVarToExplicitArrayTypeTest.java | 6 ++++++
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/java.hints/src/org/netbeans/modules/java/hints/errors/ConvertInvalidVarToExplicitArrayType.java b/java.hints/src/org/netbeans/modules/java/hints/errors/ConvertInvalidVarToExplicitArrayType.java
index 428cb05..9568817 100644
--- a/java.hints/src/org/netbeans/modules/java/hints/errors/ConvertInvalidVarToExplicitArrayType.java
+++ b/java.hints/src/org/netbeans/modules/java/hints/errors/ConvertInvalidVarToExplicitArrayType.java
@@ -96,9 +96,9 @@ public class ConvertInvalidVarToExplicitArrayType implements ErrorRule<Void> {
 
                 TypeMirror etType = trees.getTypeMirror(new TreePath(initArrayTreePath, tree));
 
-                //skipped fix for invalid array member and for parameterized array member.
+                //skipped fix for invalid array member, anonymous class and parameterized array member.
                 if (etType == null || etType.getKind() == TypeKind.ERROR || (etType.getKind() == TypeKind.DECLARED
-                        && !((DeclaredType) etType).getTypeArguments().isEmpty())) {
+                        && !((DeclaredType) etType).getTypeArguments().isEmpty()) || Utilities.isAnonymousType(etType)) {
                     return null;
                 }
 
diff --git a/java.hints/test/unit/src/org/netbeans/modules/java/hints/errors/ConvertInvalidVarToExplicitArrayTypeTest.java b/java.hints/test/unit/src/org/netbeans/modules/java/hints/errors/ConvertInvalidVarToExplicitArrayTypeTest.java
index a36d16f..a5d79cb 100644
--- a/java.hints/test/unit/src/org/netbeans/modules/java/hints/errors/ConvertInvalidVarToExplicitArrayTypeTest.java
+++ b/java.hints/test/unit/src/org/netbeans/modules/java/hints/errors/ConvertInvalidVarToExplicitArrayTypeTest.java
@@ -63,6 +63,12 @@ public class ConvertInvalidVarToExplicitArrayTypeTest extends ErrorHintsTestBase
                 "package test; public class Test {{final var j = {int1,var1,\"hello\"};}}",
                 -1);
     }
+    
+    public void testAnonymousClassTypeArray() throws Exception {
+        performAnalysisTest("test/Test.java",
+                "package test; public class Test {{var j = {new Object(){}};}}",
+                -1);
+    }
 
     public void testParameterizedElements() throws Exception {
         performAnalysisTest("test/Test.java",

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

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

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