sdedic commented on a change in pull request #650: [NETBEANS-1075]-Adding var hints for enhanced-for-loop URL: https://github.com/apache/incubator-netbeans/pull/650#discussion_r209255399
########## File path: java.hints/src/org/netbeans/modules/java/hints/jdk/ConvertToVarHint.java ########## @@ -159,8 +191,9 @@ private static boolean preConditionChecker(HintContext ctx) { } // hint is not applicable for compound variable declaration. - if (info.getTreeUtilities().isPartOfCompoundVariableDeclaration(treePath.getLeaf())) + if (info.getTreeUtilities().isPartOfCompoundVariableDeclaration(treePath.getLeaf())) { return false; + } // hint is not applicable for variable declaration where type is already 'var' return !info.getTreeUtilities().isVarType(treePath); Review comment: for enhanced `for` loop, this helper loops until the nearest textually following assignment, definitely not good ! It should also watch for `JavaTokenId.COLON`. Perhaps also `JavaTokenId.SEMICOLON`, for the case a client executes it on a declaration without an assignment. or `JavaTokenId.RPAREN` (end of enhanced-loop header). ---------------------------------------------------------------- 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: us...@infra.apache.org With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: notifications-unsubscr...@netbeans.apache.org For additional commands, e-mail: notifications-h...@netbeans.apache.org For further information about the NetBeans mailing lists, visit: https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists