[java] fixes module resolve results caching
authorRoman Shevchenko <roman.shevchenko@jetbrains.com>
Mon, 24 Oct 2016 15:09:22 +0000 (17:09 +0200)
committerRoman Shevchenko <roman.shevchenko@jetbrains.com>
Mon, 24 Oct 2016 15:09:22 +0000 (17:09 +0200)
java/java-psi-impl/src/com/intellij/psi/impl/source/PsiJavaModuleReference.java

index 0a2d11ecc2b68dcf946b4b52f42f9ff76f3a54a8..248aee94e0d3e96d0d63686df59b4999d3a86dd2 100644 (file)
@@ -122,13 +122,17 @@ public class PsiJavaModuleReference extends PsiReferenceBase.Poly<PsiJavaModuleR
     }
   }
 
     }
   }
 
-  private static final Key<ParameterizedCachedValue<PsiJavaModule, Pair<String, Boolean>>> KEY = Key.create("java.module.ref.text.resolve");
+  private static final Key<ParameterizedCachedValue<PsiJavaModule, Pair<String, Boolean>>> K_COMPLETE =
+    Key.create("java.module.ref.text.resolve.complete");
+  private static final Key<ParameterizedCachedValue<PsiJavaModule, Pair<String, Boolean>>> K_INCOMPLETE =
+    Key.create("java.module.ref.text.resolve.incomplete");
 
   @Nullable
   public static PsiJavaModule resolve(@NotNull final PsiElement refOwner, String refText, boolean incompleteCode) {
     if (StringUtil.isEmpty(refText)) return null;
     CachedValuesManager manager = CachedValuesManager.getManager(refOwner.getProject());
 
   @Nullable
   public static PsiJavaModule resolve(@NotNull final PsiElement refOwner, String refText, boolean incompleteCode) {
     if (StringUtil.isEmpty(refText)) return null;
     CachedValuesManager manager = CachedValuesManager.getManager(refOwner.getProject());
-    return manager.getParameterizedCachedValue(refOwner, KEY, new ParameterizedCachedValueProvider<PsiJavaModule, Pair<String, Boolean>>() {
+    Key<ParameterizedCachedValue<PsiJavaModule, Pair<String, Boolean>>> key = incompleteCode ? K_COMPLETE : K_INCOMPLETE;
+    return manager.getParameterizedCachedValue(refOwner, key, new ParameterizedCachedValueProvider<PsiJavaModule, Pair<String, Boolean>>() {
       @Nullable
       @Override
       public Result<PsiJavaModule> compute(Pair<String, Boolean> p) {
       @Nullable
       @Override
       public Result<PsiJavaModule> compute(Pair<String, Boolean> p) {