remove CompletionIgnoreDumbnessEP, run DumbAware contributors during indexing as...
authorPeter Gromov <peter@jetbrains.com>
Mon, 10 Aug 2020 17:40:50 +0000 (19:40 +0200)
committerintellij-monorepo-bot <intellij-monorepo-bot-no-reply@jetbrains.com>
Mon, 10 Aug 2020 17:41:25 +0000 (17:41 +0000)
GitOrigin-RevId: bd53f16e8225a3ce29fa753a2432a28b44f3846a

platform/analysis-api/resources/META-INF/Analysis.xml
platform/analysis-api/src/com/intellij/codeInsight/completion/CompletionContributor.java
platform/analysis-api/src/com/intellij/codeInsight/completion/CompletionIgnoreDumbnessEP.java [deleted file]
platform/analysis-impl/src/com/intellij/codeInsight/completion/LegacyCompletionContributor.java
platform/core-api/src/com/intellij/openapi/project/DumbUtil.java
platform/core-impl/src/com/intellij/mock/MockDumbUtil.java
platform/platform-impl/src/com/intellij/openapi/project/DumbUtilImpl.java

index fc7061edce875f2ced7d3bd8fd1f7739bb6eb79f..37bd65887800fa40ea5c32190339a76c1abbb35c 100644 (file)
@@ -8,8 +8,6 @@
     <extensionPoint name="gotoDeclarationHandler" interface="com.intellij.codeInsight.navigation.actions.GotoDeclarationHandler"
                     dynamic="true"/>
     <extensionPoint name="completion.skip" interface="com.intellij.codeInsight.completion.CompletionPreselectSkipper" dynamic="true"/>
-    <extensionPoint name="completion.ignoringDumbnessAllowed" beanClass="com.intellij.codeInsight.completion.CompletionIgnoreDumbnessEP"
-                    dynamic="true"/>
     <extensionPoint name="weigher" beanClass="com.intellij.psi.WeigherExtensionPoint" dynamic="true">
       <with attribute="implementationClass" implements="com.intellij.psi.Weigher"/>
     </extensionPoint>
index ae632414c2f2a3422425cfddddd10d25590fd3ee..1834923c90318dbd25f221777dff464cb678d97b 100644 (file)
@@ -10,7 +10,6 @@ import com.intellij.openapi.editor.Editor;
 import com.intellij.openapi.extensions.ExtensionPointName;
 import com.intellij.openapi.progress.ProgressManager;
 import com.intellij.openapi.project.DumbService;
-import com.intellij.openapi.project.DumbUtil;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.util.Pair;
 import com.intellij.patterns.ElementPattern;
