FIR IDE: implement incremental function analysis

This commit is contained in:
Ilya Kirillov
2020-09-17 15:14:16 +03:00
parent 8bcba00bb7
commit 9a99703f24
20 changed files with 583 additions and 271 deletions
@@ -281,14 +281,19 @@ inline fun <reified T : PsiElement> PsiElement.collectDescendantsOfType(noinline
inline fun <reified T : PsiElement> PsiElement.collectDescendantsOfType(
crossinline canGoInside: (PsiElement) -> Boolean,
noinline predicate: (T) -> Boolean = { true }
): List<T> {
val result = ArrayList<T>()
): List<T> = collectDescendantsOfTypeTo(ArrayList(), canGoInside, predicate)
inline fun <reified T : PsiElement, C : MutableCollection<T>> PsiElement.collectDescendantsOfTypeTo(
to: C,
crossinline canGoInside: (PsiElement) -> Boolean,
noinline predicate: (T) -> Boolean = { true }
): C {
forEachDescendantOfType<T>(canGoInside) {
if (predicate(it)) {
result.add(it)
to.add(it)
}
}
return result
return to
}
// ----------- Working with offsets, ranges and texts ----------------------------------------------------------------------------------------------