[LL API] Make 'KtNotUnderContentRootModuleForTest' depend on built-ins
This commit is contained in:
+2
@@ -24,6 +24,7 @@ internal class KtModuleProviderImpl(
|
||||
) : ProjectStructureProvider() {
|
||||
private val ktNotUnderContentRootModuleWithoutPsiFile by lazy {
|
||||
KtNotUnderContentRootModuleImpl(
|
||||
name = "unnamed-outside-content-root",
|
||||
moduleDescription = "Standalone-not-under-content-root-module-without-psi-file",
|
||||
project = project,
|
||||
)
|
||||
@@ -44,6 +45,7 @@ internal class KtModuleProviderImpl(
|
||||
val containingFileAsVirtualFile = containingFileAsPsiFile.virtualFile
|
||||
?: return notUnderContentRootModuleCache.getOrPut(containingFileAsPsiFile) {
|
||||
KtNotUnderContentRootModuleImpl(
|
||||
name = containingFileAsPsiFile.name,
|
||||
moduleDescription = "Standalone-not-under-content-root-module-for-$containingFileAsPsiFile",
|
||||
file = containingFileAsPsiFile,
|
||||
project = project,
|
||||
|
||||
+1
@@ -15,6 +15,7 @@ import org.jetbrains.kotlin.platform.jvm.JvmPlatforms
|
||||
import org.jetbrains.kotlin.resolve.PlatformDependentAnalyzerServices
|
||||
|
||||
internal class KtNotUnderContentRootModuleImpl(
|
||||
override val name: String,
|
||||
override val directRegularDependencies: List<KtModule> = emptyList(),
|
||||
override val directRefinementDependencies: List<KtModule> = emptyList(),
|
||||
override val directFriendDependencies: List<KtModule> = emptyList(),
|
||||
|
||||
+1
-1
@@ -57,7 +57,7 @@ fun List<KtModuleWithFiles>.associateByName(): Map<String, KtModuleWithFiles> {
|
||||
is KtLibrarySourceModule -> ktModule.libraryName
|
||||
is KtSdkModule -> ktModule.sdkName
|
||||
is KtBuiltinsModule -> "Builtins for ${ktModule.platform}"
|
||||
is KtNotUnderContentRootModuleForTest -> ktModule.moduleName
|
||||
is KtNotUnderContentRootModule -> ktModule.name
|
||||
else -> error("Unsupported module type: " + ktModule.javaClass.name)
|
||||
}
|
||||
}
|
||||
|
||||
-53
@@ -1,53 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2022 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.PsiFile
|
||||
import com.intellij.psi.search.GlobalSearchScope
|
||||
import org.jetbrains.kotlin.analysis.api.standalone.base.project.structure.KtModuleWithFiles
|
||||
import org.jetbrains.kotlin.analysis.project.structure.KtModule
|
||||
import org.jetbrains.kotlin.analysis.project.structure.KtNotUnderContentRootModule
|
||||
import org.jetbrains.kotlin.platform.TargetPlatform
|
||||
import org.jetbrains.kotlin.resolve.PlatformDependentAnalyzerServices
|
||||
import org.jetbrains.kotlin.test.getAnalyzerServices
|
||||
import org.jetbrains.kotlin.test.model.TestModule
|
||||
import org.jetbrains.kotlin.test.services.TestServices
|
||||
|
||||
class KtOutOfContentRootModuleFactory : KtModuleFactory {
|
||||
override fun createModule(testModule: TestModule, testServices: TestServices, project: Project): KtModuleWithFiles {
|
||||
val psiFiles = TestModuleStructureFactory.createSourcePsiFiles(testModule, testServices, project)
|
||||
val module = KtNotUnderContentRootModuleForTest(testModule.name, psiFiles.single(), testModule.targetPlatform)
|
||||
return KtModuleWithFiles(module, psiFiles)
|
||||
}
|
||||
}
|
||||
|
||||
internal class KtNotUnderContentRootModuleForTest(
|
||||
val moduleName: String,
|
||||
override val file: PsiFile,
|
||||
override val platform: TargetPlatform
|
||||
) : KtNotUnderContentRootModule {
|
||||
override val directRegularDependencies: List<KtModule>
|
||||
get() = emptyList()
|
||||
|
||||
override val directRefinementDependencies: List<KtModule>
|
||||
get() = emptyList()
|
||||
|
||||
override val directFriendDependencies: List<KtModule>
|
||||
get() = emptyList()
|
||||
|
||||
override val contentScope: GlobalSearchScope
|
||||
get() = GlobalSearchScope.fileScope(file)
|
||||
|
||||
override val analyzerServices: PlatformDependentAnalyzerServices
|
||||
get() = platform.getAnalyzerServices()
|
||||
|
||||
override val project: Project
|
||||
get() = file.project
|
||||
|
||||
override val moduleDescription: String
|
||||
get() = "Not under content root for ${file.virtualFile.path}"
|
||||
}
|
||||
+50
-2
@@ -6,13 +6,23 @@
|
||||
package org.jetbrains.kotlin.analysis.low.level.api.fir.test.configurators
|
||||
|
||||
import com.intellij.openapi.Disposable
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.psi.PsiFile
|
||||
import com.intellij.psi.search.GlobalSearchScope
|
||||
import org.jetbrains.kotlin.analysis.api.standalone.base.project.structure.KtModuleWithFiles
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.project.structure.LLFirBuiltinsSessionFactory
|
||||
import org.jetbrains.kotlin.analysis.project.structure.KtBuiltinsModule
|
||||
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.KtOutOfContentRootModuleFactory
|
||||
import org.jetbrains.kotlin.analysis.test.framework.project.structure.TestModuleStructureFactory
|
||||
import org.jetbrains.kotlin.analysis.test.framework.utils.SkipTestException
|
||||
import org.jetbrains.kotlin.platform.TargetPlatform
|
||||
import org.jetbrains.kotlin.resolve.PlatformDependentAnalyzerServices
|
||||
import org.jetbrains.kotlin.test.builders.TestConfigurationBuilder
|
||||
import org.jetbrains.kotlin.test.directives.model.DirectiveApplicability
|
||||
import org.jetbrains.kotlin.test.directives.model.SimpleDirectivesContainer
|
||||
import org.jetbrains.kotlin.test.getAnalyzerServices
|
||||
import org.jetbrains.kotlin.test.model.TestModule
|
||||
import org.jetbrains.kotlin.test.services.TestServices
|
||||
|
||||
@@ -45,4 +55,42 @@ object AnalysisApiFirOutOfContentRootTestConfigurator : AnalysisApiFirSourceLike
|
||||
}
|
||||
}
|
||||
|
||||
private class SkipWhenOutOfContentRootException : SkipTestException()
|
||||
private class SkipWhenOutOfContentRootException : SkipTestException()
|
||||
|
||||
private class KtOutOfContentRootModuleFactory : KtModuleFactory {
|
||||
override fun createModule(testModule: TestModule, testServices: TestServices, project: Project): KtModuleWithFiles {
|
||||
val psiFiles = TestModuleStructureFactory.createSourcePsiFiles(testModule, testServices, project)
|
||||
val platform = testModule.targetPlatform
|
||||
val module = KtNotUnderContentRootModuleForTest(testModule.name, psiFiles.single(), platform)
|
||||
return KtModuleWithFiles(module, psiFiles)
|
||||
}
|
||||
}
|
||||
|
||||
private class KtNotUnderContentRootModuleForTest(
|
||||
override val name: String,
|
||||
override val file: PsiFile,
|
||||
override val platform: TargetPlatform
|
||||
) : KtNotUnderContentRootModule {
|
||||
override val directRegularDependencies: List<KtModule> by lazy {
|
||||
val builtinsModule = LLFirBuiltinsSessionFactory.getInstance(project).getBuiltinsSession(platform).ktModule as KtBuiltinsModule
|
||||
listOf(builtinsModule)
|
||||
}
|
||||
|
||||
override val directRefinementDependencies: List<KtModule>
|
||||
get() = emptyList()
|
||||
|
||||
override val directFriendDependencies: List<KtModule>
|
||||
get() = emptyList()
|
||||
|
||||
override val contentScope: GlobalSearchScope
|
||||
get() = GlobalSearchScope.fileScope(file)
|
||||
|
||||
override val analyzerServices: PlatformDependentAnalyzerServices
|
||||
get() = platform.getAnalyzerServices()
|
||||
|
||||
override val project: Project
|
||||
get() = file.project
|
||||
|
||||
override val moduleDescription: String
|
||||
get() = "Not under content root \"${name}\" for ${file.virtualFile.path}"
|
||||
}
|
||||
+5
@@ -172,6 +172,11 @@ public class KtBuiltinsModule(
|
||||
* A set of sources which lives outside project content root. E.g, testdata files or source files of some other project.
|
||||
*/
|
||||
public interface KtNotUnderContentRootModule : KtModule {
|
||||
/**
|
||||
* Human-readable module name.
|
||||
*/
|
||||
public val name: String
|
||||
|
||||
/**
|
||||
* Module owner file.
|
||||
* A separate module is created for each file outside a content root.
|
||||
|
||||
Reference in New Issue
Block a user