[FIR] Extract resolveAndCheckFir to firUtils

Use it in compilerPipeline and FirKotlinToJvmBytecodeCompiler
This commit is contained in:
Ivan Kochurkin
2023-01-16 22:14:56 +01:00
committed by Space Team
parent 5f1ed56554
commit 04fc2bde96
3 changed files with 12 additions and 7 deletions
@@ -299,10 +299,7 @@ object FirKotlinToJvmBytecodeCompiler {
ktFiles: List<KtFile>, ktFiles: List<KtFile>,
diagnosticsReporter: BaseDiagnosticsCollector diagnosticsReporter: BaseDiagnosticsCollector
): ModuleCompilerAnalyzedOutput { ): ModuleCompilerAnalyzedOutput {
val rawFir = session.buildFirFromKtFiles(ktFiles) return resolveAndCheckFir(session, session.buildFirFromKtFiles(ktFiles), diagnosticsReporter)
val (scopeSession, fir) = session.runResolution(rawFir)
session.runCheckers(scopeSession, fir, diagnosticsReporter)
return ModuleCompilerAnalyzedOutput(session, scopeSession, fir)
} }
private fun CompilationContext.createComponentsForIncrementalCompilation( private fun CompilationContext.createComponentsForIncrementalCompilation(
@@ -420,9 +420,7 @@ private fun buildResolveAndCheckFir(
countFilesAndLines: KFunction2<Int, Int, Unit>? countFilesAndLines: KFunction2<Int, Int, Unit>?
): ModuleCompilerAnalyzedOutput { ): ModuleCompilerAnalyzedOutput {
val firFiles = session.buildFirViaLightTree(ktFiles, diagnosticsReporter, countFilesAndLines) val firFiles = session.buildFirViaLightTree(ktFiles, diagnosticsReporter, countFilesAndLines)
val (scopeSession, fir) = session.runResolution(firFiles) return resolveAndCheckFir(session, firFiles, diagnosticsReporter)
session.runCheckers(scopeSession, fir, diagnosticsReporter)
return ModuleCompilerAnalyzedOutput(session, scopeSession, fir)
} }
fun writeOutputs( fun writeOutputs(
@@ -52,3 +52,13 @@ fun FirSession.buildFirFromKtFiles(ktFiles: Collection<KtFile>): List<FirFile> {
} }
} }
} }
fun resolveAndCheckFir(
session: FirSession,
firFiles: List<FirFile>,
diagnosticsReporter: DiagnosticReporter
): ModuleCompilerAnalyzedOutput {
val (scopeSession, fir) = session.runResolution(firFiles)
session.runCheckers(scopeSession, fir, diagnosticsReporter)
return ModuleCompilerAnalyzedOutput(session, scopeSession, fir)
}