mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
DfaMemoryStateImpl refactoring: do not expose (even package-private) myVariableStates via getter
This commit is contained in:
+4
-4
@@ -39,6 +39,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
|
||||
public class DfaMemoryStateImpl implements DfaMemoryState {
|
||||
@@ -106,7 +107,7 @@ public class DfaMemoryStateImpl implements DfaMemoryState {
|
||||
public DfaMemoryStateImpl createClosureState() {
|
||||
DfaMemoryStateImpl copy = createCopy();
|
||||
copy.flushFields();
|
||||
Set<DfaVariableValue> vars = new HashSet<>(copy.getVariableStates().keySet());
|
||||
Set<DfaVariableValue> vars = new HashSet<>(copy.myVariableStates.keySet());
|
||||
for (DfaVariableValue value : vars) {
|
||||
copy.flushDependencies(value);
|
||||
}
|
||||
@@ -1206,9 +1207,8 @@ public class DfaMemoryStateImpl implements DfaMemoryState {
|
||||
return state;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
Map<DfaVariableValue, DfaVariableState> getVariableStates() {
|
||||
return myVariableStates;
|
||||
void forVariableStates(BiConsumer<DfaVariableValue, DfaVariableState> consumer) {
|
||||
myVariableStates.forEach(consumer);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -324,10 +324,8 @@ public class DfaUtil {
|
||||
PsiExpression place = instruction.getPlace();
|
||||
if (place != null) {
|
||||
PlaceResult result = myResults.computeIfAbsent(place, __ -> new PlaceResult());
|
||||
final Map<DfaVariableValue,DfaVariableState> map = ((ValuableDataFlowRunner.MyDfaMemoryState)memState).getVariableStates();
|
||||
for (Map.Entry<DfaVariableValue, DfaVariableState> entry : map.entrySet()) {
|
||||
ValuableDataFlowRunner.ValuableDfaVariableState state = (ValuableDataFlowRunner.ValuableDfaVariableState)entry.getValue();
|
||||
DfaVariableValue variableValue = entry.getKey();
|
||||
((ValuableDataFlowRunner.MyDfaMemoryState)memState).forVariableStates((variableValue, value) -> {
|
||||
ValuableDataFlowRunner.ValuableDfaVariableState state = (ValuableDataFlowRunner.ValuableDfaVariableState)value;
|
||||
final FList<PsiExpression> concatenation = state.myConcatenation;
|
||||
if (!concatenation.isEmpty() && variableValue.getQualifier() == null) {
|
||||
PsiModifierListOwner element = variableValue.getPsiVariable();
|
||||
@@ -335,7 +333,7 @@ public class DfaUtil {
|
||||
result.myValues.put((PsiVariable)element, concatenation);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
DfaValue value = instruction.getValue();
|
||||
if (value instanceof DfaVariableValue && ((DfaVariableValue)value).getQualifier() == null) {
|
||||
PsiModifierListOwner element = ((DfaVariableValue)value).getPsiVariable();
|
||||
|
||||
@@ -265,8 +265,7 @@ class StateMerger {
|
||||
Map<DfaVariableValue, Map<LongRangeSet, LongRangeSet>> ranges = new LinkedHashMap<>();
|
||||
for (DfaMemoryStateImpl state : states) {
|
||||
ProgressManager.checkCanceled();
|
||||
Map<DfaVariableValue, DfaVariableState> variableStates = state.getVariableStates();
|
||||
variableStates.forEach((varValue, varState) -> {
|
||||
state.forVariableStates((varValue, varState) -> {
|
||||
LongRangeSet range = varState.getFact(RANGE);
|
||||
if (range != null) {
|
||||
ranges.computeIfAbsent(varValue, k -> new HashMap<>()).put(range, range);
|
||||
@@ -378,12 +377,12 @@ class StateMerger {
|
||||
|
||||
@NotNull
|
||||
private Set<Fact> getFacts(@NotNull DfaMemoryStateImpl state) {
|
||||
Set<Fact> result = myFacts.get(state);
|
||||
if (result != null) {
|
||||
return result;
|
||||
}
|
||||
|
||||
result = ContainerUtil.newLinkedHashSet();
|
||||
return myFacts.computeIfAbsent(state, StateMerger::doGetFacts);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static Set<Fact> doGetFacts(DfaMemoryStateImpl state) {
|
||||
Set<Fact> result = ContainerUtil.newLinkedHashSet();
|
||||
|
||||
IdentityHashMap<EqClass, EqClassInfo> classInfo = new IdentityHashMap<>();
|
||||
|
||||
@@ -426,10 +425,7 @@ class StateMerger {
|
||||
}
|
||||
}
|
||||
|
||||
Map<DfaVariableValue, DfaVariableState> states = state.getVariableStates();
|
||||
for (Map.Entry<DfaVariableValue, DfaVariableState> entry : states.entrySet()) {
|
||||
DfaVariableValue var = entry.getKey();
|
||||
DfaVariableState variableState = entry.getValue();
|
||||
state.forVariableStates((var, variableState) -> {
|
||||
TypeConstraint typeConstraint = variableState.getTypeConstraint();
|
||||
for (DfaPsiType type : typeConstraint.getInstanceofValues()) {
|
||||
result.add(new InstanceofFact(var, true, type));
|
||||
@@ -437,9 +433,7 @@ class StateMerger {
|
||||
for (DfaPsiType type : typeConstraint.getNotInstanceofValues()) {
|
||||
result.add(new InstanceofFact(var, false, type));
|
||||
}
|
||||
}
|
||||
|
||||
myFacts.put(state, result);
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user