jlahoda commented on code in PR #5173:
URL: https://github.com/apache/netbeans/pull/5173#discussion_r1111309179


##########
java/java.editor.base/src/org/netbeans/modules/java/editor/base/semantic/UnusedDetector.java:
##########
@@ -597,5 +619,49 @@ private void handleDeclaration(TreePath path) {
                 }
             }
         }
+
+        @Override
+        public Void visitLiteral(LiteralTree node, Void p) {
+            if (node.getKind() == Kind.STRING_LITERAL) {
+                allStringLiterals.add((String) ((LiteralTree) 
node).getValue());

Review Comment:
   Sorry for late reply. Yes, this is for indirect lookups - if the lookup 
contains a method name, the `allStringLiterals` should not be used. This is all 
a heuristics (e.g. it never uses the `MethodType`, so if there are several 
private overloads, they will all be considered used, even those that will never 
be looked up). But, this is just a warning, I think it is fine to use sensible 
heuristics, and I am more fine with some false negatives (not found unused 
methods) than with false positives (used methods marked as unused).
   
   If the code is in a recognized pattern 
(`$lookup.findSomething($className.class, ...)`, the class in which the lookup 
is performed will be taken into consideration. If the pattern is different, the 
type won't be considered, and more methods will be potentially marked as used. 
This is again mostly a heuristics that should find a relatively typical pattern.
   
   This should all have zero effect on files which don't use 
`MethodHandles.Lookup`, which is a vast majority of files, and the proposed 
heuristics seemed like a reasonable tradeoff to me.
   



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