diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/util/ApplicationUtils.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/util/ApplicationUtils.kt index f2fadb6d004..7ed13843a63 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/util/ApplicationUtils.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/util/ApplicationUtils.kt @@ -25,11 +25,6 @@ public fun runReadAction(action: () -> T): T { return ApplicationManager.getApplication().runReadAction(action) } -public fun Project.runReadActionInSmartMode(action: () -> T): T { - if (ApplicationManager.getApplication().isReadAccessAllowed) return action() - return DumbService.getInstance(this).runReadActionInSmartMode(action) -} - public fun runWriteAction(action: () -> T): T { return ApplicationManager.getApplication().runWriteAction(action) } @@ -47,11 +42,4 @@ public fun Project.executeCommand(name: String, groupId: Any? = null, comman CommandProcessor.getInstance().executeCommand(this, { result = command() }, name, groupId) @Suppress("USELESS_CAST") return result as T -} - -public fun Project.runWithAlternativeResolveEnabled(action: () -> T): T { - var result: T = null as T - DumbService.getInstance(this).withAlternativeResolveEnabled { result = action() } - @Suppress("USELESS_CAST") - return result as T } \ No newline at end of file diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/util/dumbUtils.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/util/dumbUtils.kt new file mode 100644 index 00000000000..a62ed67219f --- /dev/null +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/util/dumbUtils.kt @@ -0,0 +1,33 @@ +/* + * Copyright 2010-2015 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 org.jetbrains.kotlin.idea.util + +import com.intellij.openapi.application.ApplicationManager +import com.intellij.openapi.project.DumbService +import com.intellij.openapi.project.Project + +public fun Project.runReadActionInSmartMode(action: () -> T): T { + if (ApplicationManager.getApplication().isReadAccessAllowed) return action() + return DumbService.getInstance(this).runReadActionInSmartMode(action) +} + +public fun Project.runWithAlternativeResolveEnabled(action: () -> T): T { + var result: T = null as T + DumbService.getInstance(this).withAlternativeResolveEnabled { result = action() } + @Suppress("USELESS_CAST") + return result as T +} \ No newline at end of file diff --git a/idea/src/org/jetbrains/kotlin/idea/search/ideaExtensions/KotlinOverridingMethodReferenceSearcher.kt b/idea/src/org/jetbrains/kotlin/idea/search/ideaExtensions/KotlinOverridingMethodReferenceSearcher.kt index 5ecf292cdfd..5c6455520fa 100644 --- a/idea/src/org/jetbrains/kotlin/idea/search/ideaExtensions/KotlinOverridingMethodReferenceSearcher.kt +++ b/idea/src/org/jetbrains/kotlin/idea/search/ideaExtensions/KotlinOverridingMethodReferenceSearcher.kt @@ -27,7 +27,7 @@ import org.jetbrains.kotlin.asJava.toLightMethods import org.jetbrains.kotlin.idea.references.KtSimpleNameReference import org.jetbrains.kotlin.idea.references.readWriteAccess import org.jetbrains.kotlin.idea.search.restrictToKotlinSources -import org.jetbrains.kotlin.idea.util.application.runReadActionInSmartMode +import org.jetbrains.kotlin.idea.util.runReadActionInSmartMode import org.jetbrains.kotlin.load.java.JvmAbi import org.jetbrains.kotlin.load.java.getPropertyNamesCandidatesByAccessorName import org.jetbrains.kotlin.name.Name diff --git a/idea/src/org/jetbrains/kotlin/idea/testIntegration/KotlinCreateTestIntention.kt b/idea/src/org/jetbrains/kotlin/idea/testIntegration/KotlinCreateTestIntention.kt index 91bffff6875..2f084685ddf 100644 --- a/idea/src/org/jetbrains/kotlin/idea/testIntegration/KotlinCreateTestIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/testIntegration/KotlinCreateTestIntention.kt @@ -41,7 +41,7 @@ import org.jetbrains.kotlin.idea.core.refactoring.j2k import org.jetbrains.kotlin.idea.core.refactoring.toPsiDirectory import org.jetbrains.kotlin.idea.intentions.JetSelfTargetingRangeIntention import org.jetbrains.kotlin.idea.util.application.executeCommand -import org.jetbrains.kotlin.idea.util.application.runWithAlternativeResolveEnabled +import org.jetbrains.kotlin.idea.util.runWithAlternativeResolveEnabled import org.jetbrains.kotlin.idea.util.application.runWriteAction import org.jetbrains.kotlin.psi.KtClass import org.jetbrains.kotlin.psi.KtClassOrObject @@ -133,6 +133,8 @@ class KotlinCreateTestIntention : JetSelfTargetingRangeIntention