[AA] Refactoring: Rename KtModuleFactory to KtTestModuleFactory

^KT-65960
This commit is contained in:
Marco Pennekamp
2024-02-26 16:18:40 +01:00
committed by Space Team
parent 3f04604187
commit 4ea3de1760
18 changed files with 53 additions and 53 deletions
@@ -9,8 +9,8 @@ import com.intellij.openapi.Disposable
import com.intellij.openapi.project.Project
import org.jetbrains.kotlin.analysis.api.impl.base.test.configurators.AnalysisApiBaseTestServiceRegistrar
import org.jetbrains.kotlin.analysis.api.impl.base.test.configurators.AnalysisApiDecompiledCodeTestServiceRegistrar
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.project.structure.KtTestModuleFactory
import org.jetbrains.kotlin.analysis.test.framework.project.structure.KtSourceTestModuleFactory
import org.jetbrains.kotlin.analysis.test.framework.project.structure.KtTestModule
import org.jetbrains.kotlin.analysis.test.framework.project.structure.KtTestModuleProjectStructure
import org.jetbrains.kotlin.analysis.test.framework.project.structure.TestModuleStructureFactory
@@ -42,7 +42,7 @@ object AnalysisApiFe10TestConfigurator : AnalysisApiTestConfigurator() {
override fun configureTest(builder: TestConfigurationBuilder, disposable: Disposable) {
builder.apply {
useAdditionalService<KtModuleFactory> { KtSourceModuleFactory }
useAdditionalService<KtTestModuleFactory> { KtSourceTestModuleFactory }
useAdditionalService { AnalysisApiIndexingConfiguration(AnalysisApiBinaryLibraryIndexingMode.NO_INDEXING) }
useConfigurators(
::CommonEnvironmentConfigurator,
@@ -11,8 +11,8 @@ import org.jetbrains.kotlin.analysis.api.impl.base.test.configurators.AnalysisAp
import org.jetbrains.kotlin.analysis.api.impl.base.test.configurators.AnalysisApiLibraryBaseTestServiceRegistrar
import org.jetbrains.kotlin.analysis.low.level.api.fir.test.base.AnalysisApiFirTestServiceRegistrar
import org.jetbrains.kotlin.analysis.low.level.api.fir.test.base.configureOptionalTestCompilerPlugin
import org.jetbrains.kotlin.analysis.test.framework.project.structure.KtLibraryBinaryDecompiledModuleFactory
import org.jetbrains.kotlin.analysis.test.framework.project.structure.KtModuleFactory
import org.jetbrains.kotlin.analysis.test.framework.project.structure.KtLibraryBinaryDecompiledTestModuleFactory
import org.jetbrains.kotlin.analysis.test.framework.project.structure.KtTestModuleFactory
import org.jetbrains.kotlin.analysis.test.framework.project.structure.KtTestModuleProjectStructure
import org.jetbrains.kotlin.analysis.test.framework.project.structure.TestModuleStructureFactory
import org.jetbrains.kotlin.analysis.test.framework.services.configuration.AnalysisApiJvmEnvironmentConfigurator
@@ -38,7 +38,7 @@ object StandaloneModeLibraryBinaryDecompiledTestConfigurator : StandaloneModeCon
useConfigurators(::ExternalAnnotationsEnvironmentConfigurator)
useSourcePreprocessor(::ExternalAnnotationsSourcePreprocessor)
useAdditionalService<KtModuleFactory> { KtLibraryBinaryDecompiledModuleFactory }
useAdditionalService<KtTestModuleFactory> { KtLibraryBinaryDecompiledTestModuleFactory }
useAdditionalService<TestModuleCompiler> { DispatchingTestModuleCompiler() }
useAdditionalService<TestModuleDecompiler> { TestModuleDecompilerJar() }
@@ -28,7 +28,7 @@ import java.nio.file.Path
/**
* @see TestModuleKind.CodeFragment
*/
object KtCodeFragmentModuleFactory : KtModuleFactory {
object KtCodeFragmentTestModuleFactory : KtTestModuleFactory {
override fun createModule(
testModule: TestModule,
contextModule: KtTestModule?,
@@ -15,7 +15,7 @@ import java.nio.file.Path
/**
* @see TestModuleKind.LibraryBinaryDecompiled
*/
object KtLibraryBinaryDecompiledModuleFactory : KtLibraryBinaryModuleFactoryBase() {
object KtLibraryBinaryDecompiledTestModuleFactory : KtLibraryBinaryTestModuleFactoryBase() {
override val testModuleKind: TestModuleKind
get() = TestModuleKind.LibraryBinaryDecompiled
@@ -14,7 +14,7 @@ import java.nio.file.Path
/**
* @see TestModuleKind.LibraryBinary
*/
object KtLibraryBinaryModuleFactory : KtLibraryBinaryModuleFactoryBase() {
object KtLibraryBinaryTestModuleFactory : KtLibraryBinaryTestModuleFactoryBase() {
override val testModuleKind: TestModuleKind
get() = TestModuleKind.LibraryBinary
@@ -15,7 +15,7 @@ import org.jetbrains.kotlin.test.model.TestModule
import org.jetbrains.kotlin.test.services.TestServices
import java.nio.file.Path
abstract class KtLibraryBinaryModuleFactoryBase : KtModuleFactory {
abstract class KtLibraryBinaryTestModuleFactoryBase : KtTestModuleFactory {
protected abstract val testModuleKind: TestModuleKind
protected abstract fun decompileToPsiFiles(binaryRoot: Path, testServices: TestServices, project: Project): List<PsiFile>
@@ -21,7 +21,7 @@ import java.nio.file.Path
/**
* @see TestModuleKind.LibrarySource
*/
object KtLibrarySourceModuleFactory : KtModuleFactory {
object KtLibrarySourceTestModuleFactory : KtTestModuleFactory {
override fun createModule(
testModule: TestModule,
contextModule: KtTestModule?,
@@ -15,7 +15,7 @@ import java.nio.file.Path
/**
* @see TestModuleKind.ScriptSource
*/
object KtScriptModuleFactory : KtModuleFactory {
object KtScriptTestModuleFactory : KtTestModuleFactory {
override fun createModule(
testModule: TestModule,
contextModule: KtTestModule?,
@@ -15,7 +15,7 @@ import java.nio.file.Path
/**
* @see TestModuleKind.Source
*/
object KtSourceModuleFactory : KtModuleFactory {
object KtSourceTestModuleFactory : KtTestModuleFactory {
override fun createModule(
testModule: TestModule,
contextModule: KtTestModule?,
@@ -13,9 +13,9 @@ import org.jetbrains.kotlin.test.services.TestService
import org.jetbrains.kotlin.test.services.TestServices
import java.nio.file.Path
fun interface KtModuleFactory : TestService {
fun interface KtTestModuleFactory : TestService {
/**
* Creates a [KtModule](org.jetbrains.kotlin.analysis.project.structure.KtModule) for the given [testModule].
* Creates a [KtTestModule] for the given [testModule].
*
* @param contextModule a module to use as a context module. Some kinds of modules (such as dangling file modules) require a
* context module. Modules representing code fragments also require a context element. That is why the [KtTestModule] is passed
@@ -32,13 +32,13 @@ fun interface KtModuleFactory : TestService {
): KtTestModule
}
private val TestServices.ktModuleFactory: KtModuleFactory by TestServices.testServiceAccessor()
private val TestServices.ktTestModuleFactory: KtTestModuleFactory by TestServices.testServiceAccessor()
/**
* Returns the appropriate [KtModuleFactory] to build a [KtModule][org.jetbrains.kotlin.analysis.project.structure.KtModule] for the given
* Returns the appropriate [KtTestModuleFactory] to build a [KtModule][org.jetbrains.kotlin.analysis.project.structure.KtModule] for the given
* [testModule].
*
* By default, the [KtModuleFactory] registered with these [TestServices] is returned. It may be overruled by the
* By default, the [KtTestModuleFactory] registered with these [TestServices] is returned. It may be overruled by the
* [MODULE_KIND][org.jetbrains.kotlin.analysis.test.framework.AnalysisApiTestDirectives.MODULE_KIND] directive for a specific test module.
*
* [DependencyKindModuleStructureTransformer][org.jetbrains.kotlin.analysis.test.framework.services.DependencyKindModuleStructureTransformer]
@@ -46,13 +46,13 @@ private val TestServices.ktModuleFactory: KtModuleFactory by TestServices.testSe
*
* @see org.jetbrains.kotlin.analysis.test.framework.services.DependencyKindModuleStructureTransformer
*/
fun TestServices.getKtModuleFactoryForTestModule(testModule: TestModule): KtModuleFactory = when (testModule.explicitTestModuleKind) {
TestModuleKind.Source -> KtSourceModuleFactory
TestModuleKind.LibraryBinary -> KtLibraryBinaryModuleFactory
TestModuleKind.LibraryBinaryDecompiled -> KtLibraryBinaryDecompiledModuleFactory
TestModuleKind.LibrarySource -> KtLibrarySourceModuleFactory
TestModuleKind.ScriptSource -> KtScriptModuleFactory
TestModuleKind.CodeFragment -> KtCodeFragmentModuleFactory
fun TestServices.getKtModuleFactoryForTestModule(testModule: TestModule): KtTestModuleFactory = when (testModule.explicitTestModuleKind) {
TestModuleKind.Source -> KtSourceTestModuleFactory
TestModuleKind.LibraryBinary -> KtLibraryBinaryTestModuleFactory
TestModuleKind.LibraryBinaryDecompiled -> KtLibraryBinaryDecompiledTestModuleFactory
TestModuleKind.LibrarySource -> KtLibrarySourceTestModuleFactory
TestModuleKind.ScriptSource -> KtScriptTestModuleFactory
TestModuleKind.CodeFragment -> KtCodeFragmentTestModuleFactory
TestModuleKind.NotUnderContentRoot -> error("Unsupported test module kind: ${TestModuleKind.NotUnderContentRoot}")
else -> ktModuleFactory
else -> ktTestModuleFactory
}
@@ -20,12 +20,12 @@ import org.jetbrains.kotlin.test.model.TestModule
*/
enum class TestModuleKind(val suffix: String) {
/**
* @see org.jetbrains.kotlin.analysis.test.framework.project.structure.KtSourceModuleFactory
* @see org.jetbrains.kotlin.analysis.test.framework.project.structure.KtSourceTestModuleFactory
*/
Source("Source"),
/**
* @see org.jetbrains.kotlin.analysis.test.framework.project.structure.KtLibraryBinaryModuleFactory
* @see org.jetbrains.kotlin.analysis.test.framework.project.structure.KtLibraryBinaryTestModuleFactory
*/
LibraryBinary("LibraryBinary"),
@@ -37,22 +37,22 @@ enum class TestModuleKind(val suffix: String) {
* module. See [AbstractAnalysisApiBasedTest][org.jetbrains.kotlin.analysis.test.framework.base.AbstractAnalysisApiBasedTest] for an
* overview of "main module" and "main file".
*
* @see org.jetbrains.kotlin.analysis.test.framework.project.structure.KtLibraryBinaryDecompiledModuleFactory
* @see org.jetbrains.kotlin.analysis.test.framework.project.structure.KtLibraryBinaryDecompiledTestModuleFactory
*/
LibraryBinaryDecompiled("LibraryBinaryDecompiled"),
/**
* @see org.jetbrains.kotlin.analysis.test.framework.project.structure.KtLibrarySourceModuleFactory
* @see org.jetbrains.kotlin.analysis.test.framework.project.structure.KtLibrarySourceTestModuleFactory
*/
LibrarySource("LibrarySource"),
/**
* @see org.jetbrains.kotlin.analysis.test.framework.project.structure.KtScriptModuleFactory
* @see org.jetbrains.kotlin.analysis.test.framework.project.structure.KtScriptTestModuleFactory
*/
ScriptSource("ScriptSource"),
/**
* @see org.jetbrains.kotlin.analysis.test.framework.project.structure.KtCodeFragmentModuleFactory
* @see org.jetbrains.kotlin.analysis.test.framework.project.structure.KtCodeFragmentTestModuleFactory
*/
CodeFragment("CodeFragment"),
@@ -7,8 +7,8 @@ package org.jetbrains.kotlin.analysis.low.level.api.fir.test.configurators
import com.intellij.openapi.Disposable
import org.jetbrains.kotlin.analysis.api.impl.base.test.configurators.AnalysisApiLibraryBaseTestServiceRegistrar
import org.jetbrains.kotlin.analysis.test.framework.project.structure.KtCodeFragmentModuleFactory
import org.jetbrains.kotlin.analysis.test.framework.project.structure.KtModuleFactory
import org.jetbrains.kotlin.analysis.test.framework.project.structure.KtCodeFragmentTestModuleFactory
import org.jetbrains.kotlin.analysis.test.framework.project.structure.KtTestModuleFactory
import org.jetbrains.kotlin.analysis.test.framework.services.DependencyKindModuleStructureTransformer
import org.jetbrains.kotlin.analysis.test.framework.test.configurators.AnalysisApiTestServiceRegistrar
import org.jetbrains.kotlin.test.TestInfrastructureInternals
@@ -21,7 +21,7 @@ class AnalysisApiFirCodeFragmentTestConfigurator(
super.configureTest(builder, disposable)
builder.apply {
useAdditionalService<KtModuleFactory> { KtCodeFragmentModuleFactory }
useAdditionalService<KtTestModuleFactory> { KtCodeFragmentTestModuleFactory }
@OptIn(TestInfrastructureInternals::class)
useModuleStructureTransformers(DependencyKindModuleStructureTransformer)
@@ -12,8 +12,8 @@ import org.jetbrains.kotlin.analysis.api.impl.base.test.configurators.AnalysisAp
import org.jetbrains.kotlin.analysis.api.impl.base.test.configurators.AnalysisApiLibraryBaseTestServiceRegistrar
import org.jetbrains.kotlin.analysis.low.level.api.fir.test.base.AnalysisApiFirTestServiceRegistrar
import org.jetbrains.kotlin.analysis.low.level.api.fir.test.base.configureOptionalTestCompilerPlugin
import org.jetbrains.kotlin.analysis.test.framework.project.structure.KtLibraryBinaryDecompiledModuleFactory
import org.jetbrains.kotlin.analysis.test.framework.project.structure.KtModuleFactory
import org.jetbrains.kotlin.analysis.test.framework.project.structure.KtLibraryBinaryDecompiledTestModuleFactory
import org.jetbrains.kotlin.analysis.test.framework.project.structure.KtTestModuleFactory
import org.jetbrains.kotlin.analysis.test.framework.project.structure.KtTestModuleProjectStructure
import org.jetbrains.kotlin.analysis.test.framework.project.structure.TestModuleStructureFactory
import org.jetbrains.kotlin.analysis.test.framework.services.configuration.AnalysisApiBinaryLibraryIndexingMode
@@ -35,7 +35,7 @@ object AnalysisApiFirLibraryBinaryDecompiledTestConfigurator : AnalysisApiTestCo
override fun configureTest(builder: TestConfigurationBuilder, disposable: Disposable) {
builder.apply {
useAdditionalService<KtModuleFactory> { KtLibraryBinaryDecompiledModuleFactory }
useAdditionalService<KtTestModuleFactory> { KtLibraryBinaryDecompiledTestModuleFactory }
useAdditionalService { AnalysisApiIndexingConfiguration(AnalysisApiBinaryLibraryIndexingMode.INDEX_STUBS) }
configureLibraryCompilationSupport(this)
configureOptionalTestCompilerPlugin()
@@ -12,8 +12,8 @@ import org.jetbrains.kotlin.analysis.api.impl.base.test.configurators.AnalysisAp
import org.jetbrains.kotlin.analysis.api.impl.base.test.configurators.AnalysisApiLibraryBaseTestServiceRegistrar
import org.jetbrains.kotlin.analysis.low.level.api.fir.compiler.based.SealedClassesInheritorsCalculatorPreAnalysisHandler
import org.jetbrains.kotlin.analysis.low.level.api.fir.test.base.AnalysisApiFirTestServiceRegistrar
import org.jetbrains.kotlin.analysis.test.framework.project.structure.KtLibrarySourceModuleFactory
import org.jetbrains.kotlin.analysis.test.framework.project.structure.KtModuleFactory
import org.jetbrains.kotlin.analysis.test.framework.project.structure.KtLibrarySourceTestModuleFactory
import org.jetbrains.kotlin.analysis.test.framework.project.structure.KtTestModuleFactory
import org.jetbrains.kotlin.analysis.test.framework.project.structure.KtTestModuleProjectStructure
import org.jetbrains.kotlin.analysis.test.framework.project.structure.TestModuleStructureFactory
import org.jetbrains.kotlin.analysis.test.framework.services.configuration.AnalysisApiBinaryLibraryIndexingMode
@@ -37,7 +37,7 @@ object AnalysisApiFirLibrarySourceTestConfigurator : AnalysisApiTestConfigurator
disposable: Disposable
) {
builder.apply {
useAdditionalService<KtModuleFactory> { KtLibrarySourceModuleFactory }
useAdditionalService<KtTestModuleFactory> { KtLibrarySourceTestModuleFactory }
useAdditionalService<TestModuleCompiler> { DispatchingTestModuleCompiler() }
useAdditionalService { AnalysisApiIndexingConfiguration(AnalysisApiBinaryLibraryIndexingMode.INDEX_STUBS) }
useDirectives(SealedClassesInheritorsCalculatorPreAnalysisHandler.Directives)
@@ -12,7 +12,7 @@ import com.intellij.psi.search.GlobalSearchScope
import org.jetbrains.kotlin.analysis.low.level.api.fir.project.structure.LLFirBuiltinsSessionFactory
import org.jetbrains.kotlin.analysis.project.structure.KtModule
import org.jetbrains.kotlin.analysis.project.structure.KtNotUnderContentRootModule
import org.jetbrains.kotlin.analysis.test.framework.project.structure.KtModuleFactory
import org.jetbrains.kotlin.analysis.test.framework.project.structure.KtTestModuleFactory
import org.jetbrains.kotlin.analysis.test.framework.project.structure.KtTestModuleProjectStructure
import org.jetbrains.kotlin.analysis.test.framework.project.structure.KtTestModule
import org.jetbrains.kotlin.analysis.test.framework.project.structure.TestModuleStructureFactory
@@ -38,7 +38,7 @@ object AnalysisApiFirOutOfContentRootTestConfigurator : AnalysisApiFirSourceLike
builder.apply {
useDirectives(Directives)
useAdditionalService<KtModuleFactory> { KtOutOfContentRootModuleFactory }
useAdditionalService<KtTestModuleFactory> { KtOutOfContentRootTestModuleFactory }
}
}
@@ -64,7 +64,7 @@ object AnalysisApiFirOutOfContentRootTestConfigurator : AnalysisApiFirSourceLike
private class SkipWhenOutOfContentRootException : SkipTestException()
private object KtOutOfContentRootModuleFactory : KtModuleFactory {
private object KtOutOfContentRootTestModuleFactory : KtTestModuleFactory {
override fun createModule(
testModule: TestModule,
contextModule: KtTestModule?,
@@ -7,8 +7,8 @@ package org.jetbrains.kotlin.analysis.low.level.api.fir.test.configurators
import com.intellij.openapi.Disposable
import org.jetbrains.kotlin.analysis.api.impl.base.test.configurators.AnalysisApiScriptTestServiceRegistrar
import org.jetbrains.kotlin.analysis.test.framework.project.structure.KtModuleFactory
import org.jetbrains.kotlin.analysis.test.framework.project.structure.KtScriptModuleFactory
import org.jetbrains.kotlin.analysis.test.framework.project.structure.KtTestModuleFactory
import org.jetbrains.kotlin.analysis.test.framework.project.structure.KtScriptTestModuleFactory
import org.jetbrains.kotlin.analysis.test.framework.test.configurators.AnalysisApiTestServiceRegistrar
import org.jetbrains.kotlin.test.builders.TestConfigurationBuilder
@@ -18,7 +18,7 @@ class AnalysisApiFirScriptTestConfigurator(analyseInDependentSession: Boolean) :
super.configureTest(builder, disposable)
builder.apply {
useAdditionalService<KtModuleFactory> { KtScriptModuleFactory }
useAdditionalService<KtTestModuleFactory> { KtScriptTestModuleFactory }
}
}
@@ -7,8 +7,8 @@ package org.jetbrains.kotlin.analysis.low.level.api.fir.test.configurators
import com.intellij.openapi.Disposable
import org.jetbrains.kotlin.analysis.api.impl.base.test.configurators.AnalysisApiLibraryBaseTestServiceRegistrar
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.project.structure.KtTestModuleFactory
import org.jetbrains.kotlin.analysis.test.framework.project.structure.KtSourceTestModuleFactory
import org.jetbrains.kotlin.analysis.test.framework.services.DependencyKindModuleStructureTransformer
import org.jetbrains.kotlin.analysis.test.framework.test.configurators.AnalysisApiTestServiceRegistrar
import org.jetbrains.kotlin.test.TestInfrastructureInternals
@@ -21,7 +21,7 @@ open class AnalysisApiFirSourceTestConfigurator(
super.configureTest(builder, disposable)
builder.apply {
useAdditionalService<KtModuleFactory> { KtSourceModuleFactory }
useAdditionalService<KtTestModuleFactory> { KtSourceTestModuleFactory }
@OptIn(TestInfrastructureInternals::class)
useModuleStructureTransformers(DependencyKindModuleStructureTransformer)
@@ -7,7 +7,7 @@ package org.jetbrains.kotlin.analysis.low.level.api.fir.test.configurators
import com.intellij.openapi.Disposable
import com.intellij.openapi.project.Project
import org.jetbrains.kotlin.analysis.test.framework.project.structure.KtModuleFactory
import org.jetbrains.kotlin.analysis.test.framework.project.structure.KtTestModuleFactory
import org.jetbrains.kotlin.analysis.test.framework.project.structure.KtTestModule
import org.jetbrains.kotlin.analysis.test.framework.project.structure.createKtLibrarySourceModule
import org.jetbrains.kotlin.codegen.forTestCompile.ForTestCompileRuntime
@@ -20,12 +20,12 @@ object AnalysisApiFirStdlibSourceTestConfigurator : AnalysisApiFirSourceLikeTest
override fun configureTest(builder: TestConfigurationBuilder, disposable: Disposable) {
super.configureTest(builder, disposable)
builder.apply {
useAdditionalService<KtModuleFactory> { KtStdlibSourceModuleFactory }
useAdditionalService<KtTestModuleFactory> { KtStdlibSourceTestModuleFactory }
}
}
}
private object KtStdlibSourceModuleFactory : KtModuleFactory {
private object KtStdlibSourceTestModuleFactory : KtTestModuleFactory {
override fun createModule(
testModule: TestModule,
contextModule: KtTestModule?,