extract method object from expression: declare necessary variables after call to replace invoke() with correct getter

This commit is contained in:
anna
2010-12-29 16:21:13 +03:00
parent fa41e76126
commit 58c376fcde
7 changed files with 95 additions and 4 deletions
@@ -0,0 +1,7 @@
class Test {
void foo() {
int x = 0;
int y = <selection>x = 1</selection>;
System.out.println(x + y);
}
}
@@ -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;
}
}
}
@@ -0,0 +1,7 @@
class Test {
void foo() {
int x = 0;
int y = <selection>x++</selection>;
System.out.println(x + y);
}
}
@@ -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;
}
}
}