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 2019/05/13 08:48:32 UTC

[GitHub] [netbeans] rtaneja1 commented on a change in pull request #1237: [NETBEANS-2349] Convert switch typecast case to switch expression

rtaneja1 commented on a change in pull request #1237: [NETBEANS-2349] Convert switch typecast case to switch expression
URL: https://github.com/apache/netbeans/pull/1237#discussion_r283216738
 
 

 ##########
 File path: java/java.hints/src/org/netbeans/modules/java/hints/errors/Utilities.java
 ##########
 @@ -3247,10 +3249,20 @@ public Void visitIdentifier(IdentifierTree node, Void p) {
             if (isExpression) {
                 if (statements.get(0).getKind() == Tree.Kind.RETURN) {
                     body = ((JCTree.JCReturn) statements.get(0)).getExpression();
-                    isReturnExpression = true;
+                    switchType = SWITCH_TYPE.SIMPLIFIED_WITH_RETURN_CASE;
+                    if (body instanceof JCTree.JCTypeCast) {
+                        typeCast = ((JCTree.JCTypeCast)body).getType();
+                        body = ((JCTree.JCTypeCast)body).getExpression();
+                    }
                 } else {
+                    switchType = SWITCH_TYPE.SWITCH_EXPRESSION;
                     JCTree.JCExpressionStatement jceTree = (JCTree.JCExpressionStatement) statements.get(0);
                     body = ((JCTree.JCAssign) jceTree.expr).rhs;
+                    if (body instanceof JCTree.JCTypeCast) {
+                        switchType = SWITCH_TYPE.SIMPLIFIED_WITH_CAST_CASE;
 
 Review comment:
   same code as in if, move out? 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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