Postpone counting light elements till all psi checks done

This commit is contained in:
Nikolay Krasko
2017-06-30 16:19:53 +03:00
parent fe17d616b9
commit 25109671b1
@@ -110,17 +110,24 @@ class KotlinOverridingMethodReferenceSearcher : MethodUsagesSearcher() {
return true
}
var lightMethods = refElement.toLightMethods()
fun countNonFinalLightMethods() = refElement
.toLightMethods()
.filterNot { it.hasModifierProperty(PsiModifier.FINAL) }
.ifEmpty { return true }
if (refElement is KtProperty || refElement is KtParameter) {
if (isWrongAccessorReference()) return true
lightMethods = lightMethods.filter { JvmAbi.isGetterName(it.name) == isGetter }
}
if (refElement is KtNamedFunction) {
lightMethods = lightMethods.filter { it.name == method.name }
val lightMethods = when (refElement) {
is KtProperty, is KtParameter -> {
if (isWrongAccessorReference()) return true
countNonFinalLightMethods().filter { JvmAbi.isGetterName(it.name) == isGetter }
}
is KtNamedFunction ->
countNonFinalLightMethods().filter { it.name == method.name }
else ->
countNonFinalLightMethods()
}
return lightMethods.all { super.processInexactReference(ref, it, method, consumer) }
}
}