[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:
+5
-5
@@ -53,10 +53,7 @@ internal class FirDeclarationForCompiledElementSearcher(private val symbolProvid
|
|||||||
val classId = declaration.getClassId()
|
val classId = declaration.getClassId()
|
||||||
?: errorWithFirSpecificEntries("Non-local class should have classId", psi = declaration)
|
?: errorWithFirSpecificEntries("Non-local class should have classId", psi = declaration)
|
||||||
|
|
||||||
val classCandidate = when (symbolProvider) {
|
val classCandidate = symbolProvider.getClassLikeSymbolByClassId(classId)
|
||||||
is LLFirModuleWithDependenciesSymbolProvider -> symbolProvider.getClassLikeSymbolByFqNameWithoutDependencies(classId)
|
|
||||||
else -> symbolProvider.getClassLikeSymbolByClassId(classId)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (classCandidate == null) {
|
if (classCandidate == null) {
|
||||||
errorWithFirSpecificEntries("We should be able to find a symbol for $classId", psi = declaration) {
|
errorWithFirSpecificEntries("We should be able to find a symbol for $classId", psi = declaration) {
|
||||||
@@ -131,7 +128,10 @@ private fun FirSymbolProvider.findCallableCandidates(
|
|||||||
|
|
||||||
@OptIn(FirSymbolProviderInternals::class)
|
@OptIn(FirSymbolProviderInternals::class)
|
||||||
return when (this) {
|
return when (this) {
|
||||||
is LLFirModuleWithDependenciesSymbolProvider -> getTopLevelCallableSymbolsWithoutDependencies(packageFqName, shortName)
|
is LLFirModuleWithDependenciesSymbolProvider -> {
|
||||||
|
getTopLevelCallableSymbolsWithoutDependencies(packageFqName, shortName).takeUnless { it.isEmpty() }
|
||||||
|
?: getTopLevelCallableSymbols(packageFqName, shortName)
|
||||||
|
}
|
||||||
else -> getTopLevelCallableSymbols(packageFqName, shortName)
|
else -> getTopLevelCallableSymbols(packageFqName, shortName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user