mbien commented on code in PR #4648:
URL: https://github.com/apache/netbeans/pull/4648#discussion_r975988809


##########
java/java.source.base/src/org/netbeans/modules/java/source/save/Reformatter.java:
##########
@@ -1151,7 +1151,7 @@ public Boolean visitVariable(VariableTree node, Void p) {
                                 newline();
                             else
                                 space();
-                        } else {
+                        } else if (sp.getStartPosition(root, mods) != 
sp.getStartPosition(root, node.getType())) {

Review Comment:
   the implicit `final` would have the same start position as the type (which 
is the next item in the tree I guess) because its hidden?
   
   I am wondering if this is just an impl detail or actually stable behavior, 
because there would be also the NOPOS constant
   
https://github.com/openjdk/jdk/blob/05d38604a2c620dcaf8682f02dae2fddab8e0c0b/src/jdk.compiler/share/classes/com/sun/source/util/SourcePositions.java#L41-L43
   which could be potentially returned in future?
   
   if implicit items have the same start and end pos we could extract this into:
   ```java
   private static boolean isHidden(CompilationUnitTree cut, Tree tree) {
       long start = sp.getStartPosition(cut, tree);
       long end = sp.getEndPosition(cut, tree);
       return start == end && start != javax.tools.Diagnostic.NOPOS;
   }
   ```
   Maybe that would be less likely to break on a javac update (assuming it 
works)?



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