Skip to content

Commit ddc6238

Browse files
Add LightClassUtil.getLightClassMethodsByName to avoid resolving all lightClassMethods and filtration later on
Relates to #KTIJ-1069 Relates to #EA-249999 (cherry picked from commit 6331a13)
1 parent 8995424 commit ddc6238

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

compiler/light-classes/src/org/jetbrains/kotlin/asJava/LightClassUtil.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,13 +124,18 @@ object LightClassUtil {
124124
return getPsiMethodWrappers(function).toList()
125125
}
126126

127+
fun getLightClassMethodsByName(function: KtFunction, name: String): Sequence<KtLightMethod> {
128+
return getPsiMethodWrappers(function, name)
129+
}
130+
127131
private fun getPsiMethodWrapper(declaration: KtDeclaration): PsiMethod? {
128132
return getPsiMethodWrappers(declaration).firstOrNull()
129133
}
130134

131-
private fun getPsiMethodWrappers(declaration: KtDeclaration): Sequence<KtLightMethod> =
135+
private fun getPsiMethodWrappers(declaration: KtDeclaration, name: String? = null): Sequence<KtLightMethod> =
132136
getWrappingClasses(declaration).flatMap { it.methods.asSequence() }
133137
.filterIsInstance<KtLightMethod>()
138+
.filter { name == null || name == it.name }
134139
.filter { it.kotlinOrigin === declaration || it.navigationElement === declaration }
135140

136141
private fun getWrappingClass(declaration: KtDeclaration): PsiClass? {

idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/KotlinShortNamesCache.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ class KotlinShortNamesCache(private val project: Project) : PsiShortNamesCache()
192192
filter,
193193
KtNamedFunction::class.java
194194
) { ktNamedFunction ->
195-
val methods = LightClassUtil.getLightClassMethods(ktNamedFunction).filter { it.name == name }
195+
val methods = LightClassUtil.getLightClassMethodsByName(ktNamedFunction, name)
196196
return@processElements methods.all { method ->
197197
processor.process(method)
198198
}

0 commit comments

Comments
 (0)