[LL FIR] refactoring, reuse the same function for registering JS FIR session components as in the compiler
So, if a new component is registered in the compiler, it's not forgotten for the LL FIR
This commit is contained in:
committed by
Space Team
parent
6b409d87f5
commit
f203d2d731
+5
-20
@@ -16,24 +16,18 @@ import org.jetbrains.kotlin.analysis.project.structure.KtModule
|
||||
import org.jetbrains.kotlin.analysis.project.structure.KtSourceModule
|
||||
import org.jetbrains.kotlin.fir.BuiltinTypes
|
||||
import org.jetbrains.kotlin.fir.SessionConfiguration
|
||||
import org.jetbrains.kotlin.fir.analysis.checkers.FirPlatformDiagnosticSuppressor
|
||||
import org.jetbrains.kotlin.fir.analysis.js.checkers.FirJsPlatformDiagnosticSuppressor
|
||||
import org.jetbrains.kotlin.fir.declarations.FirTypeSpecificityComparatorProvider
|
||||
import org.jetbrains.kotlin.fir.deserialization.SingleModuleDataProvider
|
||||
import org.jetbrains.kotlin.fir.resolve.calls.ConeCallConflictResolverFactory
|
||||
import org.jetbrains.kotlin.fir.resolve.providers.FirSymbolProvider
|
||||
import org.jetbrains.kotlin.fir.scopes.FirKotlinScopeProvider
|
||||
import org.jetbrains.kotlin.fir.session.FirJsSessionFactory.registerJsComponents
|
||||
import org.jetbrains.kotlin.fir.session.FirSessionFactoryHelper.registerDefaultComponents
|
||||
import org.jetbrains.kotlin.fir.session.JsCallConflictResolverFactory
|
||||
import org.jetbrains.kotlin.fir.types.typeContext
|
||||
import org.jetbrains.kotlin.js.resolve.JsTypeSpecificityComparatorWithoutDelegate
|
||||
|
||||
@OptIn(SessionConfiguration::class)
|
||||
internal class LLFirJsSessionFactory(project: Project) : LLFirAbstractSessionFactory(project) {
|
||||
override fun createSourcesSession(module: KtSourceModule): LLFirSourcesSession {
|
||||
return doCreateSourcesSession(module) { context ->
|
||||
registerDefaultComponents()
|
||||
registerModuleIndependentJsComponents()
|
||||
registerJsComponents(moduleKind = null)
|
||||
|
||||
register(
|
||||
FirSymbolProvider::class,
|
||||
@@ -53,7 +47,7 @@ internal class LLFirJsSessionFactory(project: Project) : LLFirAbstractSessionFac
|
||||
override fun createLibrarySession(module: KtModule): LLFirLibraryOrLibrarySourceResolvableModuleSession {
|
||||
return doCreateLibrarySession(module) { context ->
|
||||
registerDefaultComponents()
|
||||
registerModuleIndependentJsComponents()
|
||||
registerJsComponents(moduleKind = null)
|
||||
|
||||
register(
|
||||
FirSymbolProvider::class,
|
||||
@@ -71,14 +65,14 @@ internal class LLFirJsSessionFactory(project: Project) : LLFirAbstractSessionFac
|
||||
override fun createBinaryLibrarySession(module: KtBinaryModule): LLFirLibrarySession {
|
||||
return doCreateBinaryLibrarySession(module) {
|
||||
registerDefaultComponents()
|
||||
registerModuleIndependentJsComponents()
|
||||
registerJsComponents(moduleKind = null)
|
||||
}
|
||||
}
|
||||
|
||||
override fun createDanglingFileSession(module: KtDanglingFileModule, contextSession: LLFirSession): LLFirSession {
|
||||
return doCreateDanglingFileSession(module, contextSession) {
|
||||
registerDefaultComponents()
|
||||
registerModuleIndependentJsComponents()
|
||||
registerJsComponents(moduleKind = null)
|
||||
|
||||
register(
|
||||
FirSymbolProvider::class,
|
||||
@@ -114,13 +108,4 @@ internal class LLFirJsSessionFactory(project: Project) : LLFirAbstractSessionFac
|
||||
isFallbackDependenciesProvider,
|
||||
)
|
||||
}
|
||||
|
||||
private fun LLFirSession.registerModuleIndependentJsComponents() {
|
||||
register(ConeCallConflictResolverFactory::class, JsCallConflictResolverFactory)
|
||||
register(
|
||||
FirTypeSpecificityComparatorProvider::class,
|
||||
FirTypeSpecificityComparatorProvider(JsTypeSpecificityComparatorWithoutDelegate(typeContext))
|
||||
)
|
||||
register(FirPlatformDiagnosticSuppressor::class, FirJsPlatformDiagnosticSuppressor())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,8 +105,13 @@ object FirJsSessionFactory : FirAbstractSessionFactory() {
|
||||
}
|
||||
)
|
||||
|
||||
@OptIn(SessionConfiguration::class)
|
||||
private fun FirSession.registerJsComponents(compilerConfiguration: CompilerConfiguration) {
|
||||
val moduleKind = compilerConfiguration.get(JSConfigurationKeys.MODULE_KIND, ModuleKind.PLAIN)
|
||||
registerJsComponents(moduleKind)
|
||||
}
|
||||
|
||||
@OptIn(SessionConfiguration::class)
|
||||
fun FirSession.registerJsComponents(moduleKind: ModuleKind?) {
|
||||
register(ConeCallConflictResolverFactory::class, JsCallConflictResolverFactory)
|
||||
register(
|
||||
FirTypeSpecificityComparatorProvider::class,
|
||||
@@ -114,7 +119,8 @@ object FirJsSessionFactory : FirAbstractSessionFactory() {
|
||||
)
|
||||
register(FirPlatformDiagnosticSuppressor::class, FirJsPlatformDiagnosticSuppressor())
|
||||
|
||||
val moduleKind = compilerConfiguration.get(JSConfigurationKeys.MODULE_KIND, ModuleKind.PLAIN)
|
||||
register(FirJsModuleKind::class, FirJsModuleKind(moduleKind))
|
||||
if (moduleKind != null) {
|
||||
register(FirJsModuleKind::class, FirJsModuleKind(moduleKind))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user