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 2018/05/18 14:48:17 UTC

[GitHub] sdedic commented on a change in pull request #547: [NETBEANS-764] JDK10-LVTI: Skip ConvertToVar hint for compound variable declaration

sdedic commented on a change in pull request #547: [NETBEANS-764] JDK10-LVTI: Skip ConvertToVar hint for compound variable declaration
URL: https://github.com/apache/incubator-netbeans/pull/547#discussion_r189292326
 
 

 ##########
 File path: java.source.base/src/org/netbeans/api/java/source/TreeUtilities.java
 ##########
 @@ -1883,6 +1883,51 @@ public boolean isEndOfCompoundVariableDeclaration(@NonNull Tree tree) {
         return false;
     }
  
+    /**
+     * Checks whether tree is part of compound variable declaration.
+     * {@link Tree}.
+     *
+     * @param tree the tree{@link Tree}
+     * @return true if tree is part of compound variable declaration else return
+     * false.
+     */
+    public boolean isPartOfCompoundVariableDeclaration(@NonNull Tree tree) {
+        TokenSequence<JavaTokenId> tokenSequence = tokensFor(tree);
+
+        if (tree.getKind() != Tree.Kind.VARIABLE) {
+            return false;
+        }
+
+        // If tree ends with comma then tree is part of compound variable declaration.
+        tokenSequence.moveEnd();
+        if (tokenSequence.movePrevious() && tokenSequence.token().id() == JavaTokenId.COMMA) {
 
 Review comment:
   I didn't try - sorry. But will it work if there's a whitespace between identifier and the following comma: `int i = 10 , j = 1` ?
   

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

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