lbownik commented on code in PR #5173:
URL: https://github.com/apache/netbeans/pull/5173#discussion_r1059784644
##########
java/java.editor.base/src/org/netbeans/modules/java/editor/base/semantic/UnusedDetector.java:
##########
@@ -597,5 +615,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());
+ }
+ return super.visitLiteral(node, p);
+ }
+
+ @Override
+ public Void visitMethodInvocation(MethodInvocationTree node, Void p) {
+ Element invoked = info.getTrees().getElement(new
TreePath(getCurrentPath(), node.getMethodSelect()));
+ if (invoked != null && invoked.getEnclosingElement() ==
methodHandlesLookup && node.getArguments().size() > 0) {
+ ExpressionTree clazz = node.getArguments().get(0);
+ Element lookupType = null;
+ if (clazz.getKind() == Kind.MEMBER_SELECT) {
+ MemberSelectTree mst = (MemberSelectTree) clazz;
+ if (mst.getIdentifier().contentEquals("class")) {
+ lookupType = info.getTrees().getElement(new
TreePath(new TreePath(getCurrentPath(), clazz), mst.getExpression()));
+ }
+ }
+ String lookupName = null;
+ if (node.getArguments().size() > 1) {
Review Comment:
lines 640 - 645 could be extracted to a separate method
--
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