add runAsync
authorVladimir Krivosheev <vladimir.krivosheev@jetbrains.com>
Wed, 20 Jul 2016 10:23:04 +0000 (12:23 +0200)
committerVladimir Krivosheev <vladimir.krivosheev@jetbrains.com>
Wed, 20 Jul 2016 10:23:04 +0000 (12:23 +0200)
lib/annotations/jdk/java/util/concurrent/annotations.xml [new file with mode: 0644]
platform/analysis-api/src/com/intellij/codeInspection/InspectionProfileEntry.java
platform/analysis-impl/src/com/intellij/codeInspection/ex/InspectionProfileImpl.java
platform/analysis-impl/src/com/intellij/codeInspection/ex/ToolsImpl.java
platform/analysis-impl/src/com/intellij/profile/codeInspection/BaseInspectionProfileManager.kt
platform/analysis-impl/src/com/intellij/profile/codeInspection/ProjectInspectionProfileManager.kt
platform/core-impl/src/com/intellij/concurrency/completableFuture.kt [new file with mode: 0644]
platform/platform-impl/src/com/intellij/openapi/application/actions.kt

diff --git a/lib/annotations/jdk/java/util/concurrent/annotations.xml b/lib/annotations/jdk/java/util/concurrent/annotations.xml
new file mode 100644 (file)
index 0000000..b0e4e82
--- /dev/null
@@ -0,0 +1,6 @@
+<root>
+  <item
+      name='java.util.concurrent.CompletableFuture java.util.concurrent.CompletableFuture&lt;java.lang.Void&gt; runAsync(java.lang.Runnable, java.util.concurrent.Executor)'>
+    <annotation name='org.jetbrains.annotations.NotNull'/>
+  </item>
+</root>
\ No newline at end of file
index 1a545090af9b59dc4a52d52b1612f7d1bf41fbed..9fd1730cc08e4e18dbfaecb5143e8fe50de47916 100644 (file)
@@ -20,7 +20,6 @@ import com.intellij.codeInspection.ex.InspectionElementsMerger;
 import com.intellij.lang.Language;
 import com.intellij.lang.injection.InjectedLanguageManager;
 import com.intellij.openapi.diagnostic.Logger;
-import com.intellij.openapi.extensions.Extensions;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.util.InvalidDataException;
 import com.intellij.openapi.util.WriteExternalException;
@@ -190,7 +189,7 @@ public abstract class InspectionProfileEntry implements BatchSuppressableTool {
     }
     return elementLanguageSuppressor != null
            ? Collections.singleton(elementLanguageSuppressor)
-           : Collections.<InspectionSuppressor>emptySet();
+           : Collections.emptySet();
   }
 
   public void cleanup(@NotNull Project project) {
index d97c0cebcbdad256f0e91a8f40f52a33cc39d734..df53df032e8aebff18570f83fc744ab8fcdf420d 100644 (file)
@@ -723,11 +723,9 @@ public class InspectionProfileImpl extends ProfileEx implements ModifiableModel,
       return;
     }
 
-    for (final ToolsImpl toolList : myTools.values()) {
+    for (ToolsImpl toolList : myTools.values()) {
       if (toolList.isEnabled()) {
-        for (InspectionToolWrapper toolWrapper : toolList.getAllTools()) {
-          toolWrapper.cleanup(project);
-        }
+        toolList.cleanupTools(project);
       }
     }
   }
index c50406bd719d624afccc5a646f7a1ddc28f58ca3..63f4d6b5f3487ac7b6eeafe289ffc70f23dac377 100644 (file)
@@ -130,13 +130,10 @@ public class ToolsImpl implements Tools {
     return myShortName;
   }
 
-  @NotNull
-  public List<InspectionToolWrapper> getAllTools() {
-    List<InspectionToolWrapper> result = new ArrayList<>();
+  public void cleanupTools(@NotNull Project project) {
     for (ScopeToolState state : getTools()) {
-      result.add(state.getTool());
+      state.getTool().cleanup(project);
     }
-    return result;
   }
 
   public void writeExternal(@NotNull Element inspectionElement) throws WriteExternalException {
index 121d09829841a43bfc25e0ca9cef3f399d15070f..bd1c3edf31f164252c96f6925ed8ef2a85b7e1f9 100644 (file)
@@ -58,9 +58,7 @@ abstract class BaseInspectionProfileManager(messageBus: MessageBus) :  Inspectio
 
   internal fun cleanupSchemes(project: Project) {
     for (profile in schemeManager.allSchemes) {
-      if ((profile as InspectionProfileImpl).wasInitialized()) {
-        profile.cleanup(project)
-      }
+      profile.cleanup(project)
     }
   }
 
index 6019e1ece67e7b0e7ffd7a6cd63992357481fd52..7566344f916d5777007d7bd468d447129a516c30 100644 (file)
@@ -18,6 +18,7 @@ package com.intellij.profile.codeInspection
 import com.intellij.codeInspection.InspectionProfile
 import com.intellij.codeInspection.ex.InspectionProfileImpl
 import com.intellij.codeInspection.ex.InspectionToolRegistrar
+import com.intellij.concurrency.runAsync
 import com.intellij.configurationStore.SchemeDataHolder
 import com.intellij.openapi.Disposable
 import com.intellij.openapi.application.ApplicationManager
@@ -117,7 +118,7 @@ class ProjectInspectionProfileManager(val project: Project,
       initialLoadSchemesFuture = CompletableFuture.completedFuture(null)
     }
     else {
-      initialLoadSchemesFuture = CompletableFuture.runAsync({ schemeManager.loadSchemes() }, { app.executeOnPooledThread(it) })
+      initialLoadSchemesFuture = runAsync { schemeManager.loadSchemes() }
     }
 
     project.messageBus.connect().subscribe(ProjectManager.TOPIC, object: ProjectManagerListener {
diff --git a/platform/core-impl/src/com/intellij/concurrency/completableFuture.kt b/platform/core-impl/src/com/intellij/concurrency/completableFuture.kt
new file mode 100644 (file)
index 0000000..8cf85a6
--- /dev/null
@@ -0,0 +1,21 @@
+/*
+ * Copyright 2000-2016 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.concurrency
+
+import com.intellij.util.concurrency.AppExecutorUtil
+import java.util.concurrent.CompletableFuture
+
+inline fun runAsync(crossinline runnable: () -> Unit): CompletableFuture<Void> = CompletableFuture.runAsync(Runnable { runnable() }, AppExecutorUtil.getAppExecutorService())
\ No newline at end of file
index 702998b277bfcc406724f95adc12b25fc1879884..820f04dee7da87e02cf4b2a1337e6939124d59b5 100644 (file)
@@ -46,4 +46,4 @@ fun invokeAndWaitIfNeed(runnable: () -> Unit) {
   else {
     app.invokeAndWait(runnable, ModalityState.defaultModalityState())
   }
-}
+}
\ No newline at end of file