Add LightClassUtil.getLightClassMethodsByName to avoid resolving all lightClassMethods and filtration later on
This commit is contained in:
committed by
Space
parent
167bfcf6ea
commit
6331a135c8
@@ -124,13 +124,18 @@ object LightClassUtil {
|
|||||||
return getPsiMethodWrappers(function).toList()
|
return getPsiMethodWrappers(function).toList()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun getLightClassMethodsByName(function: KtFunction, name: String): Sequence<KtLightMethod> {
|
||||||
|
return getPsiMethodWrappers(function, name)
|
||||||
|
}
|
||||||
|
|
||||||
private fun getPsiMethodWrapper(declaration: KtDeclaration): PsiMethod? {
|
private fun getPsiMethodWrapper(declaration: KtDeclaration): PsiMethod? {
|
||||||
return getPsiMethodWrappers(declaration).firstOrNull()
|
return getPsiMethodWrappers(declaration).firstOrNull()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getPsiMethodWrappers(declaration: KtDeclaration): Sequence<KtLightMethod> =
|
private fun getPsiMethodWrappers(declaration: KtDeclaration, name: String? = null): Sequence<KtLightMethod> =
|
||||||
getWrappingClasses(declaration).flatMap { it.methods.asSequence() }
|
getWrappingClasses(declaration).flatMap { it.methods.asSequence() }
|
||||||
.filterIsInstance<KtLightMethod>()
|
.filterIsInstance<KtLightMethod>()
|
||||||
|
.filter { name == null || name == it.name }
|
||||||
.filter { it.kotlinOrigin === declaration || it.navigationElement === declaration }
|
.filter { it.kotlinOrigin === declaration || it.navigationElement === declaration }
|
||||||
|
|
||||||
private fun getWrappingClass(declaration: KtDeclaration): PsiClass? {
|
private fun getWrappingClass(declaration: KtDeclaration): PsiClass? {
|
||||||
|
|||||||
@@ -192,7 +192,7 @@ class KotlinShortNamesCache(private val project: Project) : PsiShortNamesCache()
|
|||||||
filter,
|
filter,
|
||||||
KtNamedFunction::class.java
|
KtNamedFunction::class.java
|
||||||
) { ktNamedFunction ->
|
) { ktNamedFunction ->
|
||||||
val methods = LightClassUtil.getLightClassMethods(ktNamedFunction).filter { it.name == name }
|
val methods = LightClassUtil.getLightClassMethodsByName(ktNamedFunction, name)
|
||||||
return@processElements methods.all { method ->
|
return@processElements methods.all { method ->
|
||||||
processor.process(method)
|
processor.process(method)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user