diff --git a/platform/analysis-impl/src/com/intellij/profile/codeInspection/ProjectInspectionProfileManager.kt b/platform/analysis-impl/src/com/intellij/profile/codeInspection/ProjectInspectionProfileManager.kt index 475ac1842292..fd9faa8219e7 100644 --- a/platform/analysis-impl/src/com/intellij/profile/codeInspection/ProjectInspectionProfileManager.kt +++ b/platform/analysis-impl/src/com/intellij/profile/codeInspection/ProjectInspectionProfileManager.kt @@ -18,7 +18,6 @@ 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.configurationStore.digest import com.intellij.openapi.Disposable @@ -46,8 +45,10 @@ import com.intellij.util.xmlb.SkipDefaultValuesSerializationFilters import com.intellij.util.xmlb.XmlSerializer import org.jdom.Element import org.jetbrains.annotations.TestOnly +import org.jetbrains.concurrency.Promise +import org.jetbrains.concurrency.resolvedPromise +import org.jetbrains.concurrency.runAsync import java.util.* -import java.util.concurrent.CompletableFuture import java.util.function.Function const val PROFILE = "profile" @@ -80,7 +81,7 @@ class ProjectInspectionProfileManager(val project: Project, private var state = State() - private val initialLoadSchemesFuture: CompletableFuture<*> + private val initialLoadSchemesFuture: Promise<*> private val skipDefaultsSerializationFilter = object : SkipDefaultValuesSerializationFilters(State()) { override fun accepts(accessor: Accessor, bean: Any, beanValue: Any?): Boolean { @@ -129,7 +130,7 @@ class ProjectInspectionProfileManager(val project: Project, val app = ApplicationManager.getApplication() if (app.isUnitTestMode) { - initialLoadSchemesFuture = CompletableFuture.completedFuture(null) + initialLoadSchemesFuture = resolvedPromise() } else { initialLoadSchemesFuture = runAsync { schemeManager.loadSchemes() } @@ -175,7 +176,7 @@ class ProjectInspectionProfileManager(val project: Project, private class ProjectInspectionProfileStartUpActivity : StartupActivity { override fun runActivity(project: Project) { getInstanceImpl(project).apply { - initialLoadSchemesFuture.thenRun { + initialLoadSchemesFuture.done { currentProfile.initInspectionTools(project) fireProfilesInitialized() @@ -295,7 +296,7 @@ class ProjectInspectionProfileManager(val project: Project, InspectionProfileImpl.getDefaultProfile(), null) currentScheme.copyFrom(applicationProfileManager.currentProfile) currentScheme.isProjectLevel = true - currentScheme.setName(PROJECT_DEFAULT_PROFILE_NAME) + currentScheme.name = PROJECT_DEFAULT_PROFILE_NAME schemeManager.addScheme(currentScheme) } schemeManager.setCurrent(currentScheme, false) diff --git a/platform/projectModel-api/src/org/jetbrains/concurrency/promise.kt b/platform/projectModel-api/src/org/jetbrains/concurrency/promise.kt index 9712f2bc0580..74d5be3ff635 100644 --- a/platform/projectModel-api/src/org/jetbrains/concurrency/promise.kt +++ b/platform/projectModel-api/src/org/jetbrains/concurrency/promise.kt @@ -18,6 +18,7 @@ package org.jetbrains.concurrency import com.intellij.util.Consumer import com.intellij.util.Function import com.intellij.util.SmartList +import com.intellij.util.concurrency.AppExecutorUtil import java.util.* private val rejectedPromise = Promise.reject("rejected") @@ -113,4 +114,13 @@ inline fun AsyncPromise.compute(runnable: () -> T) { if (!isRejected) { setResult(result) } +} + +inline fun runAsync(crossinline runnable: () -> Unit): Promise<*> { + val promise = AsyncPromise() + AppExecutorUtil.getAppExecutorService().execute { + promise.catchError { runnable() } + promise.setResult(null) + } + return promise } \ No newline at end of file diff --git a/platform/projectModel-impl/src/com/intellij/completableFuture.kt b/platform/projectModel-impl/src/com/intellij/completableFuture.kt deleted file mode 100644 index 8cf85a6490b4..000000000000 --- a/platform/projectModel-impl/src/com/intellij/completableFuture.kt +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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 = CompletableFuture.runAsync(Runnable { runnable() }, AppExecutorUtil.getAppExecutorService()) \ No newline at end of file