diff --git a/analysis/analysis-api-standalone/src/org/jetbrains/kotlin/analysis/project/structure/impl/KtStandaloneProjectStructureProvider.kt b/analysis/analysis-api-standalone/src/org/jetbrains/kotlin/analysis/project/structure/impl/KtStandaloneProjectStructureProvider.kt index 5d9b6519966..0e744e91d83 100644 --- a/analysis/analysis-api-standalone/src/org/jetbrains/kotlin/analysis/project/structure/impl/KtStandaloneProjectStructureProvider.kt +++ b/analysis/analysis-api-standalone/src/org/jetbrains/kotlin/analysis/project/structure/impl/KtStandaloneProjectStructureProvider.kt @@ -7,16 +7,13 @@ package org.jetbrains.kotlin.analysis.project.structure.impl import com.intellij.openapi.project.Project import com.intellij.psi.PsiElement -import com.intellij.psi.PsiFile import com.intellij.psi.PsiFileSystemItem import com.intellij.psi.PsiJavaFile -import com.intellij.util.containers.ContainerUtil import org.jetbrains.kotlin.analysis.api.standalone.base.project.structure.KtStaticProjectStructureProvider import org.jetbrains.kotlin.analysis.api.standalone.base.project.structure.StandaloneProjectFactory.findJvmRootsForJavaFiles import org.jetbrains.kotlin.analysis.low.level.api.fir.project.structure.LLFirBuiltinsSessionFactory import org.jetbrains.kotlin.analysis.project.structure.* import org.jetbrains.kotlin.platform.TargetPlatform -import org.jetbrains.kotlin.psi.KtFile import org.jetbrains.kotlin.serialization.deserialization.builtins.BuiltInSerializerProtocol import org.jetbrains.kotlin.utils.KotlinExceptionWithAttachments @@ -33,25 +30,12 @@ internal class KtStandaloneProjectStructureProvider( ) } - private val notUnderContentRootModuleCache = ContainerUtil.createConcurrentWeakMap() - private val builtinsModule: KtBuiltinsModule by lazy { LLFirBuiltinsSessionFactory.getInstance(project).getBuiltinsSession(platform).ktModule as KtBuiltinsModule } - override fun getNotUnderContentRootModule(project: Project, file: PsiFile?): KtNotUnderContentRootModule { - if (file == null) { - return ktNotUnderContentRootModuleWithoutPsiFile - } - - return notUnderContentRootModuleCache.getOrPut(file) { - KtNotUnderContentRootModuleImpl( - name = file.name, - moduleDescription = "Standalone-not-under-content-root-module-for-$file", - file = file, - project = project, - ) - } + override fun getNotUnderContentRootModule(project: Project): KtNotUnderContentRootModule { + return ktNotUnderContentRootModuleWithoutPsiFile } @OptIn(KtModuleStructureInternals::class) diff --git a/analysis/analysis-test-framework/tests/org/jetbrains/kotlin/analysis/test/framework/services/KtTestProjectStructureProvider.kt b/analysis/analysis-test-framework/tests/org/jetbrains/kotlin/analysis/test/framework/services/KtTestProjectStructureProvider.kt index 780e6d3208c..6bb9d70a3c8 100644 --- a/analysis/analysis-test-framework/tests/org/jetbrains/kotlin/analysis/test/framework/services/KtTestProjectStructureProvider.kt +++ b/analysis/analysis-test-framework/tests/org/jetbrains/kotlin/analysis/test/framework/services/KtTestProjectStructureProvider.kt @@ -7,7 +7,6 @@ package org.jetbrains.kotlin.analysis.test.framework.services import com.intellij.openapi.project.Project import com.intellij.psi.PsiElement -import com.intellij.psi.PsiFile import com.intellij.psi.PsiFileSystemItem import org.jetbrains.kotlin.analysis.api.standalone.base.project.structure.KtModuleProjectStructure import org.jetbrains.kotlin.analysis.api.standalone.base.project.structure.KtStaticProjectStructureProvider @@ -22,7 +21,7 @@ class KtTestProjectStructureProvider( private val builtinsModule: KtBuiltinsModule, private val projectStructure: KtModuleProjectStructure, ) : KtStaticProjectStructureProvider() { - override fun getNotUnderContentRootModule(project: Project, file: PsiFile?): KtNotUnderContentRootModule { + override fun getNotUnderContentRootModule(project: Project): KtNotUnderContentRootModule { error("Not-under content root modules most be initialized explicitly in tests") } diff --git a/analysis/project-structure/src/org/jetbrains/kotlin/analysis/project/structure/ProjectStructureProvider.kt b/analysis/project-structure/src/org/jetbrains/kotlin/analysis/project/structure/ProjectStructureProvider.kt index e1e2a839ee9..24b975c556b 100644 --- a/analysis/project-structure/src/org/jetbrains/kotlin/analysis/project/structure/ProjectStructureProvider.kt +++ b/analysis/project-structure/src/org/jetbrains/kotlin/analysis/project/structure/ProjectStructureProvider.kt @@ -42,7 +42,7 @@ public abstract class ProjectStructureProvider { */ public abstract fun getModule(element: PsiElement, contextualModule: KtModule?): KtModule - protected abstract fun getNotUnderContentRootModule(project: Project, file: PsiFile?): KtNotUnderContentRootModule + protected abstract fun getNotUnderContentRootModule(project: Project): KtNotUnderContentRootModule @OptIn(KtModuleStructureInternals::class) protected fun computeSpecialModule(file: PsiFile): KtModule? { @@ -81,7 +81,7 @@ public abstract class ProjectStructureProvider { return getModule(contextElement, contextualModule = null) } - return getNotUnderContentRootModule(file.project, file = null) + return getNotUnderContentRootModule(file.project) } /**