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/09/04 08:36:19 UTC

[GitHub] sarveshkesharwani commented on a change in pull request #650: [NETBEANS-1075]-Adding var hints for enhanced-for-loop

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

 ##########
 File path: java.hints/src/org/netbeans/modules/java/hints/jdk/ConvertToVarHint.java
 ##########
 @@ -209,17 +228,18 @@ private static boolean isValidVarType(HintContext ctx) {
                 default:
                     break;
             }
+            // variable initializer type should be same as variable type.
+            TypeMirror initTypeMirror = ctx.getInfo().getTrees().getTypeMirror(initTreePath);
+            TypeMirror variableTypeMirror = ctx.getInfo().getTrees().getElement(treePath).asType();
+            if ((!Utilities.isValidType(initTypeMirror)) || (!ctx.getInfo().getTypes().isSameType(variableTypeMirror, Utilities.resolveCapturedType(ctx.getInfo(), initTypeMirror)))) {
+                return false;
+            }
+            return true;
+        } else if (expressionTreePath != null) {
+            ExecutableElement iterator = ExpandEnhancedForLoop.findIterable(ctx.getInfo());
+            return (iterator != null);
 
 Review comment:
   @rtaneja1 , Thanks for pointing this out. I have fixed this in the latest commit and I have added a test for this as well.

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