mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
extract method object from expression: declare necessary variables after call to replace invoke() with correct getter
This commit is contained in:
+7
@@ -0,0 +1,7 @@
|
||||
class Test {
|
||||
void foo() {
|
||||
int x = 0;
|
||||
int y = <selection>x = 1</selection>;
|
||||
System.out.println(x + y);
|
||||
}
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
class Test {
|
||||
void foo() {
|
||||
int x = 0;
|
||||
Inner inner = new Inner().invoke();
|
||||
x = inner.getX();
|
||||
int y = x;
|
||||
System.out.println(x + y);
|
||||
}
|
||||
|
||||
private class Inner {
|
||||
private int x;
|
||||
|
||||
public int getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
public Inner invoke() {
|
||||
x = 1;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
class Test {
|
||||
void foo() {
|
||||
int x = 0;
|
||||
int y = <selection>x++</selection>;
|
||||
System.out.println(x + y);
|
||||
}
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
class Test {
|
||||
void foo() {
|
||||
int x = 0;
|
||||
Inner inner = new Inner(x).invoke();
|
||||
x = inner.getX();
|
||||
int y = x;
|
||||
System.out.println(x + y);
|
||||
}
|
||||
|
||||
private class Inner {
|
||||
private int x;
|
||||
|
||||
public Inner(int x) {
|
||||
this.x = x;
|
||||
}
|
||||
|
||||
public int getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
public Inner invoke() {
|
||||
x++;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user