[FIR] Migrate fir plugin prototype tests to new test infrastructure
This commit is contained in:
committed by
TeamCityServer
parent
e56c87a17a
commit
6d42914e56
@@ -45,7 +45,8 @@ class FirAnalyzerFacade(
|
||||
val languageVersionSettings: LanguageVersionSettings,
|
||||
val ktFiles: Collection<KtFile> = emptyList(), // may be empty if light tree mode enabled
|
||||
val originalFiles: Collection<File> = emptyList(), // may be empty if light tree mode disabled
|
||||
val useLightTree: Boolean = false
|
||||
val useLightTree: Boolean = false,
|
||||
val enablePluginPhases: Boolean = false,
|
||||
) : AbstractFirAnalyzerFacade() {
|
||||
private var firFiles: List<FirFile>? = null
|
||||
private var _scopeSession: ScopeSession? = null
|
||||
@@ -77,7 +78,7 @@ class FirAnalyzerFacade(
|
||||
override fun runResolution(): List<FirFile> {
|
||||
if (firFiles == null) buildRawFir()
|
||||
if (_scopeSession != null) return firFiles!!
|
||||
val resolveProcessor = FirTotalResolveProcessor(session)
|
||||
val resolveProcessor = FirTotalResolveProcessor(session, enablePluginPhases)
|
||||
resolveProcessor.process(firFiles!!)
|
||||
_scopeSession = resolveProcessor.scopeSession
|
||||
return firFiles!!
|
||||
|
||||
+2
-2
@@ -15,10 +15,10 @@ import org.jetbrains.kotlin.fir.resolve.transformers.body.resolve.FirImplicitTyp
|
||||
import org.jetbrains.kotlin.fir.resolve.transformers.contracts.FirContractResolveProcessor
|
||||
import org.jetbrains.kotlin.fir.resolve.transformers.plugin.*
|
||||
|
||||
class FirTotalResolveProcessor(session: FirSession) {
|
||||
class FirTotalResolveProcessor(session: FirSession, enablePluginPhases: Boolean = false) {
|
||||
val scopeSession: ScopeSession = ScopeSession()
|
||||
|
||||
private val processors: List<FirResolveProcessor> = createAllCompilerResolveProcessors(session, scopeSession)
|
||||
private val processors: List<FirResolveProcessor> = createAllCompilerResolveProcessors(session, scopeSession, enablePluginPhases)
|
||||
|
||||
fun process(files: List<FirFile>) {
|
||||
for (processor in processors) {
|
||||
|
||||
+4
@@ -57,4 +57,8 @@ object FirDiagnosticsDirectives : SimpleDirectivesContainer() {
|
||||
Enables ${FirScopeDumpHandler::class}
|
||||
""".trimIndent()
|
||||
)
|
||||
|
||||
val ENABLE_PLUGIN_PHASES by directive(
|
||||
description = "Enable plugin phases"
|
||||
)
|
||||
}
|
||||
|
||||
+18
-2
@@ -17,6 +17,7 @@ import org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM
|
||||
import org.jetbrains.kotlin.cli.jvm.config.jvmClasspathRoots
|
||||
import org.jetbrains.kotlin.cli.jvm.config.jvmModularRoots
|
||||
import org.jetbrains.kotlin.config.JVMConfigurationKeys
|
||||
import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.analysis.FirAnalyzerFacade
|
||||
import org.jetbrains.kotlin.fir.checkers.registerExtendedCommonCheckers
|
||||
import org.jetbrains.kotlin.fir.moduleData
|
||||
@@ -38,8 +39,14 @@ import org.jetbrains.kotlin.test.model.*
|
||||
import org.jetbrains.kotlin.test.services.*
|
||||
|
||||
class FirFrontendFacade(
|
||||
testServices: TestServices
|
||||
testServices: TestServices,
|
||||
private val additionalSessionConfiguration: SessionConfiguration?
|
||||
) : FrontendFacade<FirOutputArtifact>(testServices, FrontendKinds.FIR) {
|
||||
// Separate constructor is needed for creating callable references to it
|
||||
constructor(testServices: TestServices) : this(testServices, additionalSessionConfiguration = null)
|
||||
|
||||
fun interface SessionConfiguration : (FirSessionFactory.FirSessionConfigurator) -> Unit
|
||||
|
||||
override val additionalServices: List<ServiceRegistrationData>
|
||||
get() = listOf(service(::FirModuleInfoProvider))
|
||||
|
||||
@@ -98,11 +105,20 @@ class FirFrontendFacade(
|
||||
if (FirDiagnosticsDirectives.WITH_EXTENDED_CHECKERS in module.directives) {
|
||||
registerExtendedCommonCheckers()
|
||||
}
|
||||
additionalSessionConfiguration?.invoke(this)
|
||||
}
|
||||
|
||||
moduleInfoProvider.registerModuleData(module, session.moduleData)
|
||||
|
||||
val firAnalyzerFacade = FirAnalyzerFacade(session, languageVersionSettings, ktFiles, originalFiles, lightTreeEnabled)
|
||||
val enablePluginPhases = FirDiagnosticsDirectives.ENABLE_PLUGIN_PHASES in module.directives
|
||||
val firAnalyzerFacade = FirAnalyzerFacade(
|
||||
session,
|
||||
languageVersionSettings,
|
||||
ktFiles,
|
||||
originalFiles,
|
||||
lightTreeEnabled,
|
||||
enablePluginPhases
|
||||
)
|
||||
val firFiles = firAnalyzerFacade.runResolution()
|
||||
val filesMap = firFiles.mapNotNull { firFile ->
|
||||
val testFile = module.files.firstOrNull { it.name == firFile.name } ?: return@mapNotNull null
|
||||
|
||||
Reference in New Issue
Block a user