mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-10 13:17:09 +07:00
extract method object: avoid element invalidation by batch update (IDEA-98365)
This commit is contained in:
+37
@@ -0,0 +1,37 @@
|
||||
import java.util.*;
|
||||
|
||||
public class ABug {
|
||||
|
||||
private String drinkBear(String amount) {
|
||||
String firstTime = "asdf";
|
||||
|
||||
if (firstTime == null)
|
||||
return "loser";
|
||||
|
||||
ArrayList<String> bottles = new ArrayList<>();
|
||||
bottles.add("asdf");
|
||||
|
||||
<selection>List<String> errors = new ArrayList<>();
|
||||
|
||||
int money = 0;
|
||||
int nCount = 0;
|
||||
int rCount = 0;
|
||||
int wCount = 0;
|
||||
char[] tripel = new char[bottles.size()];
|
||||
boolean no33pr = false;
|
||||
int first = 0;
|
||||
int last = 0;
|
||||
if (true) return null;</selection>
|
||||
|
||||
boolean unhappy = no33pr && first || no33pr && last;
|
||||
|
||||
String result = amount + Arrays.toString(tripel) + rCount + wCount + nCount + money + errors;
|
||||
|
||||
if (!unhappy)
|
||||
result += "happy";
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
+113
@@ -0,0 +1,113 @@
|
||||
import java.util.*;
|
||||
|
||||
public class ABug {
|
||||
|
||||
private String drinkBear(String amount) {
|
||||
String firstTime = "asdf";
|
||||
|
||||
if (firstTime == null)
|
||||
return "loser";
|
||||
|
||||
ArrayList<String> bottles = new ArrayList<>();
|
||||
bottles.add("asdf");
|
||||
|
||||
Inner inner = new Inner(bottles).invoke();
|
||||
if (inner.is()) return null;
|
||||
boolean no33pr = inner.isNo33pr();
|
||||
int first = inner.getFirst();
|
||||
int last = inner.getLast();
|
||||
char[] tripel = inner.getTripel();
|
||||
int rCount = inner.getrCount();
|
||||
int wCount = inner.getwCount();
|
||||
int nCount = inner.getnCount();
|
||||
int money = inner.getMoney();
|
||||
List<String> errors = inner.getErrors();
|
||||
|
||||
boolean unhappy = no33pr && first || no33pr && last;
|
||||
|
||||
String result = amount + Arrays.toString(tripel) + rCount + wCount + nCount + money + errors;
|
||||
|
||||
if (!unhappy)
|
||||
result += "happy";
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private class Inner {
|
||||
private boolean myResult;
|
||||
private ArrayList<String> bottles;
|
||||
private List<String> errors;
|
||||
private int money;
|
||||
private int nCount;
|
||||
private int rCount;
|
||||
private int wCount;
|
||||
private char[] tripel;
|
||||
private boolean no33pr;
|
||||
private int first;
|
||||
private int last;
|
||||
|
||||
public Inner(ArrayList<String> bottles) {
|
||||
this.bottles = bottles;
|
||||
}
|
||||
|
||||
boolean is() {
|
||||
return myResult;
|
||||
}
|
||||
|
||||
public List<String> getErrors() {
|
||||
return errors;
|
||||
}
|
||||
|
||||
public int getMoney() {
|
||||
return money;
|
||||
}
|
||||
|
||||
public int getnCount() {
|
||||
return nCount;
|
||||
}
|
||||
|
||||
public int getrCount() {
|
||||
return rCount;
|
||||
}
|
||||
|
||||
public int getwCount() {
|
||||
return wCount;
|
||||
}
|
||||
|
||||
public char[] getTripel() {
|
||||
return tripel;
|
||||
}
|
||||
|
||||
public boolean isNo33pr() {
|
||||
return no33pr;
|
||||
}
|
||||
|
||||
public int getFirst() {
|
||||
return first;
|
||||
}
|
||||
|
||||
public int getLast() {
|
||||
return last;
|
||||
}
|
||||
|
||||
public Inner invoke() {
|
||||
errors = new ArrayList<>();
|
||||
|
||||
money = 0;
|
||||
nCount = 0;
|
||||
rCount = 0;
|
||||
wCount = 0;
|
||||
tripel = new char[bottles.size()];
|
||||
no33pr = false;
|
||||
first = 0;
|
||||
last = 0;
|
||||
if (true) {
|
||||
myResult = true;
|
||||
return this;
|
||||
}
|
||||
myResult = false;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user