mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
KTIJ-33154 [kotlin] Consistently use cancelling processor in getAllElements
In cases when `SubKey` is a very small percentage of all possible results collected by `processAllElements`, simply returning `true` from processing without any cancellation checks can be problematic. This change makes sure that `processor` with cancellation checks is consistently used for every processed result. The downside is that now we have to use unchecked cast of a collection. GitOrigin-RevId: d475d20b0d4df33f8aff7cf65eb7b79659b40cf9
This commit is contained in:
committed by
intellij-monorepo-bot
parent
56f14e2efd
commit
e235b7aae5
+8
-9
@@ -78,15 +78,14 @@ abstract class KotlinStringStubIndexHelper<Key : NavigatablePsiElement>(private
|
||||
noinline keyFilter: (String) -> Boolean = { true },
|
||||
noinline valueFilter: (SubKey) -> Boolean = { true },
|
||||
): Sequence<SubKey> {
|
||||
val results = mutableListOf<SubKey>()
|
||||
val processor = cancelableCollectFilterProcessor(results, filter = valueFilter)
|
||||
processAllElements(project, scope, keyFilter) { key ->
|
||||
if (key is SubKey)
|
||||
processor.process(key)
|
||||
else
|
||||
true
|
||||
}
|
||||
return results.asSequence() // todo move valueFilter out
|
||||
val results = mutableListOf<Any>()
|
||||
val processor = cancelableCollectFilterProcessor(results) { key -> key is SubKey && valueFilter(key) }
|
||||
|
||||
processAllElements(project, scope, keyFilter, processor)
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
val castedResults = results as List<SubKey>
|
||||
return castedResults.asSequence() // todo move valueFilter out
|
||||
}
|
||||
|
||||
fun processAllElements(
|
||||
|
||||
Reference in New Issue
Block a user