mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
DfaValueFactory#createCommonValue
This commit is contained in:
@@ -631,19 +631,14 @@ public class CFGBuilder {
|
||||
public CFGBuilder loopOver(PsiExpression[] expressions, DfaVariableValue targetVariable) {
|
||||
DfaValueFactory factory = getFactory();
|
||||
if (expressions.length > ControlFlowAnalyzer.MAX_UNROLL_SIZE) {
|
||||
DfaValue loopElement = null;
|
||||
for (PsiExpression expression : expressions) {
|
||||
pushExpression(expression);
|
||||
DfaValue expressionValue = factory.createValue(expression);
|
||||
if (expressionValue == null) {
|
||||
expressionValue = factory.createTypeValue(expression.getType(), NullnessUtil.getExpressionNullness(expression));
|
||||
}
|
||||
loopElement = loopElement == null ? expressionValue : loopElement.union(expressionValue);
|
||||
pop();
|
||||
}
|
||||
ConditionalGotoInstruction condGoto = new ConditionalGotoInstruction(null, false, null);
|
||||
condGoto.setOffset(myAnalyzer.getInstructionCount());
|
||||
myBranches.add(() -> pushUnknown().add(condGoto));
|
||||
DfaValue loopElement = factory.createCommonValue(expressions);
|
||||
pushForWrite(targetVariable).push(loopElement).assign();
|
||||
} else {
|
||||
push(factory.getConstFactory().getSentinel());
|
||||
|
||||
+4
@@ -16,10 +16,14 @@
|
||||
|
||||
package com.intellij.codeInspection.dataFlow.value;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class DfaUnknownValue extends DfaValue {
|
||||
private static class DfaUnknownValueHolder {
|
||||
private static final DfaUnknownValue myInstance = new DfaUnknownValue();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static DfaUnknownValue getInstance() {
|
||||
return DfaUnknownValueHolder.myInstance;
|
||||
}
|
||||
|
||||
+14
@@ -258,6 +258,20 @@ public class DfaValueFactory {
|
||||
@NotNull
|
||||
public DfaExpressionFactory getExpressionFactory() { return myExpressionFactory;}
|
||||
|
||||
@NotNull
|
||||
public DfaValue createCommonValue(@NotNull PsiExpression[] expressions) {
|
||||
DfaValue loopElement = null;
|
||||
for (PsiExpression expression : expressions) {
|
||||
DfaValue expressionValue = createValue(expression);
|
||||
if (expressionValue == null) {
|
||||
expressionValue = createTypeValue(expression.getType(), NullnessUtil.getExpressionNullness(expression));
|
||||
}
|
||||
loopElement = loopElement == null ? expressionValue : loopElement.union(expressionValue);
|
||||
if (loopElement == DfaUnknownValue.getInstance()) break;
|
||||
}
|
||||
return loopElement == null ? DfaUnknownValue.getInstance() : loopElement;
|
||||
}
|
||||
|
||||
private static class ClassInitializationInfo {
|
||||
final boolean myCanInstantiateItself;
|
||||
final boolean myCtorsCallMethods;
|
||||
|
||||
Reference in New Issue
Block a user