[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>,
diagnosticsReporter: BaseDiagnosticsCollector
): ModuleCompilerAnalyzedOutput {
val rawFir = session.buildFirFromKtFiles(ktFiles)
val (scopeSession, fir) = session.runResolution(rawFir)
session.runCheckers(scopeSession, fir, diagnosticsReporter)
return ModuleCompilerAnalyzedOutput(session, scopeSession, fir)
return resolveAndCheckFir(session, session.buildFirFromKtFiles(ktFiles), diagnosticsReporter)
}
private fun CompilationContext.createComponentsForIncrementalCompilation(
@@ -420,9 +420,7 @@ private fun buildResolveAndCheckFir(
countFilesAndLines: KFunction2<Int, Int, Unit>?
): ModuleCompilerAnalyzedOutput {
val firFiles = session.buildFirViaLightTree(ktFiles, diagnosticsReporter, countFilesAndLines)
val (scopeSession, fir) = session.runResolution(firFiles)
session.runCheckers(scopeSession, fir, diagnosticsReporter)
return ModuleCompilerAnalyzedOutput(session, scopeSession, fir)
return resolveAndCheckFir(session, firFiles, diagnosticsReporter)
}
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)
}