mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
TrackingRunner: prefer reporting exact place where relation was established (IDEA-238060)
GitOrigin-RevId: 2f476f1ab1ed75530cb21597d199e86c49703b10
This commit is contained in:
committed by
intellij-monorepo-bot
parent
5398b343e8
commit
103a0c382b
+12
-20
@@ -1382,26 +1382,18 @@ public class TrackingRunner extends DataFlowRunner {
|
||||
}
|
||||
|
||||
private static MemoryStateChange findRelationAddedChange(MemoryStateChange history, DfaVariableValue var, Relation relation) {
|
||||
List<RelationType> subRelations;
|
||||
switch (relation.myRelationType) {
|
||||
case NE:
|
||||
if (relation.myCounterpart.getDfType() instanceof DfConstantType) {
|
||||
return history.findRelation(var, rel -> rel.equals(relation) ||
|
||||
rel.myRelationType == RelationType.EQ &&
|
||||
rel.myCounterpart.getDfType() instanceof DfConstantType,
|
||||
true);
|
||||
}
|
||||
subRelations = Arrays.asList(RelationType.NE, RelationType.GT, RelationType.LT);
|
||||
break;
|
||||
case LE:
|
||||
subRelations = Arrays.asList(RelationType.EQ, RelationType.LT);
|
||||
break;
|
||||
case GE:
|
||||
subRelations = Arrays.asList(RelationType.EQ, RelationType.GT);
|
||||
break;
|
||||
default:
|
||||
subRelations = Collections.singletonList(relation.myRelationType);
|
||||
if (relation.myRelationType == RelationType.NE && relation.myCounterpart.getDfType() instanceof DfConstantType) {
|
||||
return history.findRelation(var, rel -> rel.equals(relation) ||
|
||||
rel.myRelationType == RelationType.EQ &&
|
||||
rel.myCounterpart.getDfType() instanceof DfConstantType,
|
||||
true);
|
||||
}
|
||||
return history.findRelation(var, rel -> rel.myCounterpart == relation.myCounterpart && subRelations.contains(rel.myRelationType), true);
|
||||
MemoryStateChange exact = history.findRelation(var, rel -> rel.myCounterpart == relation.myCounterpart &&
|
||||
relation.myRelationType.equals(rel.myRelationType), true);
|
||||
if (exact != null) {
|
||||
return exact;
|
||||
}
|
||||
return history.findRelation(var, rel -> rel.myCounterpart == relation.myCounterpart &&
|
||||
relation.myRelationType.isSubRelation(rel.myRelationType), true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
Value is always false (i == expected; line#15)
|
||||
Condition 'i != expected' was checked before (i == expected; line#9)
|
||||
*/
|
||||
class A
|
||||
void compareInts(int i) {
|
||||
int expected = new Random().nextInt(100);
|
||||
int result;
|
||||
if (i == expected) {
|
||||
result = 0;
|
||||
}
|
||||
else if (i < expected) {
|
||||
result = -1;
|
||||
}
|
||||
else if (<selection>i == expected</selection>) {
|
||||
result = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
@@ -182,4 +182,5 @@ public class DataFlowInspectionTrackerTest extends LightJavaCodeInsightFixtureTe
|
||||
public void testMergeOnAnd() { doTest(); }
|
||||
public void testPassedNotNull() { doTest(); }
|
||||
public void testClassCheckInStream() { doTest(); }
|
||||
public void testEqualsLessEquals() { doTest(); }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user