mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-13 09:19:13 +07:00
Field can be local: added support for nested and local classes (IDEA-206647)
This commit is contained in:
+12
@@ -0,0 +1,12 @@
|
||||
// "Convert field to local variable in method 'test'" "true"
|
||||
class Foo {
|
||||
void test() {
|
||||
class Bar {
|
||||
|
||||
void test() {
|
||||
int x = 2; // could be local
|
||||
System.out.println(x);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
// "Convert to local" "true"
|
||||
class Outer {
|
||||
|
||||
void test() {
|
||||
class Local {
|
||||
|
||||
void foo() {
|
||||
String s = "1";
|
||||
System.out.println(s);
|
||||
}
|
||||
|
||||
void bar() {
|
||||
String s = "2";
|
||||
System.out.println(s);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// "Convert field to local variable in method 'test'" "true"
|
||||
class Foo {
|
||||
static class Bar {
|
||||
|
||||
void test() {
|
||||
int x = 2; // could be local
|
||||
System.out.println(x);
|
||||
}
|
||||
}
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
// "Convert to local" "true"
|
||||
class Test {
|
||||
|
||||
private Runnable r = () -> {
|
||||
String field = "foo";
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// "Fix all 'Field can be local' problems in file" "false"
|
||||
class Outer {
|
||||
|
||||
void test(Inner inner) {
|
||||
System.out.println(inner.field);
|
||||
}
|
||||
|
||||
class Inner {
|
||||
private final String f<caret>ield;
|
||||
|
||||
Inner(String field) {
|
||||
this.field = field;
|
||||
}
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// "Convert field to local variable in method 'test'" "true"
|
||||
class Foo {
|
||||
void test() {
|
||||
class Bar {
|
||||
private int <caret>x;
|
||||
|
||||
void test() {
|
||||
x = 2; // could be local
|
||||
System.out.println(x);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
// "Convert to local" "true"
|
||||
class Outer {
|
||||
|
||||
void test() {
|
||||
class Local {
|
||||
private String <caret>s;
|
||||
|
||||
void foo() {
|
||||
s = "1";
|
||||
System.out.println(s);
|
||||
}
|
||||
|
||||
void bar() {
|
||||
s = "2";
|
||||
System.out.println(s);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// "Convert field to local variable in method 'test'" "true"
|
||||
class Foo {
|
||||
static class Bar {
|
||||
private int <caret>x;
|
||||
|
||||
void test() {
|
||||
x = 2; // could be local
|
||||
System.out.println(x);
|
||||
}
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// "Convert to local" "true"
|
||||
class Test {
|
||||
|
||||
private String <caret>field;
|
||||
|
||||
private Runnable r = () -> {
|
||||
field = "foo";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user