[LL FIR] KT-57455 Avoid creating optional annotation class providers
- An `OptionalAnnotationClassesProvider` only needs to be created if the package part provider may even have optional annotation classes. - In the IDE case, the package part provider never provides optional annotation classes, so especially in the IDE, we can avoid a lot of useless symbol providers with this.
This commit is contained in:
committed by
Space Team
parent
d3be38476a
commit
f9785c1050
+24
@@ -84,4 +84,28 @@ class OptionalAnnotationClassesProvider(
|
||||
|
||||
override fun getPackage(fqName: FqName): FqName? =
|
||||
if (optionalAnnotationClassesAndPackages.second.contains(fqName.asString())) fqName else null
|
||||
|
||||
companion object {
|
||||
/**
|
||||
* Creates a new [OptionalAnnotationClassesProvider] if [packagePartProvider] has any optional annotation classes. Otherwise, the
|
||||
* symbol provider does not need to be created because it would provide no symbols.
|
||||
*/
|
||||
fun createIfNeeded(
|
||||
session: FirSession,
|
||||
moduleDataProvider: ModuleDataProvider,
|
||||
kotlinScopeProvider: FirKotlinScopeProvider,
|
||||
packagePartProvider: PackagePartProvider,
|
||||
defaultDeserializationOrigin: FirDeclarationOrigin = FirDeclarationOrigin.Library,
|
||||
): OptionalAnnotationClassesProvider? {
|
||||
if (!packagePartProvider.mayHaveOptionalAnnotationClasses()) return null
|
||||
|
||||
return OptionalAnnotationClassesProvider(
|
||||
session,
|
||||
moduleDataProvider,
|
||||
kotlinScopeProvider,
|
||||
packagePartProvider,
|
||||
defaultDeserializationOrigin,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user