diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/bytecodeAnalysis/ProjectBytecodeAnalysis.java b/java/java-analysis-impl/src/com/intellij/codeInspection/bytecodeAnalysis/ProjectBytecodeAnalysis.java index c6c58ad4d3bb..41debdd78de3 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInspection/bytecodeAnalysis/ProjectBytecodeAnalysis.java +++ b/java/java-analysis-impl/src/com/intellij/codeInspection/bytecodeAnalysis/ProjectBytecodeAnalysis.java @@ -210,8 +210,10 @@ public class ProjectBytecodeAnalysis { private ParameterAnnotations loadParameterAnnotations(@NotNull HKey notNullKey) throws EquationsLimitException { + Map> equationsCache = new HashMap>(); + final Solver notNullSolver = new Solver(new ELattice(Value.NotNull, Value.Top), Value.Top); - collectEquations(Collections.singletonList(notNullKey), notNullSolver); + collectEquations(Collections.singletonList(notNullKey), notNullSolver, equationsCache); HashMap notNullSolutions = notNullSolver.solve(); boolean notNull = @@ -219,7 +221,7 @@ public class ProjectBytecodeAnalysis { final Solver nullableSolver = new Solver(new ELattice(Value.Null, Value.Top), Value.Top); final HKey nullableKey = new HKey(notNullKey.key, notNullKey.dirKey + 1, true); - collectEquations(Collections.singletonList(nullableKey), nullableSolver); + collectEquations(Collections.singletonList(nullableKey), nullableSolver, equationsCache); HashMap nullableSolutions = nullableSolver.solve(); boolean nullable = (Value.Null == nullableSolutions.get(nullableKey)) || (Value.Null == nullableSolutions.get(nullableKey.mkUnstable())); @@ -229,17 +231,17 @@ public class ProjectBytecodeAnalysis { private MethodAnnotations loadMethodAnnotations(@NotNull PsiMethod owner, @NotNull HKey key, ArrayList allKeys) throws EquationsLimitException { MethodAnnotations result = new MethodAnnotations(); + Map> equationsCache = new HashMap>(); final Solver outSolver = new Solver(new ELattice(Value.Bot, Value.Top), Value.Top); - collectEquations(allKeys, outSolver); + collectEquations(allKeys, outSolver, equationsCache); HashMap solutions = outSolver.solve(); int arity = owner.getParameterList().getParameters().length; BytecodeAnalysisConverter.addMethodAnnotations(solutions, result, key, arity); - final Solver nullableMethodSolver = new Solver(new ELattice(Value.Bot, Value.Null), Value.Bot); HKey nullableKey = key.updateDirection(BytecodeAnalysisConverter.mkDirectionKey(NullableOut)); - collectEquations(Collections.singletonList(nullableKey), nullableMethodSolver); + collectEquations(Collections.singletonList(nullableKey), nullableMethodSolver, equationsCache); HashMap nullableSolutions = nullableMethodSolver.solve(); if (nullableSolutions.get(nullableKey) == Value.Null || nullableSolutions.get(nullableKey.negate()) == Value.Null) { @@ -248,7 +250,8 @@ public class ProjectBytecodeAnalysis { return result; } - private void collectEquations(List keys, Solver solver) throws EquationsLimitException { + private void collectEquations(List keys, Solver solver, @NotNull Map> cache) throws EquationsLimitException { + GlobalSearchScope librariesScope = ProjectScope.getLibrariesScope(myProject); HashSet queued = new HashSet(); Stack queue = new Stack(); @@ -258,7 +261,6 @@ public class ProjectBytecodeAnalysis { queued.add(key); } - HashMap> cache = new HashMap>(); FileBasedIndex index = FileBasedIndex.getInstance(); while (!queue.empty()) {