mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Action search: make it possible to use from AI
GitOrigin-RevId: cdedc88fa44bd6d26679a38615f9ede3b3da3141
This commit is contained in:
committed by
intellij-monorepo-bot
parent
675dbd16f3
commit
faeb98c666
@@ -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<String>(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<String>
|
||||
): List<Job> {
|
||||
val abbreviationsJob = processAbbreviations(pattern, presentationProvider, consumer)
|
||||
|
||||
val nonMatchedIdsChannel = Channel<String>(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
|
||||
|
||||
@@ -182,7 +182,7 @@ public final class GotoActionModel implements ChooseByNameModel, Comparator<Obje
|
||||
public static class MatchedValue implements MergeableElement, UiInspectorContextProvider {
|
||||
public final @NotNull Object value;
|
||||
final @NotNull MatchedValueType type;
|
||||
final @NotNull String pattern;
|
||||
public final @NotNull String pattern;
|
||||
final int matchingDegree;
|
||||
|
||||
public @Nullable Double similarityScore = null;
|
||||
|
||||
Reference in New Issue
Block a user