You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@netbeans.apache.org by "Svatopluk Dedic (JIRA)" <ji...@apache.org> on 2019/05/22 08:38:00 UTC
[jira] [Created] (NETBEANS-2584) Unhandled cases in Convert to Rule
/ Expression switch Hint
Svatopluk Dedic created NETBEANS-2584:
-----------------------------------------
Summary: 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
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}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@netbeans.apache.org
For additional commands, e-mail: commits-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists