hide non-dumb-aware intentions (EA-65004 - INRE: FileBasedIndexImpl.handleDumbMode)
authorpeter <peter@jetbrains.com>
Wed, 18 Feb 2015 12:09:13 +0000 (13:09 +0100)
committerpeter <peter@jetbrains.com>
Wed, 18 Feb 2015 15:18:44 +0000 (16:18 +0100)
platform/analysis-api/src/com/intellij/codeInsight/intention/IntentionAction.java
platform/lang-impl/src/com/intellij/codeInsight/intention/impl/IntentionActionWithTextCaching.java
platform/lang-impl/src/com/intellij/codeInsight/intention/impl/IntentionListStep.java

index 9119fd6eadabddc3999ce3fc00a69bc5ee2c3947..8c2a8c5c51e2c25dd54a0dd7d49128f26cbd7bf4 100644 (file)
@@ -34,6 +34,8 @@ import org.jetbrains.annotations.NotNull;
  * <p/>
  * Implement {@link HighPriorityAction HighPriorityAction} or
  * {@link LowPriorityAction LowPriorityAction} to change ordering.
+ * <p/>
+ * Can be {@link com.intellij.openapi.project.DumbAware}.
  *
  * @see IntentionManager#registerIntentionAndMetaData(IntentionAction, String...)
  */
index 2c5b5b3ad8c64f049f34cde17ff44e37bc6110e2..303d002458df0524e462f234ed057e8c22f83b76 100644 (file)
@@ -18,6 +18,8 @@ package com.intellij.codeInsight.intention.impl;
 
 import com.intellij.codeInsight.daemon.impl.HighlightInfo;
 import com.intellij.codeInsight.intention.IntentionAction;
+import com.intellij.openapi.project.DumbService;
+import com.intellij.openapi.project.PossiblyDumbAware;
 import com.intellij.openapi.util.Comparing;
 import com.intellij.openapi.diagnostic.Logger;
 import org.jetbrains.annotations.NotNull;
@@ -29,7 +31,7 @@ import java.util.ArrayList;
 /**
 * @author cdr
 */
-class IntentionActionWithTextCaching implements Comparable<IntentionActionWithTextCaching> {
+class IntentionActionWithTextCaching implements Comparable<IntentionActionWithTextCaching>, PossiblyDumbAware {
   private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.intention.impl.IntentionActionWithTextCaching");
   private final List<IntentionAction> myOptionIntentions = new ArrayList<IntentionAction>();
   private final List<IntentionAction> myOptionErrorFixes = new ArrayList<IntentionAction>();
@@ -109,4 +111,9 @@ class IntentionActionWithTextCaching implements Comparable<IntentionActionWithTe
   public Icon getIcon() {
     return myIcon;
   }
+
+  @Override
+  public boolean isDumbAware() {
+    return DumbService.isDumbAware(myAction);
+  }
 }
index 491508e2c7a8831df6436c77519dee172fcbc8dc..3e23137c8621347fc6dd8bf267c5cc8e076a753f 100644 (file)
@@ -33,6 +33,7 @@ import com.intellij.icons.AllIcons;
 import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.editor.Editor;
+import com.intellij.openapi.project.DumbService;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.ui.popup.*;
 import com.intellij.openapi.util.Comparing;
@@ -294,6 +295,7 @@ class IntentionListStep implements ListPopupStep<IntentionActionWithTextCaching>
     result.addAll(myCachedInspectionFixes);
     result.addAll(myCachedIntentions);
     result.addAll(myCachedGutters);
+    result = DumbService.getInstance(myProject).filterByDumbAwareness(result);
     Collections.sort(result, new Comparator<IntentionActionWithTextCaching>() {
       @Override
       public int compare(final IntentionActionWithTextCaching o1, final IntentionActionWithTextCaching o2) {