lahodaj commented on a change in pull request #2277:
URL: https://github.com/apache/netbeans/pull/2277#discussion_r461489834



##########
File path: 
java/java.hints/src/org/netbeans/modules/java/hints/suggestions/ExpectedTypeResolver.java
##########
@@ -1388,4 +1391,16 @@ private static void 
addTypeAndReplaceMoreSpecific(CompilationInfo info, Collecti
     public List<? extends TypeMirror> visitUses(UsesTree node, Object p) {
         return null;
     }
+   
+    public List<? extends TypeMirror> visitBindingPattern(BindingPatternTree 
bpt, Object p) {

Review comment:
       I am a little surprised this compiles, but should be safe at runtime.
   
   Should these new methods eventually have an implementation that would 
produce the expected type?

##########
File path: 
java/spi.java.hints/src/org/netbeans/modules/java/hints/spiimpl/Utilities.java
##########
@@ -1427,7 +1484,7 @@ protected JCCatch catchClause() {
             }
             return super.classOrInterfaceBodyDeclaration(className, 
isInterface);
         }
-
+        

Review comment:
       Nit: unnecessary change:
   ```suggestion
   
   ```

##########
File path: 
java/spi.java.hints/src/org/netbeans/modules/java/hints/spiimpl/Utilities.java
##########
@@ -1352,6 +1354,33 @@ protected JCModifiers modifiersOpt(JCModifiers partial) {
             return super.modifiersOpt(partial);
         }
 
+
+        public JCVariableDecl formalParameter(boolean lambdaParam, boolean 
recordComponents) {
+            if (token.kind == TokenKind.IDENTIFIER) {
+                if (token.name().startsWith(dollar)) {
+                    com.sun.tools.javac.util.Name name = token.name();
+
+                    Token peeked = S.token(1);
+
+                    if (peeked.kind == TokenKind.COMMA || peeked.kind == 
TokenKind.RPAREN) {
+                        nextToken();
+                        return JackpotTrees.createVariableWildcard(ctx, name);
+                    }
+                }
+            }
+                        JCTree.JCVariableDecl result = null;

Review comment:
       Nit: note the indent is wrong on this line.
   ```suggestion
               JCTree.JCVariableDecl result = null;
   ```

##########
File path: 
java/java.hints/test/unit/src/org/netbeans/modules/java/hints/jdk/ConvertToPatternInstanceOfTest.java
##########
@@ -140,15 +148,4 @@ public void testNoSoSimpleNameClash() throws Exception {
                               "}\n");
     }
 
-    @Override

Review comment:
       We are giving up the ability to run tests without nb-javac on JDK<14. 
Possibly not that big issue as we are not running the tests in that combination 
anyway.

##########
File path: 
java/spi.java.hints/src/org/netbeans/modules/java/hints/spiimpl/Utilities.java
##########
@@ -1352,6 +1354,33 @@ protected JCModifiers modifiersOpt(JCModifiers partial) {
             return super.modifiersOpt(partial);
         }
 
+
+        public JCVariableDecl formalParameter(boolean lambdaParam, boolean 
recordComponents) {
+            if (token.kind == TokenKind.IDENTIFIER) {
+                if (token.name().startsWith(dollar)) {
+                    com.sun.tools.javac.util.Name name = token.name();
+
+                    Token peeked = S.token(1);
+
+                    if (peeked.kind == TokenKind.COMMA || peeked.kind == 
TokenKind.RPAREN) {
+                        nextToken();
+                        return JackpotTrees.createVariableWildcard(ctx, name);
+                    }
+                }
+            }
+                        JCTree.JCVariableDecl result = null;
+            try {
+                Class[] paramTypes = {boolean.class, boolean.class};
+                result = (JCTree.JCVariableDecl) MethodHandles.lookup()
+                        .findSpecial(JavacParser.class, "formalParameter", 
MethodType.methodType(JCTree.JCVariableDecl.class, paramTypes), 
JackpotJavacParser.class) // NOI18N
+                        .invoke(this, lambdaParam, recordComponents);
+            } catch (Throwable e) {
+                
Logger.getLogger(NBParserFactory.class.getName()).log(Level.FINE, null, e);

Review comment:
       I think it should be fine to just fail here, shouldn't it (the method 
must exist, as the current method overrides it):
   ```suggestion
                   throw new IllegalStateException(ex);
   ```

##########
File path: 
java/spi.java.hints/src/org/netbeans/modules/java/hints/spiimpl/Utilities.java
##########
@@ -1408,7 +1437,35 @@ protected JCCatch catchClause() {
             }
             return super.catchClause();
         }
+        
+        public com.sun.tools.javac.util.List<JCTree> 
classOrInterfaceOrRecordBodyDeclaration(com.sun.tools.javac.util.Name 
className, boolean isInterface, boolean isRecord) {
+
+            if (token.kind == TokenKind.IDENTIFIER) {
+                if (token.name().startsWith(dollar)) {
+                    com.sun.tools.javac.util.Name name = token.name();
+
+                    Token peeked = S.token(1);
+
+                    if (peeked.kind == TokenKind.SEMI) {
+                        nextToken();
+                        nextToken();
+
+                        return 
com.sun.tools.javac.util.List.<JCTree>of(F.Ident(name));
+                    }
+                }
+            }
 
+            com.sun.tools.javac.util.List<JCTree> result = null;
+            Class[] argsType = {com.sun.tools.javac.util.Name.class, 
boolean.class, boolean.class};
+            try {
+                result = (com.sun.tools.javac.util.List<JCTree>) 
MethodHandles.lookup().findSpecial(JavacParser.class, 
"classOrInterfaceOrRecordBodyDeclaration", 
MethodType.methodType(com.sun.tools.javac.util.List.class, argsType), 
JackpotJavacParser.class) // NOI18N
+                        .invoke(this, className, false, false);
+            } catch (Throwable ex) {
+                Logger.getLogger(Utilities.class.getName()).log(Level.SEVERE, 
null, ex);

Review comment:
       I think it should be fine to just fail here, shouldn't it (the method 
must exist, as the current method overrides it):
   ```suggestion
                   throw new IllegalStateException(ex);
   ```




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
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