mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-06 03:21:12 +07:00
extract method object: wrap if/loop bodies in {} when needed (IDEA-92156)
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
class Test {
|
||||
void foo(String[] args){
|
||||
for (String aArg : args) {
|
||||
<selection>boolean a = aArg == null;
|
||||
if (aArg == null) continue;</selection>
|
||||
|
||||
System.out.println(aArg + a);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
class Test {
|
||||
void foo(String[] args){
|
||||
for (String aArg : args) {
|
||||
Inner inner = new Inner(aArg).invoke();
|
||||
if (inner.is()) continue;
|
||||
boolean a = inner.isA();
|
||||
|
||||
System.out.println(aArg + a);
|
||||
}
|
||||
}
|
||||
|
||||
private class Inner {
|
||||
private boolean myResult;
|
||||
private String aArg;
|
||||
private boolean a;
|
||||
|
||||
public Inner(String aArg) {
|
||||
this.aArg = aArg;
|
||||
}
|
||||
|
||||
boolean is() {
|
||||
return myResult;
|
||||
}
|
||||
|
||||
public boolean isA() {
|
||||
return a;
|
||||
}
|
||||
|
||||
public Inner invoke() {
|
||||
a = aArg == null;
|
||||
if (aArg == null) {
|
||||
myResult = true;
|
||||
return this;
|
||||
}
|
||||
myResult = false;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user