[AA] Allow declaration provider package set computation to return null
- This is in line with the API of `FirSymbolNamesProvider`. It only makes sense to compute package sets for source and library modules. Also, source module package set computation in the IDE is currently broken, so it's good to be able to return `null` in the meantime. - This also allows the removal of the workaround for source modules in `LLFirProviderHelper`, as the IDE declaration provider can now return `null` itself in this case. ^KTIJ-27411
This commit is contained in:
committed by
Space Team
parent
5c091f611e
commit
576d8d1c10
+6
-1
@@ -45,7 +45,12 @@ public abstract class KotlinDeclarationProvider : KotlinComposableProvider {
|
||||
|
||||
public abstract fun findFilesForScript(scriptFqName: FqName): Collection<KtScript>
|
||||
|
||||
public abstract fun computePackageSetWithTopLevelCallableDeclarations(): Set<String>
|
||||
/**
|
||||
* Calculates the set of package names which can be provided by this declaration provider and contain callables.
|
||||
*
|
||||
* The set may contain false positives. `null` may be returned if the package set is too expensive or impossible to compute.
|
||||
*/
|
||||
public abstract fun computePackageSetWithTopLevelCallableDeclarations(): Set<String>?
|
||||
}
|
||||
|
||||
public abstract class KotlinDeclarationProviderFactory {
|
||||
|
||||
+3
-2
@@ -13,6 +13,7 @@ import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.utils.flatMapToNullableSet
|
||||
|
||||
public class CompositeKotlinDeclarationProvider private constructor(
|
||||
override val providers: List<KotlinDeclarationProvider>
|
||||
@@ -65,8 +66,8 @@ public class CompositeKotlinDeclarationProvider private constructor(
|
||||
return providers.flatMapTo(mutableListOf()) { it.findFilesForScript(scriptFqName) }
|
||||
}
|
||||
|
||||
override fun computePackageSetWithTopLevelCallableDeclarations(): Set<String> {
|
||||
return providers.flatMapTo(mutableSetOf()) { it.computePackageSetWithTopLevelCallableDeclarations() }
|
||||
override fun computePackageSetWithTopLevelCallableDeclarations(): Set<String>? {
|
||||
return providers.flatMapToNullableSet { it.computePackageSetWithTopLevelCallableDeclarations() }
|
||||
}
|
||||
|
||||
public companion object {
|
||||
|
||||
+1
-4
@@ -102,10 +102,7 @@ internal class LLFirProviderHelper(
|
||||
val symbolNameCache = FirCompositeCachedSymbolNamesProvider.create(
|
||||
firSession,
|
||||
listOfNotNull(
|
||||
object : LLFirKotlinSymbolNamesProvider(declarationProvider, allowKotlinPackage) {
|
||||
// This is a temporary workaround for KTIJ-25536.
|
||||
override fun getPackageNamesWithTopLevelCallables(): Set<String>? = null
|
||||
},
|
||||
LLFirKotlinSymbolNamesProvider(declarationProvider, allowKotlinPackage),
|
||||
extensionTool?.symbolNamesProvider,
|
||||
)
|
||||
)
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@ internal open class LLFirKotlinSymbolNamesProvider(
|
||||
}
|
||||
|
||||
override fun getPackageNamesWithTopLevelCallables(): Set<String>? {
|
||||
val packageNames = declarationProvider.computePackageSetWithTopLevelCallableDeclarations()
|
||||
val packageNames = declarationProvider.computePackageSetWithTopLevelCallableDeclarations() ?: return null
|
||||
|
||||
if (allowKotlinPackage == false && packageNames.any { it.isKotlinPackage() }) {
|
||||
return packageNames.filterToSetOrEmpty { !it.isKotlinPackage() }
|
||||
|
||||
Reference in New Issue
Block a user