ConvertSwitchToIfIntention: better comments handling

This commit is contained in:
Tagir Valeev
2018-10-23 15:34:51 +07:00
parent fdce964e39
commit 747aec38c9
5 changed files with 48 additions and 5 deletions

View File

@@ -0,0 +1,13 @@
// "Replace 'switch' with 'if'" "true"
class Foo {
Object foo(int x) {
if (x == 1) { // not needed
return null;
} else if (x == 2) {// not needed
return null;
} else if (x == 4) {
return "foo";
}
return null;
}
}

View File

@@ -1,13 +1,13 @@
// "Replace 'switch' with 'if'" "true"
class X {
public void doSomething( String value) {
//comment1
//comment4
//comment6
//comment7
if ("case1".equals(value)) {//comment2
if ("case1".equals(value)) {//comment1
//comment2
//comment3
} else if ("case2".equals(value)) {//comment5
} else if ("case2".equals(value)) {//comment4
//comment5
}//comment8
}
}

View File

@@ -0,0 +1,15 @@
// "Replace 'switch' with 'if'" "true"
class Foo {
Object foo(int x) {
sw<caret>itch (x) {
case 1: // not needed
return null;
case 2:// not needed
return null;
case 4:
return "foo";
default:
return null;
}
}
}