diff --git a/platform/lang-impl/src/com/intellij/ide/util/gotoByName/ActionAsyncProvider.kt b/platform/lang-impl/src/com/intellij/ide/util/gotoByName/ActionAsyncProvider.kt index c6b86cd84baa..7f9f082e9fdd 100644 --- a/platform/lang-impl/src/com/intellij/ide/util/gotoByName/ActionAsyncProvider.kt +++ b/platform/lang-impl/src/com/intellij/ide/util/gotoByName/ActionAsyncProvider.kt @@ -74,18 +74,43 @@ class ActionAsyncProvider(private val model: GotoActionModel) { val actionIds = (actionManager as ActionManagerImpl).actionIds scope.launch { - val abbreviationsJob = processAbbreviations(pattern, presentationProvider, consumer) - - val nonMatchedIdsChannel = Channel(capacity = Channel.UNLIMITED) - val matchedStubsJob = processMatchedActionsAndStubs(pattern, actionIds, presentationProvider, consumer, nonMatchedIdsChannel, abbreviationsJob) - val unmatchedStubsJob = processUnmatchedStubs(nonMatchedIdsChannel, pattern, presentationProvider, consumer, matchedStubsJob) - - val topHitsJob = processTopHits(pattern, presentationProvider, consumer, unmatchedStubsJob) - val intentionsJob = processIntentions(pattern, presentationProvider, consumer, topHitsJob) - processOptions(pattern, presentationProvider, consumer, intentionsJob) + runFilterJobs(presentationProvider, pattern, consumer, actionIds) } } + suspend fun filterElementsSuspend( + scope: CoroutineScope, + presentationProvider: suspend (AnAction) -> Presentation, + pattern: String, + consumer: suspend (MatchedValue) -> Boolean, + ) { + if (pattern.isEmpty()) return + + LOG.debug { "Start actions searching ($pattern)" } + + val actionIds = (actionManager as ActionManagerImpl).actionIds + + scope.runFilterJobs( presentationProvider, pattern, consumer, actionIds).forEach { it.join() } + } + + fun CoroutineScope.runFilterJobs( + presentationProvider: suspend (AnAction) -> Presentation, + pattern: String, + consumer: suspend (MatchedValue) -> Boolean, + actionIds: Set + ): List { + val abbreviationsJob = processAbbreviations(pattern, presentationProvider, consumer) + + val nonMatchedIdsChannel = Channel(capacity = Channel.UNLIMITED) + val matchedStubsJob = processMatchedActionsAndStubs(pattern, actionIds, presentationProvider, consumer, nonMatchedIdsChannel, abbreviationsJob) + val unmatchedStubsJob = processUnmatchedStubs(nonMatchedIdsChannel, pattern, presentationProvider, consumer, matchedStubsJob) + + val topHitsJob = processTopHits(pattern, presentationProvider, consumer, unmatchedStubsJob) + val intentionsJob = processIntentions(pattern, presentationProvider, consumer, topHitsJob) + val processOptionsJob = processOptions(pattern, presentationProvider, consumer, intentionsJob) + return listOf(abbreviationsJob, matchedStubsJob, unmatchedStubsJob, topHitsJob, intentionsJob, processOptionsJob) + } + private fun CoroutineScope.processAbbreviations(pattern: String, presentationProvider: suspend (AnAction) -> Presentation, consumer: suspend (MatchedValue) -> Boolean diff --git a/platform/lang-impl/src/com/intellij/ide/util/gotoByName/GotoActionModel.java b/platform/lang-impl/src/com/intellij/ide/util/gotoByName/GotoActionModel.java index 0ddbd5a31d0d..bc9414271b4d 100644 --- a/platform/lang-impl/src/com/intellij/ide/util/gotoByName/GotoActionModel.java +++ b/platform/lang-impl/src/com/intellij/ide/util/gotoByName/GotoActionModel.java @@ -182,7 +182,7 @@ public final class GotoActionModel implements ChooseByNameModel, Comparator