extract method object: created object name should be unique (suggestion)

This commit is contained in:
anna
2010-11-15 16:09:03 +03:00
parent ce2ffdf3c8
commit 0c79b901e1
4 changed files with 65 additions and 1 deletions

View File

@@ -0,0 +1,18 @@
class A {
int foo() {
int x = 45;
int y = 46;
int inner = 47;
<selection>x = y + 1;
y = 77;</selection>
x = y + x + 45;
boolean z = true;
if (z) {
return y;
} else {
x = y;
}
y = 45;
return x;
}
}

View File

@@ -0,0 +1,42 @@
class A {
int foo() {
int x = 45;
int y = 46;
int inner = 47;
Inner inner1 = new Inner(y).invoke();
y = inner1.getY();
x = inner1.getX();
x = y + x + 45;
boolean z = true;
if (z) {
return y;
} else {
x = y;
}
y = 45;
return x;
}
private class Inner {
private int y;
private int x;
public Inner(int y) {
this.y = y;
}
public int getX() {
return x;
}
public int getY() {
return y;
}
public Inner invoke() {
x = y + 1;
y = 77;
return this;
}
}
}