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 2022/02/01 10:41:35 UTC

[GitHub] [netbeans] mbien commented on a change in pull request #3540: [jackpot] DefaultRuleUtilities::referencedIn fix for single variable matching

mbien commented on a change in pull request #3540:
URL: https://github.com/apache/netbeans/pull/3540#discussion_r796465847



##########
File path: java/java.hints.declarative/src/org/netbeans/modules/java/hints/declarative/conditionapi/Matcher.java
##########
@@ -90,25 +91,38 @@ public Void scan(Tree tree, Void p) {
         return result[0];
     }
 
+    @SuppressWarnings("BoxedValueEquality")
     public boolean referencedIn(@NonNull Variable variable, @NonNull Variable in) {
-        final Element e = ctx.ctx.getInfo().getTrees().getElement(ctx.getSingleVariable(variable));
+        final Trees trees = ctx.ctx.getInfo().getTrees();
+        final Element e = trees.getElement(ctx.getSingleVariable(variable));
 
         if (e == null) { //TODO: check also error
             return false;
         }
 
+        TreePath v = ctx.getSingleVariable(in);
+        if (v != null && e.equals(trees.getElement(v))) {

Review comment:
       haven't considered that. Fixed + added another test for the mentioned case.




-- 
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: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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