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/05 09:38:02 UTC

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

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

 ##########
 File path: java.hints/src/org/netbeans/modules/java/hints/jdk/ConvertToVarHint.java
 ##########
 @@ -237,6 +239,17 @@ private static boolean isValidVarType(HintContext ctx) {
             return true;
         } else if (expressionTreePath != null) {
             ExecutableElement iterator = ExpandEnhancedForLoop.findIterable(ctx.getInfo());
+            TypeMirror expTypeMirror = ctx.getInfo().getTrees().getTypeMirror(expressionTreePath);
+            TypeMirror typeTypeMirror = ctx.getInfo().getTrees().getTypeMirror(typeTreePath);
+            if (expTypeMirror.getKind() == TypeKind.DECLARED) {
+                DeclaredType dt = (DeclaredType) expTypeMirror;
+                if (dt.getTypeArguments().size() > 0) {
 
 Review comment:
   Please handle array types as well, eg: String[] arr = {"1", "2"}; for (Object o : arr)

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