[LL API] Search declarations in dependencies as a fallback

'JvmClassFileBasedSymbolProvider' works incorrectly for some cases,
such as built-in classes. Moreover, the whole declaration binding logic
looks over-complicated and redundant, as we get a 'ClassId'/'CallableId'
from a 'KtDeclaration', and look for it again in indices.

This commit fixes a bunch of failing completion tests:
- HighLevelJvmBasicCompletionTestGenerated
- HighLevelMultiFileJvmBasicCompletionTestGenerated
- FirKeywordCompletionHandlerTestGenerated
This commit is contained in:
Yan Zhulanow
2023-03-06 17:48:31 +09:00
committed by Space Team
parent 342488e66e
commit 07fdbeca19
@@ -53,10 +53,7 @@ internal class FirDeclarationForCompiledElementSearcher(private val symbolProvid
val classId = declaration.getClassId()
?: errorWithFirSpecificEntries("Non-local class should have classId", psi = declaration)
val classCandidate = when (symbolProvider) {
is LLFirModuleWithDependenciesSymbolProvider -> symbolProvider.getClassLikeSymbolByFqNameWithoutDependencies(classId)
else -> symbolProvider.getClassLikeSymbolByClassId(classId)
}
val classCandidate = symbolProvider.getClassLikeSymbolByClassId(classId)
if (classCandidate == null) {
errorWithFirSpecificEntries("We should be able to find a symbol for $classId", psi = declaration) {
@@ -131,7 +128,10 @@ private fun FirSymbolProvider.findCallableCandidates(
@OptIn(FirSymbolProviderInternals::class)
return when (this) {
is LLFirModuleWithDependenciesSymbolProvider -> getTopLevelCallableSymbolsWithoutDependencies(packageFqName, shortName)
is LLFirModuleWithDependenciesSymbolProvider -> {
getTopLevelCallableSymbolsWithoutDependencies(packageFqName, shortName).takeUnless { it.isEmpty() }
?: getTopLevelCallableSymbols(packageFqName, shortName)
}
else -> getTopLevelCallableSymbols(packageFqName, shortName)
}
}