mbien commented on code in PR #6415:
URL: https://github.com/apache/netbeans/pull/6415#discussion_r1317854672


##########
java/java.completion/src/org/netbeans/modules/java/completion/JavaCompletionTask.java:
##########
@@ -6597,4 +6620,16 @@ private static ElementKind 
simplifyElementKind(ElementKind kind) {
         }
         return kind;
     }
+
+    private static final Kind TEMPLATE;
+    static {
+        Kind template;
+        try {
+            template = Kind.valueOf("TEMPLATE");
+        } catch (IllegalArgumentException ex) {
+            template = null;
+        }
+        TEMPLATE = template;
+    }
+

Review Comment:
   nitpick: `TEMPLATE` should be now available due to nb-javac 21. I ran a 
quick test and could build and run on JDK 11 with this change.
   
   would simplify the switches:
   ```diff
   diff --git 
a/java/java.completion/src/org/netbeans/modules/java/completion/JavaCompletionTask.java
 
b/java/java.completion/src/org/netbeans/modules/java/completion/JavaCompletionTask.java
   index 6546786..3d31ae8 100644
   --- 
a/java/java.completion/src/org/netbeans/modules/java/completion/JavaCompletionTask.java
   +++ 
b/java/java.completion/src/org/netbeans/modules/java/completion/JavaCompletionTask.java
   @@ -56,7 +56,6 @@
    import static javax.lang.model.SourceVersion.RELEASE_10;
    import static javax.lang.model.SourceVersion.RELEASE_11;
    import static javax.lang.model.SourceVersion.RELEASE_16;
   -import static javax.lang.model.SourceVersion.RELEASE_19;
    import static javax.lang.model.SourceVersion.RELEASE_21;
    import static javax.lang.model.type.TypeKind.VOID;
    
   @@ -500,11 +499,8 @@
                case DECONSTRUCTION_PATTERN:
                    insideDeconstructionRecordPattern(env);
                    break;
   -            default:
   -                if ("TEMPLATE".equals(path.getLeaf().getKind().name())) {
   -                    insideStringTemplate(env);
   -                    break;
   -                }
   +            case TEMPLATE:
   +                insideStringTemplate(env);
                    break;
            }
        }
   @@ -6186,13 +6182,10 @@
                        break;
                    case BLOCK:
                        return null;
   -                default:
   -                    if (tree.getKind() == TEMPLATE) {
   -                        //TODO:can there be good smart types?
   -                        //(how about incomplete String templates?)
   -                        return null;
   -                    }
   -                    break;
   +                case TEMPLATE:
   +                    //TODO:can there be good smart types?
   +                    //(how about incomplete String templates?)
   +                    return null;
                }
                lastTree = tree;
                path = path.getParentPath();
   @@ -6621,15 +6614,4 @@
            return kind;
        }
    
   -    private static final Kind TEMPLATE;
   -    static {
   -        Kind template;
   -        try {
   -            template = Kind.valueOf("TEMPLATE");
   -        } catch (IllegalArgumentException ex) {
   -            template = null;
   -        }
   -        TEMPLATE = template;
   -    }
   -
    }
   
   ```



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

To unsubscribe, e-mail: [email protected]

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