@@ -240,9 +239,7 @@ public abstract class CompletionContributor {
 
   @NotNull
   public static List<CompletionContributor> forLanguageHonorDumbness(@NotNull Language language, @NotNull Project project) {
-    return CompletionIgnoreDumbnessEP.isIgnoringDumbnessAllowed(language) ?
-           DumbUtil.getInstance(project).filterByDumbAwarenessHonoringIgnoring(forLanguage(language)) :
-           DumbService.getInstance(project).filterByDumbAwareness(forLanguage(language));
+    return DumbService.getInstance(project).filterByDumbAwareness(forLanguage(language));
   }
 
   private static final LanguageExtension<CompletionContributor> INSTANCE = new CompletionExtension<>(EP.getName());
diff --git a/platform/analysis-api/src/com/intellij/codeInsight/completion/CompletionIgnoreDumbnessEP.java b/platform/analysis-api/src/com/intellij/codeInsight/completion/CompletionIgnoreDumbnessEP.java
deleted file mode 100644 (file)
index 22f7c61..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
-package com.intellij.codeInsight.completion;
-
-import com.intellij.lang.Language;
-import com.intellij.openapi.extensions.ExtensionPointName;
-import com.intellij.serviceContainer.LazyExtensionInstance;
-import com.intellij.util.xmlb.annotations.Attribute;
-import org.jetbrains.annotations.ApiStatus;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-@ApiStatus.Internal
-@ApiStatus.Experimental
-public class CompletionIgnoreDumbnessEP extends LazyExtensionInstance<Object> {
-  private static final ExtensionPointName<CompletionIgnoreDumbnessEP> EP_NAME =
-    ExtensionPointName.create("com.intellij.completion.ignoringDumbnessAllowed");
-
-  public static boolean isIgnoringDumbnessAllowed(@NotNull Language language) {
-    return EP_NAME.getByKey(language.getID(), CompletionIgnoreDumbnessEP.class, ep -> ep.language) != null;
-  }
-
-  /**
-   * Language ID.
-   *
-   * @see Language#getID()
-   */
-  @Attribute("language")
-  public String language;
-
-  @Override
-  protected @Nullable String getImplementationClassName() {
-    return null;
-  }
-}
index 9feb633182c4689f8bfa79af1908bcafea3345fb..e06336dd87f0af0084ec16e647447d0cd38b044a 100644 (file)
@@ -18,6 +18,8 @@ package com.intellij.codeInsight.completion;
 import com.intellij.codeInsight.lookup.LookupElement;
 import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.paths.PsiDynaReference;
+import com.intellij.openapi.project.DumbAware;
+import com.intellij.openapi.project.DumbService;
 import com.intellij.openapi.util.Ref;
 import com.intellij.openapi.util.TextRange;
 import com.intellij.psi.PsiElement;
@@ -35,7 +37,7 @@ import java.util.Set;
 /**
  * @author peter
  */
-public class LegacyCompletionContributor extends CompletionContributor {
+public class LegacyCompletionContributor extends CompletionContributor implements DumbAware {
   private static final Logger LOG = Logger.getInstance(LegacyCompletionContributor.class);
 
   @Override
@@ -51,6 +53,8 @@ public class LegacyCompletionContributor extends CompletionContributor {
 
     completeReference(parameters, result);
 
+    if (DumbService.isDumb(insertedElement.getProject())) return;
+
     final Set<LookupElement> lookupSet = new LinkedHashSet<>();
     final Set<CompletionVariant> keywordVariants = new HashSet<>();
     PsiFile file = parameters.getOriginalFile();
index a02637d8b6c6205c6a05fe56252cbfe57490586f..a0f171939bb6511cbf01f2231dd52c57af63adcd 100644 (file)
@@ -2,12 +2,8 @@
 package com.intellij.openapi.project;
 
 import org.jetbrains.annotations.ApiStatus;
-import org.jetbrains.annotations.Contract;
 import org.jetbrains.annotations.NotNull;
 
-import java.util.Collection;
-import java.util.List;
-
 @ApiStatus.Experimental
 @ApiStatus.Internal
 public interface DumbUtil {
@@ -16,17 +12,6 @@ public interface DumbUtil {
     return project.getService(DumbUtil.class);
   }
 
-  /**
-   * @return all the elements of the given collection if there's no dumb mode currently ({@link DumbService#isDumb()} is false),
-   * or method is called inside {@link com.intellij.util.indexing.FileBasedIndex#ignoreDumbMode(Runnable, com.intellij.util.indexing.DumbModeAccessType)}.
-   * Otherwise, the dumb-aware ones are returned.
-   * @see DumbService#isDumbAware(Object)
-   */
-  @Contract(pure = true)
-  @ApiStatus.Internal
-  @ApiStatus.Experimental
-  @NotNull <T> List<T> filterByDumbAwarenessHonoringIgnoring(@NotNull Collection<? extends T> collection);
-
   /**
    * @return true iff one may use file based indices, i.e. project is not in dumb mode, or
    * {@link com.intellij.util.indexing.FileBasedIndex#ignoreDumbMode(Runnable, com.intellij.util.indexing.DumbModeAccessType)} was used
index c736330888f70f4778b35cc3deb81b7f9ea01e0b..5fa4f649e767f1f23082c271fa50e4a315f1cc65 100644 (file)
@@ -2,19 +2,9 @@
 package com.intellij.mock;
 
 import com.intellij.openapi.project.DumbUtil;
-import org.jetbrains.annotations.NotNull;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
 
 public class MockDumbUtil implements DumbUtil {
 
-  @Override
-  public @NotNull <T> List<T> filterByDumbAwarenessHonoringIgnoring(@NotNull Collection<? extends T> collection) {
-    return collection instanceof List ? (List<T>)collection : new ArrayList<>(collection);
-  }
-
   @Override
   public boolean mayUseIndices() {
     return true;
index 00e811dd332d91c914db2221656db878f6bac94d..82eddc7fa3ff7e0e4d4ceb360029dd89d451575c 100644 (file)
@@ -2,13 +2,8 @@
 package com.intellij.openapi.project;
 
 import com.intellij.util.indexing.FileBasedIndex;
-import org.jetbrains.annotations.Contract;
 import org.jetbrains.annotations.NotNull;
 
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
 public class DumbUtilImpl implements DumbUtil {
   private final Project myProject;
 
@@ -16,20 +11,6 @@ public class DumbUtilImpl implements DumbUtil {
     myProject = project;
   }
 
-  @Override
-  @Contract(pure = true)
-  public @NotNull <T> List<T> filterByDumbAwarenessHonoringIgnoring(@NotNull Collection<? extends T> collection) {
-    if (!mayUseIndices()) {
-      return DumbService.getInstance(myProject).filterByDumbAwareness(collection);
-    }
-
-    if (collection instanceof List) {
-      return (List<T>) collection;
-    }
-
-    return new ArrayList<>(collection);
-  }
-
   @Override
   public boolean mayUseIndices() {
     return !DumbService.getInstance(myProject).isDumb() || FileBasedIndex.getInstance().getCurrentDumbModeAccessType() != null;