mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
+4
-11
@@ -32,7 +32,6 @@ import com.intellij.psi.util.PropertyUtilBase;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.siyeh.ig.psiutils.ExpectedTypeUtils;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -62,7 +61,7 @@ public class DfaExpressionFactory {
|
||||
}
|
||||
|
||||
private final DfaValueFactory myFactory;
|
||||
private final Map<Object, PsiVariable> myMockIndices = ContainerUtil.newHashMap();
|
||||
private final Map<Integer, PsiVariable> myMockIndices = ContainerUtil.newHashMap();
|
||||
|
||||
public DfaExpressionFactory(DfaValueFactory factory) {
|
||||
myFactory = factory;
|
||||
@@ -129,14 +128,7 @@ public class DfaExpressionFactory {
|
||||
private DfaValue createReferenceValue(@NotNull PsiReferenceExpression refExpr) {
|
||||
PsiModifierListOwner var = getAccessedVariableOrGetter(refExpr.resolve());
|
||||
if (var == null) {
|
||||
if (!(refExpr.getParent() instanceof PsiMethodCallExpression)) {
|
||||
String name = refExpr.getReferenceName();
|
||||
PsiType expectedType = ExpectedTypeUtils.findExpectedType(refExpr, false);
|
||||
if (name != null && expectedType != null) {
|
||||
var = myMockIndices.computeIfAbsent(name, n -> new LightVariableBuilder<>("$unresolved$" + n, expectedType, refExpr));
|
||||
}
|
||||
}
|
||||
if (var == null) return null;
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!var.hasModifierProperty(PsiModifier.VOLATILE)) {
|
||||
@@ -220,7 +212,8 @@ public class DfaExpressionFactory {
|
||||
private PsiVariable getArrayIndexVariable(@Nullable PsiExpression indexExpression) {
|
||||
Object constant = JavaConstantExpressionEvaluator.computeConstantExpression(indexExpression, false);
|
||||
if (constant instanceof Integer && ((Integer)constant).intValue() >= 0) {
|
||||
return myMockIndices.computeIfAbsent(constant, k -> new LightVariableBuilder<>("$array$index$" + k, PsiType.INT, indexExpression));
|
||||
return myMockIndices
|
||||
.computeIfAbsent((Integer)constant, k -> new LightVariableBuilder<>("$array$index$" + k, PsiType.INT, indexExpression));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -1,61 +0,0 @@
|
||||
import java.util.*;
|
||||
|
||||
public class UnresolvedInTernary {
|
||||
void sideEffect() {
|
||||
System.out.println("side effect");
|
||||
}
|
||||
|
||||
void sideEffectTest() {
|
||||
if(<error descr="Cannot resolve symbol 'test'">test</error>) {
|
||||
if(<error descr="Cannot resolve symbol 'test'"><warning descr="Condition 'test' is always 'true'">test</warning></error>) {
|
||||
sideEffect();
|
||||
}
|
||||
if(<error descr="Cannot resolve symbol 'test'">test</error>) {
|
||||
sideEffect();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<?> getList() {
|
||||
return Arrays.asList(
|
||||
<error descr="Cannot resolve symbol 'test'">test</error> ? null : 1,
|
||||
<error descr="Cannot resolve symbol 'test'">test</error> ? null : 2,
|
||||
<error descr="Cannot resolve symbol 'test'">test</error> ? null : 3,
|
||||
<error descr="Cannot resolve symbol 'test'">test</error> ? null : 4,
|
||||
<error descr="Cannot resolve symbol 'test'">test</error> ? null : 5,
|
||||
<error descr="Cannot resolve symbol 'test'">test</error> ? null : 6,
|
||||
<error descr="Cannot resolve symbol 'test'">test</error> ? null : 7,
|
||||
<error descr="Cannot resolve symbol 'test'">test</error> ? null : 8,
|
||||
<error descr="Cannot resolve symbol 'test'">test</error> ? null : 9,
|
||||
<error descr="Cannot resolve symbol 'test'">test</error> ? null : 10,
|
||||
<error descr="Cannot resolve symbol 'test'">test</error> ? null : 11,
|
||||
<error descr="Cannot resolve symbol 'test'">test</error> ? null : 12,
|
||||
<error descr="Cannot resolve symbol 'test'">test</error> ? null : 13,
|
||||
<error descr="Cannot resolve symbol 'test'">test</error> ? null : 14,
|
||||
<error descr="Cannot resolve symbol 'test'">test</error> ? null : 15,
|
||||
<error descr="Cannot resolve symbol 'test'">test</error> ? null : 16,
|
||||
<error descr="Cannot resolve symbol 'test'">test</error> ? null : 17,
|
||||
<error descr="Cannot resolve symbol 'test'">test</error> ? null : 18,
|
||||
<error descr="Cannot resolve symbol 'test'">test</error> ? null : 19,
|
||||
<error descr="Cannot resolve symbol 'test'">test</error> ? null : 20,
|
||||
<error descr="Cannot resolve symbol 'test'">test</error> ? null : 21,
|
||||
<error descr="Cannot resolve symbol 'test'">test</error> ? null : 22,
|
||||
<error descr="Cannot resolve symbol 'test'">test</error> ? null : 23,
|
||||
<error descr="Cannot resolve symbol 'test'">test</error> ? null : 24,
|
||||
<error descr="Cannot resolve symbol 'test'">test</error> ? null : 25,
|
||||
<error descr="Cannot resolve symbol 'test'">test</error> ? null : 26,
|
||||
<error descr="Cannot resolve symbol 'test'">test</error> ? null : 27,
|
||||
<error descr="Cannot resolve symbol 'test'">test</error> ? null : 28,
|
||||
<error descr="Cannot resolve symbol 'test'">test</error> ? null : 29,
|
||||
<error descr="Cannot resolve symbol 'test'">test</error> ? null : 30,
|
||||
<error descr="Cannot resolve symbol 'test'">test</error> ? null : 31,
|
||||
<error descr="Cannot resolve symbol 'test'">test</error> ? null : 32,
|
||||
<error descr="Cannot resolve symbol 'test'">test</error> ? null : 33,
|
||||
<error descr="Cannot resolve symbol 'test'">test</error> ? null : 34,
|
||||
<error descr="Cannot resolve symbol 'test'">test</error> ? null : 35,
|
||||
<error descr="Cannot resolve symbol 'test'">test</error> ? null : 36,
|
||||
<error descr="Cannot resolve symbol 'test'">test</error> ?
|
||||
<error descr="Cannot resolve symbol 'test'"><warning descr="Condition 'test' is always 'true'">test</warning></error> ? 1 : 2 : 3
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -546,5 +546,4 @@ public class DataFlowInspectionTest extends DataFlowInspectionTestCase {
|
||||
public void testGetterOfNullableFieldIsNotAnnotated() { doTest(); }
|
||||
|
||||
public void testGetterOfNullableFieldIsNotNull() { doTest(); }
|
||||
public void testUnresolvedInTernary() { doTest(); }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user