Don't choose navigation target only by index (KT-26004)

There might be situation when platform code has a declaration with
another signature and the same fqname, but navigating to common
declaration is expected.

 #KT-26004 Fixed
This commit is contained in:
Nikolay Krasko
2018-09-21 18:34:24 +03:00
parent b79dcbe8e6
commit dda1673096
@@ -203,20 +203,16 @@ object SourceNavigationHelper {
navigationKind: NavigationKind
): Collection<KtNamedDeclaration> {
val scopes = targetScopes(declaration, navigationKind)
val index = getIndexForTopLevelPropertyOrFunction(declaration)
for (scope in scopes) {
val candidates = index.get(declaration.fqName!!.asString(), declaration.project, scope)
if (candidates.isNotEmpty()) return candidates
}
return emptyList()
}
private fun getIndexForTopLevelPropertyOrFunction(
decompiledDeclaration: KtNamedDeclaration
): StringStubIndexExtension<out KtNamedDeclaration> = when (decompiledDeclaration) {
is KtNamedFunction -> KotlinTopLevelFunctionFqnNameIndex.getInstance()
is KtProperty -> KotlinTopLevelPropertyFqnNameIndex.getInstance()
else -> throw IllegalArgumentException("Neither function nor declaration: " + decompiledDeclaration::class.java.name)
val index: StringStubIndexExtension<out KtNamedDeclaration> = when (declaration) {
is KtNamedFunction -> KotlinTopLevelFunctionFqnNameIndex.getInstance()
is KtProperty -> KotlinTopLevelPropertyFqnNameIndex.getInstance()
else -> throw IllegalArgumentException("Neither function nor declaration: " + declaration::class.java.name)
}
return scopes.flatMap { scope ->
index.get(declaration.fqName!!.asString(), declaration.project, scope)
}
}
private fun getInitialMemberCandidates(