Files
openide/java/java-tests/testData/inspection/dataFlow/fixture/CellsComplex.java
Tagir Valeev 9c1be97480 DFA: support unary ++/-- (IDEA-221657)
Also: define binop widening based on CFG, not on PSI (so loops generated via inliners are also supported)
Better squashing

GitOrigin-RevId: e1e15652b0363357f6d8dd40c6048e09ae436d09
2019-09-11 07:33:10 +00:00

42 lines
975 B
Java

class Foo {
// TODO: make not complex
public static int[] <weak_warning descr="Method 'cells' is complex: data flow results could be imprecise">cells</weak_warning>(int[] start, int[] end) {
int overlap = 0;
int gaps = 0;
for (int i = 0, j = 0; j < end.length; ) {
if (i < start.length && start[i] < end[j]) {
overlap++;
i++;
} else {
j++;
overlap--;
}
if (overlap == 0) {
gaps++;
}
}
int[] cells = new int[gaps * 2];
overlap = 0;
gaps = 0;
int previousOverlap = 0;
for (int i = 0, j = 0; j < end.length; ) {
if (i < start.length && start[i] < end[j]) {
overlap++;
if (previousOverlap == 0) {
cells[gaps++] = start[i];
}
i++;
} else {
overlap--;
if (overlap == 0) {
cells[gaps++] = end[j];
}
j++;
}
previousOverlap = overlap;
}
return cells;
}
}