[Analysis API] Minor, tune the 'createModule()' signature

Move the 'dependencyPaths' parameter closer to other traits of
a created module.
This commit is contained in:
Yan Zhulanow
2024-01-30 04:58:39 +09:00
committed by Space Team
parent 6a94a3331f
commit b925462852
9 changed files with 12 additions and 10 deletions
@@ -29,9 +29,9 @@ object KtCodeFragmentModuleFactory : KtModuleFactory {
override fun createModule(
testModule: TestModule,
contextModule: KtModuleWithFiles?,
dependencyPaths: Collection<Path>,
testServices: TestServices,
project: Project,
dependencyPaths: Collection<Path>
): KtModuleWithFiles {
requireNotNull(contextModule) { "Code fragment requires a context module" }
@@ -22,9 +22,9 @@ object KtLibraryBinaryModuleFactory : KtModuleFactory {
override fun createModule(
testModule: TestModule,
contextModule: KtModuleWithFiles?,
dependencyPaths: Collection<Path>,
testServices: TestServices,
project: Project,
dependencyPaths: Collection<Path>,
): KtModuleWithFiles {
val library = testServices.compiledLibraryProvider.compileToLibrary(testModule, dependencyPaths).artifact
val decompiledFiles = testServices.testModuleDecompiler.getAllPsiFilesFromLibrary(library, project)
@@ -25,9 +25,9 @@ object KtLibrarySourceModuleFactory : KtModuleFactory {
override fun createModule(
testModule: TestModule,
contextModule: KtModuleWithFiles?,
dependencyPaths: Collection<Path>,
testServices: TestServices,
project: Project,
dependencyPaths: Collection<Path>,
): KtModuleWithFiles {
Assume.assumeFalse("Compilation of multi-platform libraries is not supported", testModule.targetPlatform.isMultiPlatform())
@@ -21,13 +21,15 @@ fun interface KtModuleFactory : TestService {
* @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 [KtModuleWithFiles] is passed,
* instead of a plain (KtModule)[org.jetbrains.kotlin.analysis.project.structure.KtModule].
*
* @param dependencyPaths Paths of directories containing dependency libraries. The paths will be set as class paths for compilation.
*/
fun createModule(
testModule: TestModule,
contextModule: KtModuleWithFiles?,
dependencyPaths: Collection<Path>,
testServices: TestServices,
project: Project,
dependencyPaths: Collection<Path>,
): KtModuleWithFiles
}
@@ -19,9 +19,9 @@ object KtScriptModuleFactory : KtModuleFactory {
override fun createModule(
testModule: TestModule,
contextModule: KtModuleWithFiles?,
dependencyPaths: Collection<Path>,
testServices: TestServices,
project: Project,
dependencyPaths: Collection<Path>,
): KtModuleWithFiles {
val ktFile = TestModuleStructureFactory.createSourcePsiFiles(testModule, testServices, project).single() as KtFile
val module = KtScriptModuleImpl(
@@ -19,9 +19,9 @@ object KtSourceModuleFactory : KtModuleFactory {
override fun createModule(
testModule: TestModule,
contextModule: KtModuleWithFiles?,
dependencyPaths: Collection<Path>,
testServices: TestServices,
project: Project,
dependencyPaths: Collection<Path>,
): KtModuleWithFiles {
val psiFiles = TestModuleStructureFactory.createSourcePsiFiles(testModule, testServices, project)
@@ -112,10 +112,10 @@ object TestModuleStructureFactory {
val contextModuleName = testModule.directives.singleOrZeroValue(AnalysisApiTestDirectives.CONTEXT_MODULE)
val contextModule = contextModuleName?.let(existingModules::getValue)
val dependencies = testModule.regularDependencies.mapNotNull { moduleNamesToPaths[it.moduleName] }.flatten()
val dependencyPaths = testModule.regularDependencies.mapNotNull { moduleNamesToPaths[it.moduleName] }.flatten()
val moduleWithFiles = testServices
.getKtModuleFactoryForTestModule(testModule)
.createModule(testModule, contextModule, testServices, project, dependencies)
.createModule(testModule, contextModule, dependencyPaths, testServices, project)
existingModules[testModule.name] = moduleWithFiles
result.add(moduleWithFiles)
@@ -67,9 +67,9 @@ private object KtOutOfContentRootModuleFactory : KtModuleFactory {
override fun createModule(
testModule: TestModule,
contextModule: KtModuleWithFiles?,
dependencyPaths: Collection<Path>,
testServices: TestServices,
project: Project,
dependencyPaths: Collection<Path>,
): KtModuleWithFiles {
val psiFiles = TestModuleStructureFactory.createSourcePsiFiles(testModule, testServices, project)
val platform = testModule.targetPlatform
@@ -29,9 +29,9 @@ private object KtStdlibSourceModuleFactory : KtModuleFactory {
override fun createModule(
testModule: TestModule,
contextModule: KtModuleWithFiles?,
dependencyPaths: Collection<Path>,
testServices: TestServices,
project: Project,
dependencyPaths: Collection<Path>,
): KtModuleWithFiles {
val libraryJar = ForTestCompileRuntime.runtimeJarForTests().toPath()
val librarySourcesJar = ForTestCompileRuntime.runtimeSourcesJarForTests().toPath()