mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-19 21:11:28 +07:00
[threading] IJPL-236136: Also add context cancellation wrapping for PsiSearchHelperImpl#processRequests
(cherry picked from commit 9a29797dc768446133225b396a200057125ff385) IJ-CR-193149 GitOrigin-RevId: 2feefcb08e4a3ef81de714b377a818b00358ef6e
This commit is contained in:
committed by
intellij-monorepo-bot
parent
9357f910d6
commit
7b7ce206c6
@@ -884,40 +884,42 @@ public class PsiSearchHelperImpl implements PsiSearchHelper {
|
||||
Map<SearchRequestCollector, Processor<? super PsiReference>> collectors = new HashMap<>();
|
||||
collectors.put(collector, processor);
|
||||
|
||||
ProgressIndicator progress = getOrCreateIndicator();
|
||||
if (appendCollectorsFromQueryRequests(progress, collectors) == QueryRequestsRunResult.STOPPED) {
|
||||
return false;
|
||||
}
|
||||
do {
|
||||
Map<TextIndexQuery, Collection<RequestWithProcessor>> globals = new HashMap<>();
|
||||
List<Computable<Boolean>> customs = new ArrayList<>();
|
||||
Set<RequestWithProcessor> locals = new LinkedHashSet<>();
|
||||
Map<RequestWithProcessor, Processor<? super CandidateFileInfo>> localProcessors = new HashMap<>();
|
||||
distributePrimitives(collectors, locals, globals, customs, localProcessors);
|
||||
if (!processGlobalRequestsOptimized(globals, progress, localProcessors)) {
|
||||
return ConcurrencyUtils.runWithIndicatorOrContextCancellation((__) -> {
|
||||
ProgressIndicator progress = getOrCreateIndicator();
|
||||
if (appendCollectorsFromQueryRequests(progress, collectors) == QueryRequestsRunResult.STOPPED) {
|
||||
return false;
|
||||
}
|
||||
for (RequestWithProcessor local : locals) {
|
||||
progress.checkCanceled();
|
||||
if (!processSingleRequest(local.request, local.refProcessor)) {
|
||||
do {
|
||||
Map<TextIndexQuery, Collection<RequestWithProcessor>> globals = new HashMap<>();
|
||||
List<Computable<Boolean>> customs = new ArrayList<>();
|
||||
Set<RequestWithProcessor> locals = new LinkedHashSet<>();
|
||||
Map<RequestWithProcessor, Processor<? super CandidateFileInfo>> localProcessors = new HashMap<>();
|
||||
distributePrimitives(collectors, locals, globals, customs, localProcessors);
|
||||
if (!processGlobalRequestsOptimized(globals, progress, localProcessors)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
for (Computable<Boolean> custom : customs) {
|
||||
progress.checkCanceled();
|
||||
if (!custom.compute()) {
|
||||
for (RequestWithProcessor local : locals) {
|
||||
progress.checkCanceled();
|
||||
if (!processSingleRequest(local.request, local.refProcessor)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
for (Computable<Boolean> custom : customs) {
|
||||
progress.checkCanceled();
|
||||
if (!custom.compute()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
QueryRequestsRunResult result = appendCollectorsFromQueryRequests(progress, collectors);
|
||||
if (result == QueryRequestsRunResult.STOPPED) {
|
||||
return false;
|
||||
}
|
||||
else if (result == QueryRequestsRunResult.UNCHANGED) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
QueryRequestsRunResult result = appendCollectorsFromQueryRequests(progress, collectors);
|
||||
if (result == QueryRequestsRunResult.STOPPED) {
|
||||
return false;
|
||||
}
|
||||
else if (result == QueryRequestsRunResult.UNCHANGED) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
while (true);
|
||||
while (true);
|
||||
});
|
||||
}
|
||||
|
||||
private static @NotNull ProgressIndicator getOrCreateIndicator() {
|
||||
|
||||
Reference in New Issue
Block a user