mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-17 07:20:53 +07:00
extract method object: created object name should be unique (suggestion)
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user