mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
convert to local for switch block: add decl before switch (IDEA-181440)
This commit is contained in:
+8
-1
@@ -132,7 +132,14 @@ public abstract class BaseConvertToLocalQuickFix<V extends PsiVariable> implemen
|
||||
variable,
|
||||
references,
|
||||
delete,
|
||||
declaration -> anchorBlock.addBefore(declaration, anchor)
|
||||
declaration -> {
|
||||
PsiElement parent = anchorBlock.getParent();
|
||||
if (parent instanceof PsiSwitchStatement) {
|
||||
PsiElement switchContainer = parent.getParent();
|
||||
return switchContainer.addBefore(declaration, parent);
|
||||
}
|
||||
return anchorBlock.addBefore(declaration, anchor);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
// "Convert to local" "true"
|
||||
class TestFieldConversion
|
||||
{
|
||||
|
||||
public void someMethod(int s) {
|
||||
int someInt = 0;
|
||||
switch (s) {
|
||||
case 1:
|
||||
System.out.println(someInt);
|
||||
break;
|
||||
case 3:
|
||||
System.out.println(someInt);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
// "Convert to local" "true"
|
||||
class TestFieldConversion
|
||||
{
|
||||
private int som<caret>eInt = 0;
|
||||
|
||||
public void someMethod(int s) {
|
||||
switch (s) {
|
||||
case 1:
|
||||
System.out.println(someInt);
|
||||
break;
|
||||
case 3:
|
||||
System.out.println(someInt);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user