add DumbService.filterByDumbAwareness(T[])
authorpeter <peter@jetbrains.com>
Wed, 18 Feb 2015 11:23:20 +0000 (12:23 +0100)
committerpeter <peter@jetbrains.com>
Wed, 18 Feb 2015 15:18:40 +0000 (16:18 +0100)
java/java-psi-impl/src/com/intellij/psi/impl/JavaPsiFacadeImpl.java
platform/core-api/src/com/intellij/openapi/project/DumbService.java
platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightingSettingsPerFile.java
platform/lang-impl/src/com/intellij/ide/impl/ProjectViewSelectInTarget.java
platform/usageView/src/com/intellij/usages/UsageTargetUtil.java

index ca19d9766eb8572e742d138ab8e0268374f05b81..aa389214205a7cf04e18b951f662b41887008afd 100644 (file)
@@ -196,7 +196,7 @@ public class JavaPsiFacadeImpl extends JavaPsiFacadeEx {
     DumbService dumbService = DumbService.getInstance(getProject());
     PsiElementFinder[] finders = finders();
     if (dumbService.isDumb()) {
-      List<PsiElementFinder> list = dumbService.filterByDumbAwareness(Arrays.asList(finders));
+      List<PsiElementFinder> list = dumbService.filterByDumbAwareness(finders);
       finders = list.toArray(new PsiElementFinder[list.size()]);
     }
     return finders;
index bbc3e824e93378d11ce5141543158d16c37a9e1d..b70196ea2acfcccf6a0cc14571ebb46503b8c5fb 100644 (file)
@@ -29,6 +29,7 @@ import org.jetbrains.annotations.Nullable;
 
 import javax.swing.*;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collection;
 import java.util.List;
 
@@ -159,6 +160,19 @@ public abstract class DumbService {
     return INSTANCE_KEY.getValue(project);
   }
 
+  /**
+   * @return all the elements of the given array if there's no dumb mode currently, or the dumb-aware ones if {@link #isDumb()} is true.
+   * @see #isDumbAware(Object) 
+   */
+  @NotNull
+  public <T> List<T> filterByDumbAwareness(@NotNull T[] array) {
+    return filterByDumbAwareness(Arrays.asList(array));
+  }
+
+  /**
+   * @return all the elements of the given collection if there's no dumb mode currently, or the dumb-aware ones if {@link #isDumb()} is true. 
+   * @see #isDumbAware(Object)
+   */
   @NotNull
   public <T> List<T> filterByDumbAwareness(@NotNull Collection<T> collection) {
     if (isDumb()) {
index 852b33c5e99a6e3918dcc0327c93ed65b604a28e..ff5c27ad756c625f2db2bc24aa9d2f278d1e0ca7 100644 (file)
@@ -65,8 +65,7 @@ public class HighlightingSettingsPerFile extends HighlightingLevelManager implem
   private static FileHighlightingSetting getDefaultHighlightingSetting(@NotNull Project project, final VirtualFile virtualFile) {
     if (virtualFile != null) {
       DefaultHighlightingSettingProvider[] providers = DefaultHighlightingSettingProvider.EP_NAME.getExtensions();
-      List<DefaultHighlightingSettingProvider> filtered =
-        DumbService.getInstance(project).filterByDumbAwareness(Arrays.asList(providers));
+      List<DefaultHighlightingSettingProvider> filtered = DumbService.getInstance(project).filterByDumbAwareness(providers);
       for (DefaultHighlightingSettingProvider p : filtered) {
         FileHighlightingSetting setting = p.getDefaultSetting(project, virtualFile);
         if (setting != null) {
index 2ed96628b1f57355be28f91ca6357282515ed0fb..85890642c3b5314ed56f34e29fdea302d37e3159 100644 (file)
@@ -40,7 +40,6 @@ import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.Collection;
 import java.util.List;
 
@@ -157,7 +156,7 @@ public abstract class ProjectViewSelectInTarget extends SelectInTargetPsiWrapper
   }
 
   private TreeStructureProvider[] getProvidersDumbAware() {
-    List<TreeStructureProvider> allProviders = Arrays.asList(Extensions.getExtensions(TreeStructureProvider.EP_NAME, myProject));
+    TreeStructureProvider[] allProviders = Extensions.getExtensions(TreeStructureProvider.EP_NAME, myProject);
     List<TreeStructureProvider> dumbAware = DumbService.getInstance(myProject).filterByDumbAwareness(allProviders);
     return dumbAware.toArray(new TreeStructureProvider[dumbAware.size()]);
   }
index 3a41b25019bd0c76847901fec6fe7450e5e1adb5..355c36793b6a2bd1813a9add180803dffac8c5ee 100644 (file)
@@ -27,7 +27,6 @@ import com.intellij.psi.PsiFile;
 import org.jetbrains.annotations.NotNull;
 
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
 
@@ -72,6 +71,6 @@ public class UsageTargetUtil {
 
   @NotNull
   private static List<UsageTargetProvider> getProviders(Project project) {
-    return DumbService.getInstance(project).filterByDumbAwareness(Arrays.asList(Extensions.getExtensions(EP_NAME)));
+    return DumbService.getInstance(project).filterByDumbAwareness(Extensions.getExtensions(EP_NAME));
   }
 }