[ https://issues.apache.org/jira/browse/NETBEANS-2584?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Svatopluk Dedic updated NETBEANS-2584: -------------------------------------- Description: During review of PR#1237, there were some glitches which may be handled better. None of them actually break code semantics or compilability, so I consider that an improvement. Set source level to 12 for the following snippet. {code:java} public class JavaApplication1 { /** * @param args the command line arguments */ public static void main(String[] args) { // TODO code application logic here int a = 0; int b = 2; } int f1(String p) { int a = 0; int b = 2; int r = 5; switch (p) { case "a": { if (a == 0) { break; } r = 1; break; } case "b": r = 2; break; // the ending brace will be placed at the 'case' line, not aligned with the 'switch' statement } int f2(String p) { int a = 0; int r; switch (p) { case "a": { r = 1; // if remains with an empty body. Ugly, but we need to ensure // that possible side effects from the tests happen. if (a == 0) { break; } break; } default: r = 3; } return r; } int f3(String p) { int a = 0; int b = 2; int r; // this switch is not recognized as a possible expression switch // but it could, the {} contains just an assignment. switch (p) { case "a": { r = 1; break; } case "b": r = 2; break; default: r = 3; break; } return r; } } {code} was: During review of PR#1237, there were some glitches which may be handled better. None of them actually break code semantics or compilability, so I consider that an improvement. Set source level to 12 for the following snippet. {code:java} public class JavaApplication1 { /** * @param args the command line arguments */ public static void main(String[] args) { // TODO code application logic here int a = 0; int b = 2; } int f1(String p) { int a = 0; int b = 2; int r = 5; switch (p) { case "a": { if (a == 0) { break; } r = 1; break; } case "b": r = 2; break; // the ending brace will be placed at the 'case' line, not aligned with the 'switch' statement } int f2(String p) { int a = 0; int r; switch (p) { case "a": { r = 1; // if remains with an empty body. Ugly, but we need to ensure // that possible side effects from the tests happen. if (a == 0) { break; } break; } default: r = 3; } return r; } int f3(String p) { int a = 0; int b = 2; int r; // this switch is not recognized as a possible expression switch // but it could, the {} contains just one statement switch (p) { case "a": { r = 1; break; } case "b": r = 2; break; default: r = 3; break; } return r; } } {code} > Unhandled cases in Convert to Rule / Expression switch Hint > ----------------------------------------------------------- > > Key: NETBEANS-2584 > URL: https://issues.apache.org/jira/browse/NETBEANS-2584 > Project: NetBeans > Issue Type: Improvement > Reporter: Svatopluk Dedic > Assignee: vikas kumar prabhakar > Priority: Major > > During review of PR#1237, there were some glitches which may be handled > better. None of them actually break code semantics or compilability, so I > consider that an improvement. > Set source level to 12 for the following snippet. > {code:java} > public class JavaApplication1 { > /** > * @param args the command line arguments > */ > public static void main(String[] args) { > // TODO code application logic here > int a = 0; > int b = 2; > } > > int f1(String p) { > int a = 0; > int b = 2; > int r = 5; > switch (p) { > case "a": { > if (a == 0) { > break; > } > r = 1; > break; > } > case "b": r = 2; break; > // the ending brace will be placed at the 'case' line, not aligned > with the 'switch' statement > } > int f2(String p) { > int a = 0; > int r; > switch (p) { > case "a": { > r = 1; > // if remains with an empty body. Ugly, but we need to ensure > // that possible side effects from the tests happen. > if (a == 0) { > break; > } > break; > } > default: r = 3; > } > return r; > } > > int f3(String p) { > int a = 0; > int b = 2; > int r; > > // this switch is not recognized as a possible expression switch > // but it could, the {} contains just an assignment. > switch (p) { > case "a": { > r = 1; > break; > } > > case "b": r = 2; break; > default: r = 3; break; > } > return r; > } > } > {code} -- This message was sent by Atlassian JIRA (v7.6.3#76005) --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@netbeans.apache.org For additional commands, e-mail: commits-h...@netbeans.apache.org For further information about the NetBeans mailing lists, visit: https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists