[Analysis API] Minor, tune the 'createModule()' signature
Move the 'dependencyPaths' parameter closer to other traits of a created module.
This commit is contained in:
+1
-1
@@ -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" }
|
||||
|
||||
|
||||
+1
-1
@@ -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)
|
||||
|
||||
+1
-1
@@ -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())
|
||||
|
||||
|
||||
+3
-1
@@ -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
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -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(
|
||||
|
||||
+1
-1
@@ -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)
|
||||
|
||||
|
||||
+2
-2
@@ -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)
|
||||
|
||||
+1
-1
@@ -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
|
||||
|
||||
+1
-1
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user