You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by GitBox <gi...@apache.org> on 2018/09/04 11:57:11 UTC

[GitHub] geertjanw closed pull request #819: [NETBEANS-1021] Hide use explicit param hint if params syntax invalid

geertjanw closed pull request #819: [NETBEANS-1021] Hide use explicit param hint if params syntax invalid
URL: https://github.com/apache/incubator-netbeans/pull/819
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/java/java.hints/src/org/netbeans/modules/java/hints/suggestions/Lambda.java b/java/java.hints/src/org/netbeans/modules/java/hints/suggestions/Lambda.java
index 41f4df58a6..39a4dc495c 100644
--- a/java/java.hints/src/org/netbeans/modules/java/hints/suggestions/Lambda.java
+++ b/java/java.hints/src/org/netbeans/modules/java/hints/suggestions/Lambda.java
@@ -225,6 +225,11 @@ public static ErrorDescription reference2Lambda(HintContext ctx) {
     @TriggerTreeKind(Kind.LAMBDA_EXPRESSION)
     public static ErrorDescription explicitParameterTypes(HintContext ctx) {
         LambdaExpressionTree let = (LambdaExpressionTree) ctx.getPath().getLeaf();
+
+        if (ctx.getInfo().getTreeUtilities().hasError(let)) {
+            return null;
+        }
+
         boolean hasSyntheticParameterName = false;
         
         for (VariableTree var : let.getParameters()) {
diff --git a/java/java.hints/test/unit/src/org/netbeans/modules/java/hints/suggestions/LambdaTest.java b/java/java.hints/test/unit/src/org/netbeans/modules/java/hints/suggestions/LambdaTest.java
index 19e277e2a5..f32f022377 100644
--- a/java/java.hints/test/unit/src/org/netbeans/modules/java/hints/suggestions/LambdaTest.java
+++ b/java/java.hints/test/unit/src/org/netbeans/modules/java/hints/suggestions/LambdaTest.java
@@ -603,6 +603,31 @@ public void testImplicitVarParameterTypes2() throws Exception {
                                       "    }\n" +
                                       "}\n");
     }
+    
+    @Test
+    public void testConvertVarToExplicitParameterTypes() throws Exception {
+        HintTest.create()
+                .setCaretMarker('^')
+                .input("package test;\n" +
+                       "import java.util.*;\n" +
+                       "public class Test {\n" +
+                       "    public void main(List<String> list) {\n" +
+                       "        Collections.sort(list, (var l, var r) -^> l.compareTo(r));\n" +
+                       "    }\n" +
+                       "}\n")
+                .sourceLevel("1.11")
+                .run(Lambda.class)
+                .findWarning("4:47-4:47:verifier:ERR_addExplicitLambdaParameters")
+                .applyFix()
+                .assertCompilable()
+                .assertVerbatimOutput("package test;\n" +
+                                      "import java.util.*;\n" +
+                                      "public class Test {\n" +
+                                      "    public void main(List<String> list) {\n" +
+                                      "        Collections.sort(list, (String l, String r) -> l.compareTo(r));\n" +
+                                      "    }\n" +
+                                      "}\n");
+    }
 
     static {
         JavacParser.DISABLE_SOURCE_LEVEL_DOWNGRADE = true;


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

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

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