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_r208540876
 
 

 ##########
 File path: 
java.hints/src/org/netbeans/modules/java/hints/jdk/ConvertToVarHint.java
 ##########
 @@ -209,17 +243,15 @@ 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();
+            return !((!Utilities.isValidType(initTypeMirror)) || 
(!ctx.getInfo().getTypes().isSameType(variableTypeMirror, 
Utilities.resolveCapturedType(ctx.getInfo(), initTypeMirror))));
+        } else if (expressionTreePath != null) {
+            ExecutableElement iterator = 
HintsUtils.findIterable(ctx.getInfo());
+            return !(iterator == null);
 
 Review comment:
   `iterator != null`

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

Reply via email to