[LL FIR] KT-55329 Support transitive dependsOn dependencies in LL FIR

- In contrast to other kinds of dependencies, `dependsOn` dependencies
  must be followed transitively.
- Add `transitiveDependsOnDependencies` to `KtModule`. These
  dependencies are calculated lazily with a topological sort. They are
  added to the dependency provider when it's built in
  `LLFirSessionFactory`.

^KT-55329 fixed
This commit is contained in:
Marco Pennekamp
2022-12-20 18:41:23 +01:00
committed by teamcity
parent 1803bd36cc
commit d6cb75ca91
15 changed files with 126 additions and 36 deletions
@@ -10,6 +10,7 @@ import com.intellij.psi.search.GlobalSearchScope
import org.jetbrains.kotlin.analysis.project.structure.KtLibraryModule
import org.jetbrains.kotlin.analysis.project.structure.KtLibrarySourceModule
import org.jetbrains.kotlin.analysis.project.structure.KtModule
import org.jetbrains.kotlin.analysis.project.structure.computeTransitiveDependsOnDependencies
import org.jetbrains.kotlin.platform.TargetPlatform
import org.jetbrains.kotlin.resolve.PlatformDependentAnalyzerServices
import java.nio.file.Path
@@ -25,6 +26,7 @@ internal class KtLibraryModuleImpl(
override val libraryName: String,
override val librarySources: KtLibrarySourceModule?,
) : KtLibraryModule, KtModuleWithPlatform {
override val transitiveDependsOnDependencies: List<KtModule> by lazy { computeTransitiveDependsOnDependencies(directDependsOnDependencies) }
override val analyzerServices: PlatformDependentAnalyzerServices = super.analyzerServices
override fun getBinaryRoots(): Collection<Path> = binaryRoots
@@ -10,6 +10,7 @@ import com.intellij.psi.search.GlobalSearchScope
import org.jetbrains.kotlin.analysis.project.structure.KtLibraryModule
import org.jetbrains.kotlin.analysis.project.structure.KtLibrarySourceModule
import org.jetbrains.kotlin.analysis.project.structure.KtModule
import org.jetbrains.kotlin.analysis.project.structure.computeTransitiveDependsOnDependencies
import org.jetbrains.kotlin.platform.TargetPlatform
import org.jetbrains.kotlin.resolve.PlatformDependentAnalyzerServices
@@ -23,5 +24,6 @@ internal class KtLibrarySourceModuleImpl(
override val libraryName: String,
override val binaryLibrary: KtLibraryModule,
) : KtLibrarySourceModule, KtModuleWithPlatform {
override val transitiveDependsOnDependencies: List<KtModule> by lazy { computeTransitiveDependsOnDependencies(directDependsOnDependencies) }
override val analyzerServices: PlatformDependentAnalyzerServices = super.analyzerServices
}
@@ -10,6 +10,7 @@ import com.intellij.psi.PsiFile
import com.intellij.psi.search.GlobalSearchScope
import org.jetbrains.kotlin.analysis.project.structure.KtModule
import org.jetbrains.kotlin.analysis.project.structure.KtNotUnderContentRootModule
import org.jetbrains.kotlin.analysis.project.structure.computeTransitiveDependsOnDependencies
import org.jetbrains.kotlin.platform.TargetPlatform
import org.jetbrains.kotlin.platform.jvm.JvmPlatforms
import org.jetbrains.kotlin.resolve.PlatformDependentAnalyzerServices
@@ -24,6 +25,7 @@ internal class KtNotUnderContentRootModuleImpl(
override val moduleDescription: String,
override val project: Project,
) : KtNotUnderContentRootModule, KtModuleWithPlatform {
override val transitiveDependsOnDependencies: List<KtModule> by lazy { computeTransitiveDependsOnDependencies(directDependsOnDependencies) }
override val analyzerServices: PlatformDependentAnalyzerServices = super.analyzerServices
override val contentScope: GlobalSearchScope =
@@ -9,6 +9,7 @@ import com.intellij.openapi.project.Project
import com.intellij.psi.search.GlobalSearchScope
import org.jetbrains.kotlin.analysis.project.structure.KtModule
import org.jetbrains.kotlin.analysis.project.structure.KtSdkModule
import org.jetbrains.kotlin.analysis.project.structure.computeTransitiveDependsOnDependencies
import org.jetbrains.kotlin.platform.TargetPlatform
import org.jetbrains.kotlin.resolve.PlatformDependentAnalyzerServices
import java.nio.file.Path
@@ -23,6 +24,7 @@ internal class KtSdkModuleImpl(
private val binaryRoots: Collection<Path>,
override val sdkName: String,
) : KtSdkModule, KtModuleWithPlatform {
override val transitiveDependsOnDependencies: List<KtModule> by lazy { computeTransitiveDependsOnDependencies(directDependsOnDependencies) }
override val analyzerServices: PlatformDependentAnalyzerServices = super.analyzerServices
override fun getBinaryRoots(): Collection<Path> = binaryRoots
@@ -10,6 +10,7 @@ import com.intellij.psi.PsiFileSystemItem
import com.intellij.psi.search.GlobalSearchScope
import org.jetbrains.kotlin.analysis.project.structure.KtModule
import org.jetbrains.kotlin.analysis.project.structure.KtSourceModule
import org.jetbrains.kotlin.analysis.project.structure.computeTransitiveDependsOnDependencies
import org.jetbrains.kotlin.config.LanguageVersionSettings
import org.jetbrains.kotlin.platform.TargetPlatform
import org.jetbrains.kotlin.resolve.PlatformDependentAnalyzerServices
@@ -25,5 +26,6 @@ internal class KtSourceModuleImpl(
override val languageVersionSettings: LanguageVersionSettings,
internal val sourceRoots: List<PsiFileSystemItem>,
) : KtSourceModule, KtModuleWithPlatform {
override val transitiveDependsOnDependencies: List<KtModule> by lazy { computeTransitiveDependsOnDependencies(directDependsOnDependencies) }
override val analyzerServices: PlatformDependentAnalyzerServices = super.analyzerServices
}