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_r210187094
########## File path: java.hints/src/org/netbeans/modules/java/hints/jdk/ConvertVarToExplicitType.java ########## @@ -152,16 +153,18 @@ private static boolean isLocalVarType(HintContext ctx) { } TreePath treePath = ctx.getPath(); - EnhancedForLoopTree efl = null; - TypeMirror expressionType = null; - if (treePath.getLeaf() instanceof EnhancedForLoopTree) { - efl = (EnhancedForLoopTree) treePath.getLeaf(); - expressionType = ctx.getInfo().getTrees().getTypeMirror(new TreePath(treePath, efl.getExpression())); - } - // should be local variable - // Can either be a local variable or iterator in enhanced-for-loop - if ((info.getTrees().getElement(treePath) != null && info.getTrees().getElement(treePath).getKind() != ElementKind.LOCAL_VARIABLE) && expressionType == null) { - return false; + if (treePath.getLeaf().getKind() == Tree.Kind.ENHANCED_FOR_LOOP) { Review comment: Lines 156-167 seem identical to `ConvertToVarHint.java:175-187`. The classes are in the same package; could the code be shared (I think no instance vars are used). ---------------------------------------------------------------- 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