[LL API] Add tests for 'out of content root' analysis mode

This commit is contained in:
Yan Zhulanow
2022-12-14 20:37:14 +09:00
committed by Space Team
parent e4c2902e81
commit f1edbc1a14
58 changed files with 2698 additions and 280 deletions
@@ -10,10 +10,11 @@ import com.intellij.openapi.project.Project
import org.jetbrains.kotlin.analysis.api.standalone.base.project.structure.KtModuleProjectStructure
import org.jetbrains.kotlin.analysis.low.level.api.fir.compiler.based.SealedClassesInheritorsCaclulatorPreAnalysisHandler
import org.jetbrains.kotlin.analysis.low.level.api.fir.test.configurators.AnalysisApiFirSourceTestConfigurator
import org.jetbrains.kotlin.analysis.test.framework.project.structure.KtModuleFactory
import org.jetbrains.kotlin.analysis.test.framework.project.structure.KtSourceModuleFactory
import org.jetbrains.kotlin.analysis.test.framework.test.configurators.AnalysisApiTestConfigurator
import org.jetbrains.kotlin.analysis.test.framework.test.configurators.AnalysisApiTestServiceRegistrar
import org.jetbrains.kotlin.analysis.test.framework.test.configurators.FrontendKind
import org.jetbrains.kotlin.psi.KtFile
import org.jetbrains.kotlin.test.builders.TestConfigurationBuilder
import org.jetbrains.kotlin.test.services.TestModuleStructure
import org.jetbrains.kotlin.test.services.TestServices
@@ -24,24 +25,22 @@ object StandaloneModeConfigurator : AnalysisApiTestConfigurator() {
override fun configureTest(builder: TestConfigurationBuilder, disposable: Disposable) {
with(builder) {
useAdditionalService<KtModuleFactory> { KtSourceModuleFactory() }
useDirectives(SealedClassesInheritorsCaclulatorPreAnalysisHandler.Directives)
usePreAnalysisHandlers(::SealedClassesInheritorsCaclulatorPreAnalysisHandler)
}
}
private val sourceConfigurator = AnalysisApiFirSourceTestConfigurator(analyseInDependentSession = false)
override val serviceRegistrars: List<AnalysisApiTestServiceRegistrar>
get() = AnalysisApiFirSourceTestConfigurator(analyseInDependentSession = false).serviceRegistrars +
listOf(StandaloneModeTestServiceRegistrar)
get() = sourceConfigurator.serviceRegistrars + listOf(StandaloneModeTestServiceRegistrar)
override fun createModules(
moduleStructure: TestModuleStructure,
testServices: TestServices,
project: Project
): KtModuleProjectStructure {
return AnalysisApiFirSourceTestConfigurator(analyseInDependentSession = false).createModules(moduleStructure, testServices, project)
}
override fun doOutOfBlockModification(file: KtFile) {
AnalysisApiFirSourceTestConfigurator(analyseInDependentSession = false).doOutOfBlockModification(file)
return sourceConfigurator.createModules(moduleStructure, testServices, project)
}
}