sdedic commented on a change in pull request #997: Simplifying semantic 
highlighter.
URL: https://github.com/apache/incubator-netbeans/pull/997#discussion_r234197828
 
 

 ##########
 File path: 
java/java.editor.base/src/org/netbeans/modules/java/editor/base/semantic/SemanticHighlighterBase.java
 ##########
 @@ -727,6 +630,76 @@ private void handlePossibleIdentifier(TreePath expr, 
Collection<UseTypes> type,
             }
             
             if (c != null) {
+                Collection<UseTypes> type = EnumSet.noneOf(UseTypes.class);
+
+                if (decl.getKind().isClass() || decl.getKind().isInterface()) {
+                    if (!declaration) {
+                        type.add(UseTypes.CLASS_USE);
+                    }
+                } else if (decl.getKind().isField() || 
isLocalVariableClosure(decl)) {
+                    if (!declaration) {
+                        TreePath pathToCheck = getCurrentPath();
+                        while (true) {
+                            if 
(pathToCheck.getParentPath().getLeaf().getKind() == Kind.POSTFIX_DECREMENT ||
+                                
pathToCheck.getParentPath().getLeaf().getKind() == Kind.POSTFIX_INCREMENT ||
+                                
pathToCheck.getParentPath().getLeaf().getKind() == Kind.PREFIX_DECREMENT ||
+                                
pathToCheck.getParentPath().getLeaf().getKind() == Kind.PREFIX_INCREMENT) {
+                                type.add(UseTypes.WRITE);
+                                pathToCheck = pathToCheck.getParentPath();
+                                continue;
+                            }
+                            if 
(CompoundAssignmentTree.class.isAssignableFrom(pathToCheck.getParentPath().getLeaf().getKind().asInterface())
 &&
+                                ((CompoundAssignmentTree) 
pathToCheck.getParentPath().getLeaf()).getVariable() == pathToCheck.getLeaf()) {
+                                type.add(UseTypes.WRITE);
+                                pathToCheck = pathToCheck.getParentPath();
+                                continue;
+                            }
+                            break;
+                        }
+                        if (pathToCheck.getParentPath().getLeaf().getKind() == 
Kind.ASSIGNMENT &&
+                            ((AssignmentTree) 
pathToCheck.getParentPath().getLeaf()).getVariable() == pathToCheck.getLeaf()) {
+                            type.add(UseTypes.WRITE);
 
 Review comment:
   It took me a while to infer that this branch will never execute after 
conditions in the above `while` are statisifed :-) It uses `pathToCheck` but in 
the case `pathToCheck != getCurrentPath()` the condition can never be true, 
right ?
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

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