From e5cd674f33eeebdded6532793966703c27580111 Mon Sep 17 00:00:00 2001 From: Dmitrii Gridin Date: Wed, 26 Jul 2023 15:52:17 +0200 Subject: [PATCH] [AA] split KtSourceModuleImpl on separate files ^KT-60728 --- .../project/structure/KtJdkModuleImpl.kt | 31 +++++++++ .../project/structure/KtLibraryModuleImpl.kt | 30 +++++++++ .../structure/KtLibrarySourceModuleImpl.kt | 27 ++++++++ .../KtModuleWithModifiableDependencies.kt | 21 +++++++ .../project/structure/KtSourceModuleImpl.kt | 63 +------------------ 5 files changed, 110 insertions(+), 62 deletions(-) create mode 100644 analysis/analysis-test-framework/tests/org/jetbrains/kotlin/analysis/test/framework/project/structure/KtJdkModuleImpl.kt create mode 100644 analysis/analysis-test-framework/tests/org/jetbrains/kotlin/analysis/test/framework/project/structure/KtLibraryModuleImpl.kt create mode 100644 analysis/analysis-test-framework/tests/org/jetbrains/kotlin/analysis/test/framework/project/structure/KtLibrarySourceModuleImpl.kt create mode 100644 analysis/analysis-test-framework/tests/org/jetbrains/kotlin/analysis/test/framework/project/structure/KtModuleWithModifiableDependencies.kt diff --git a/analysis/analysis-test-framework/tests/org/jetbrains/kotlin/analysis/test/framework/project/structure/KtJdkModuleImpl.kt b/analysis/analysis-test-framework/tests/org/jetbrains/kotlin/analysis/test/framework/project/structure/KtJdkModuleImpl.kt new file mode 100644 index 00000000000..e725321f8cf --- /dev/null +++ b/analysis/analysis-test-framework/tests/org/jetbrains/kotlin/analysis/test/framework/project/structure/KtJdkModuleImpl.kt @@ -0,0 +1,31 @@ +/* + * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.analysis.test.framework.project.structure + +import com.intellij.openapi.project.Project +import com.intellij.psi.search.GlobalSearchScope +import org.jetbrains.kotlin.analysis.project.structure.* +import org.jetbrains.kotlin.platform.TargetPlatform +import org.jetbrains.kotlin.resolve.PlatformDependentAnalyzerServices +import org.jetbrains.kotlin.test.getAnalyzerServices +import java.nio.file.Path + +class KtJdkModuleImpl( + override val sdkName: String, + override val platform: TargetPlatform, + override val contentScope: GlobalSearchScope, + override val project: Project, + private val binaryRoots: Collection, +) : KtModuleWithModifiableDependencies(), KtSdkModule { + override val analyzerServices: PlatformDependentAnalyzerServices + get() = platform.getAnalyzerServices() + + override fun getBinaryRoots(): Collection = binaryRoots + + override val directRegularDependencies: MutableList = mutableListOf() + override val directDependsOnDependencies: MutableList = mutableListOf() + override val directFriendDependencies: MutableList = mutableListOf() +} \ No newline at end of file diff --git a/analysis/analysis-test-framework/tests/org/jetbrains/kotlin/analysis/test/framework/project/structure/KtLibraryModuleImpl.kt b/analysis/analysis-test-framework/tests/org/jetbrains/kotlin/analysis/test/framework/project/structure/KtLibraryModuleImpl.kt new file mode 100644 index 00000000000..323028e5a70 --- /dev/null +++ b/analysis/analysis-test-framework/tests/org/jetbrains/kotlin/analysis/test/framework/project/structure/KtLibraryModuleImpl.kt @@ -0,0 +1,30 @@ +/* + * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.analysis.test.framework.project.structure + +import com.intellij.openapi.project.Project +import com.intellij.psi.search.GlobalSearchScope +import org.jetbrains.kotlin.analysis.project.structure.* +import org.jetbrains.kotlin.platform.TargetPlatform +import org.jetbrains.kotlin.resolve.PlatformDependentAnalyzerServices +import org.jetbrains.kotlin.test.getAnalyzerServices +import java.nio.file.Path + +class KtLibraryModuleImpl( + override val libraryName: String, + override val platform: TargetPlatform, + override val contentScope: GlobalSearchScope, + override val project: Project, + private val binaryRoots: Collection, + override var librarySources: KtLibrarySourceModule?, +) : KtModuleWithModifiableDependencies(), KtLibraryModule { + override val analyzerServices: PlatformDependentAnalyzerServices get() = platform.getAnalyzerServices() + override fun getBinaryRoots(): Collection = binaryRoots + + override val directRegularDependencies: MutableList = mutableListOf() + override val directDependsOnDependencies: MutableList = mutableListOf() + override val directFriendDependencies: MutableList = mutableListOf() +} \ No newline at end of file diff --git a/analysis/analysis-test-framework/tests/org/jetbrains/kotlin/analysis/test/framework/project/structure/KtLibrarySourceModuleImpl.kt b/analysis/analysis-test-framework/tests/org/jetbrains/kotlin/analysis/test/framework/project/structure/KtLibrarySourceModuleImpl.kt new file mode 100644 index 00000000000..80a6a6fcdde --- /dev/null +++ b/analysis/analysis-test-framework/tests/org/jetbrains/kotlin/analysis/test/framework/project/structure/KtLibrarySourceModuleImpl.kt @@ -0,0 +1,27 @@ +/* + * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.analysis.test.framework.project.structure + +import com.intellij.openapi.project.Project +import com.intellij.psi.search.GlobalSearchScope +import org.jetbrains.kotlin.analysis.project.structure.* +import org.jetbrains.kotlin.platform.TargetPlatform +import org.jetbrains.kotlin.resolve.PlatformDependentAnalyzerServices +import org.jetbrains.kotlin.test.getAnalyzerServices + +class KtLibrarySourceModuleImpl( + override val libraryName: String, + override val platform: TargetPlatform, + override val contentScope: GlobalSearchScope, + override val project: Project, + override val binaryLibrary: KtLibraryModule, +) : KtModuleWithModifiableDependencies(), KtLibrarySourceModule { + override val analyzerServices: PlatformDependentAnalyzerServices get() = platform.getAnalyzerServices() + + override val directRegularDependencies: MutableList = mutableListOf() + override val directDependsOnDependencies: MutableList = mutableListOf() + override val directFriendDependencies: MutableList = mutableListOf() +} diff --git a/analysis/analysis-test-framework/tests/org/jetbrains/kotlin/analysis/test/framework/project/structure/KtModuleWithModifiableDependencies.kt b/analysis/analysis-test-framework/tests/org/jetbrains/kotlin/analysis/test/framework/project/structure/KtModuleWithModifiableDependencies.kt new file mode 100644 index 00000000000..d231e3632e4 --- /dev/null +++ b/analysis/analysis-test-framework/tests/org/jetbrains/kotlin/analysis/test/framework/project/structure/KtModuleWithModifiableDependencies.kt @@ -0,0 +1,21 @@ +/* + * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.analysis.test.framework.project.structure + +import org.jetbrains.kotlin.analysis.project.structure.* + +abstract class KtModuleWithModifiableDependencies { + abstract val directRegularDependencies: MutableList + abstract val directDependsOnDependencies: MutableList + abstract val directFriendDependencies: MutableList + + /** + * When dependencies are modifiable, transitive `dependsOn` dependencies must be recomputed each time as [directDependsOnDependencies] + * may have been mutated. + */ + val transitiveDependsOnDependencies: List + get() = computeTransitiveDependsOnDependencies(directDependsOnDependencies) +} diff --git a/analysis/analysis-test-framework/tests/org/jetbrains/kotlin/analysis/test/framework/project/structure/KtSourceModuleImpl.kt b/analysis/analysis-test-framework/tests/org/jetbrains/kotlin/analysis/test/framework/project/structure/KtSourceModuleImpl.kt index 3db19ca15a5..a487a192a41 100644 --- a/analysis/analysis-test-framework/tests/org/jetbrains/kotlin/analysis/test/framework/project/structure/KtSourceModuleImpl.kt +++ b/analysis/analysis-test-framework/tests/org/jetbrains/kotlin/analysis/test/framework/project/structure/KtSourceModuleImpl.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ @@ -12,20 +12,6 @@ import org.jetbrains.kotlin.config.LanguageVersionSettings import org.jetbrains.kotlin.platform.TargetPlatform import org.jetbrains.kotlin.resolve.PlatformDependentAnalyzerServices import org.jetbrains.kotlin.test.getAnalyzerServices -import java.nio.file.Path - -abstract class KtModuleWithModifiableDependencies { - abstract val directRegularDependencies: MutableList - abstract val directDependsOnDependencies: MutableList - abstract val directFriendDependencies: MutableList - - /** - * When dependencies are modifiable, transitive `dependsOn` dependencies must be recomputed each time as [directDependsOnDependencies] - * may have been mutated. - */ - val transitiveDependsOnDependencies: List - get() = computeTransitiveDependsOnDependencies(directDependsOnDependencies) -} class KtSourceModuleImpl( override val moduleName: String, @@ -40,50 +26,3 @@ class KtSourceModuleImpl( override val directDependsOnDependencies: MutableList = mutableListOf() override val directFriendDependencies: MutableList = mutableListOf() } - -class KtJdkModuleImpl( - override val sdkName: String, - override val platform: TargetPlatform, - override val contentScope: GlobalSearchScope, - override val project: Project, - private val binaryRoots: Collection, -) : KtModuleWithModifiableDependencies(), KtSdkModule { - override val analyzerServices: PlatformDependentAnalyzerServices - get() = platform.getAnalyzerServices() - - override fun getBinaryRoots(): Collection = binaryRoots - - override val directRegularDependencies: MutableList = mutableListOf() - override val directDependsOnDependencies: MutableList = mutableListOf() - override val directFriendDependencies: MutableList = mutableListOf() -} - -class KtLibraryModuleImpl( - override val libraryName: String, - override val platform: TargetPlatform, - override val contentScope: GlobalSearchScope, - override val project: Project, - private val binaryRoots: Collection, - override var librarySources: KtLibrarySourceModule?, -) : KtModuleWithModifiableDependencies(), KtLibraryModule { - override val analyzerServices: PlatformDependentAnalyzerServices get() = platform.getAnalyzerServices() - override fun getBinaryRoots(): Collection = binaryRoots - - override val directRegularDependencies: MutableList = mutableListOf() - override val directDependsOnDependencies: MutableList = mutableListOf() - override val directFriendDependencies: MutableList = mutableListOf() -} - -class KtLibrarySourceModuleImpl( - override val libraryName: String, - override val platform: TargetPlatform, - override val contentScope: GlobalSearchScope, - override val project: Project, - override val binaryLibrary: KtLibraryModule, -) : KtModuleWithModifiableDependencies(), KtLibrarySourceModule { - override val analyzerServices: PlatformDependentAnalyzerServices get() = platform.getAnalyzerServices() - - override val directRegularDependencies: MutableList = mutableListOf() - override val directDependsOnDependencies: MutableList = mutableListOf() - override val directFriendDependencies: MutableList = mutableListOf() -} \ No newline at end of file