errael commented on a change in pull request #2126:
URL: https://github.com/apache/netbeans/pull/2126#discussion_r419052793



##########
File path: 
java/java.source.base/src/org/netbeans/modules/java/source/save/CasualDiff.java
##########
@@ -535,8 +535,18 @@ public int endPos(JCTree t) {
             VariableTree vt = fgt.getVariables().get(fgt.getVariables().size() 
- 1);
             return TreeInfo.getEndPos((JCTree)vt, oldTopLevel.endPositions);
         }
-        return TreeInfo.getEndPos(t, oldTopLevel.endPositions);
+        int endPos = TreeInfo.getEndPos(t, oldTopLevel.endPositions);
+
+        // [NETBEANS-4299], catch a synthetic annotation attribute and try rhs
+        if (endPos == Position.NOPOS && t instanceof JCAssign) {
+            JCAssign assign = (JCAssign)t;
+            if (assign.lhs instanceof JCIdent
+                    && ((JCIdent)assign.lhs).sym instanceof 
Symbol.MethodSymbol) {

Review comment:
       I guess a regular/real assignment would have been in 
oldTopLevel.endPositions. So since it failed to get endPos as an assignment, 
all that's needed is to simply check the rhs (the end should be after that). 
Checking the lhs shouldn't be needed at all. I was being most conservative, but 
any rhs match should be good. I guess it could just be
   ```
   // [NETBEANS-4299], catch a synthetic annotation attribute and try rhs
   if (endPos == Position.NOPOS && t instanceof JCAssign) {
       endPos = TreeInfo.getEndPos(((JCAssign)t).rhs, oldTopLevel.endPositions);
   }
   ```
   That feels less conservative and I don't know anything about the quirks in 
the trees.
   
   @jlahoda  your call. Do you want either change or as is?




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

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