[java-intentions] ConvertSwitchToIfIntention: fix brace handling

Fixes EA-795482 - IOE: JavaParserUtil.parseFragment

GitOrigin-RevId: 63fe89da84e4432fab8f8f191c139add97553640
This commit is contained in:
Tagir Valeev
2023-02-13 10:13:31 +01:00
committed by intellij-monorepo-bot
parent e947f7b9a8
commit 2b2d79fb6a
7 changed files with 68 additions and 2 deletions

View File

@@ -0,0 +1,12 @@
// "Replace 'switch' with 'if'" "true-preview"
class X {
void test(int x) {
if (x == 1) {
{
System.out.println("hello");
}
} else if (x == 2) {
System.out.println("oops");
}
}
}

View File

@@ -0,0 +1,12 @@
// "Replace 'switch' with 'if'" "true-preview"
class X {
void test(int x) {
if (x == 1) {
{
System.out.println("hello");
}
} else if (x == 2) {
System.out.println("oops");
}
}
}

View File

@@ -0,0 +1,10 @@
// "Replace 'switch' with 'if'" "true-preview"
class X {
void test(int x) {
if (x == 1) {
System.out.println("");
} else if (x == 2) {
System.out.println("oops");
}
}
}

View File

@@ -0,0 +1,11 @@
// "Replace 'switch' with 'if'" "true-preview"
class X {
void test(int x) {
<caret>switch (x) {
case 1 -> {{
System.out.println("hello");
}}
case 2 -> System.out.println("oops");
}
}
}

View File

@@ -0,0 +1,12 @@
// "Replace 'switch' with 'if'" "true-preview"
class X {
void test(int x) {
<caret>switch (x) {
case 1 -> {
{
System.out.println("hello");
}}
case 2 -> System.out.println("oops");
}
}
}

View File

@@ -0,0 +1,9 @@
// "Replace 'switch' with 'if'" "true-preview"
class X {
void test(int x) {
<caret>switch (x) {
case 1 -> { System.out.println("");}
case 2 -> System.out.println("oops");
}
}
}