diff --git a/.idea/modules.xml b/.idea/modules.xml index 37912c277b7e..db7e2d68d54d 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -1244,6 +1244,7 @@ + diff --git a/platform/build-scripts/src/org/jetbrains/intellij/build/kotlin/KotlinPluginBuilder.kt b/platform/build-scripts/src/org/jetbrains/intellij/build/kotlin/KotlinPluginBuilder.kt index 7fba5106c0f8..f959ced9aa9f 100644 --- a/platform/build-scripts/src/org/jetbrains/intellij/build/kotlin/KotlinPluginBuilder.kt +++ b/platform/build-scripts/src/org/jetbrains/intellij/build/kotlin/KotlinPluginBuilder.kt @@ -40,6 +40,7 @@ object KotlinPluginBuilder { "kotlin.base.project-structure", "kotlin.base.external-build-system", "kotlin.base.scripting", + "kotlin.base.scripting.k1", "kotlin.base.scripting.k2", "kotlin.base.analysis-api-platform", "kotlin.base.analysis", diff --git a/plugins/kotlin/BUILD.bazel b/plugins/kotlin/BUILD.bazel index d97230971b9f..c61c8d27ce6a 100644 --- a/plugins/kotlin/BUILD.bazel +++ b/plugins/kotlin/BUILD.bazel @@ -22,6 +22,7 @@ java_library( "//plugins/kotlin/base/analysis-api-platform", "//plugins/kotlin/base/project-structure", "//plugins/kotlin/base/scripting", + "//plugins/kotlin/base/scripting.k1", "//plugins/kotlin/base/scripting.k2", "//plugins/kotlin/base/analysis-api/analysis-api-utils:kotlin-base-analysis-api-utils", "//plugins/kotlin/base/facet", @@ -232,6 +233,7 @@ java_library( "//plugins/kotlin/base/analysis-api-platform", "//plugins/kotlin/base/project-structure", "//plugins/kotlin/base/scripting", + "//plugins/kotlin/base/scripting.k1", "//plugins/kotlin/base/scripting.k2", "//plugins/kotlin/base/analysis-api/analysis-api-utils:kotlin-base-analysis-api-utils", "//plugins/kotlin/base/facet", diff --git a/plugins/kotlin/base/fe10/analysis/BUILD.bazel b/plugins/kotlin/base/fe10/analysis/BUILD.bazel index 5d12258f004b..33d6972b3334 100644 --- a/plugins/kotlin/base/fe10/analysis/BUILD.bazel +++ b/plugins/kotlin/base/fe10/analysis/BUILD.bazel @@ -49,6 +49,7 @@ jvm_library( "@lib//:kotlinc-analysis-api-impl-base", "//plugins/kotlin/base/plugin", "@lib//:kotlinc-analysis-api-platform-interface", + "//plugins/kotlin/base/scripting.k1", ] ) ### auto-generated section `build kotlin.base.fe10.analysis` end \ No newline at end of file diff --git a/plugins/kotlin/base/fe10/analysis/kotlin.base.fe10.analysis.iml b/plugins/kotlin/base/fe10/analysis/kotlin.base.fe10.analysis.iml index 528761d3ae89..0d484738ba07 100644 --- a/plugins/kotlin/base/fe10/analysis/kotlin.base.fe10.analysis.iml +++ b/plugins/kotlin/base/fe10/analysis/kotlin.base.fe10.analysis.iml @@ -55,5 +55,6 @@ + \ No newline at end of file diff --git a/plugins/kotlin/base/fe10/analysis/src/org/jetbrains/kotlin/idea/caches/resolve/KotlinCacheServiceImpl.kt b/plugins/kotlin/base/fe10/analysis/src/org/jetbrains/kotlin/idea/caches/resolve/KotlinCacheServiceImpl.kt index a1e4f15d9b5b..c32940f780f3 100644 --- a/plugins/kotlin/base/fe10/analysis/src/org/jetbrains/kotlin/idea/caches/resolve/KotlinCacheServiceImpl.kt +++ b/plugins/kotlin/base/fe10/analysis/src/org/jetbrains/kotlin/idea/caches/resolve/KotlinCacheServiceImpl.kt @@ -38,9 +38,6 @@ import org.jetbrains.kotlin.idea.base.projectStructure.moduleInfo.LibrarySourceI import org.jetbrains.kotlin.idea.base.projectStructure.moduleInfo.ModuleSourceInfo import org.jetbrains.kotlin.idea.base.projectStructure.moduleInfo.NotUnderContentRootModuleInfo import org.jetbrains.kotlin.idea.base.psi.KotlinPsiHeuristics -import org.jetbrains.kotlin.idea.base.scripting.projectStructure.ScriptDependenciesInfo -import org.jetbrains.kotlin.idea.base.scripting.projectStructure.ScriptDependenciesSourceInfo -import org.jetbrains.kotlin.idea.base.scripting.projectStructure.ScriptModuleInfo import org.jetbrains.kotlin.idea.caches.project.getDependentModules import org.jetbrains.kotlin.idea.caches.project.isLibraryClasses import org.jetbrains.kotlin.idea.caches.resolve.util.GlobalFacadeModuleFilters @@ -48,6 +45,9 @@ import org.jetbrains.kotlin.idea.caches.resolve.util.contextWithCompositeExcepti import org.jetbrains.kotlin.idea.caches.trackers.outOfBlockModificationCount import org.jetbrains.kotlin.idea.core.script.ScriptDependenciesModificationTracker import org.jetbrains.kotlin.idea.core.script.dependencies.ScriptAdditionalIdeaDependenciesProvider +import org.jetbrains.kotlin.idea.core.script.k1.modules.ScriptDependenciesInfo +import org.jetbrains.kotlin.idea.core.script.k1.modules.ScriptDependenciesSourceInfo +import org.jetbrains.kotlin.idea.core.script.k1.modules.ScriptModuleInfo import org.jetbrains.kotlin.idea.resolve.ResolutionFacade import org.jetbrains.kotlin.platform.TargetPlatform import org.jetbrains.kotlin.platform.jvm.JvmPlatforms diff --git a/plugins/kotlin/base/fe10/analysis/src/org/jetbrains/kotlin/idea/caches/resolve/ProjectResolutionFacade.kt b/plugins/kotlin/base/fe10/analysis/src/org/jetbrains/kotlin/idea/caches/resolve/ProjectResolutionFacade.kt index 6ff9db8bfeef..54b2efdb0bc4 100644 --- a/plugins/kotlin/base/fe10/analysis/src/org/jetbrains/kotlin/idea/caches/resolve/ProjectResolutionFacade.kt +++ b/plugins/kotlin/base/fe10/analysis/src/org/jetbrains/kotlin/idea/caches/resolve/ProjectResolutionFacade.kt @@ -27,9 +27,9 @@ import org.jetbrains.kotlin.idea.base.projectStructure.moduleInfo import org.jetbrains.kotlin.idea.base.projectStructure.moduleInfo.IdeaModuleInfo import org.jetbrains.kotlin.idea.base.projectStructure.moduleInfo.NotUnderContentRootModuleInfo import org.jetbrains.kotlin.idea.base.projectStructure.moduleInfo.checkValidity -import org.jetbrains.kotlin.idea.base.scripting.projectStructure.ScriptDependenciesInfo import org.jetbrains.kotlin.idea.caches.project.getModuleInfosFromIdeaModel import org.jetbrains.kotlin.idea.caches.trackers.KotlinCodeBlockModificationListener +import org.jetbrains.kotlin.idea.core.script.k1.modules.ScriptDependenciesInfo import org.jetbrains.kotlin.js.resolve.diagnostics.ErrorsJs import org.jetbrains.kotlin.psi.KtElement import org.jetbrains.kotlin.psi.KtFile diff --git a/plugins/kotlin/base/fe10/analysis/src/org/jetbrains/kotlin/idea/core/util/ScopeUtils.kt b/plugins/kotlin/base/fe10/analysis/src/org/jetbrains/kotlin/idea/core/util/ScopeUtils.kt index 55b5f4766ecd..f2d28830d102 100644 --- a/plugins/kotlin/base/fe10/analysis/src/org/jetbrains/kotlin/idea/core/util/ScopeUtils.kt +++ b/plugins/kotlin/base/fe10/analysis/src/org/jetbrains/kotlin/idea/core/util/ScopeUtils.kt @@ -6,11 +6,11 @@ package org.jetbrains.kotlin.idea.core.util import com.intellij.psi.search.GlobalSearchScope import org.jetbrains.kotlin.idea.base.projectStructure.KotlinResolveScopeEnlarger import org.jetbrains.kotlin.idea.base.projectStructure.moduleInfo -import org.jetbrains.kotlin.idea.base.scripting.projectStructure.ScriptModuleInfo import org.jetbrains.kotlin.idea.base.projectStructure.moduleInfo.ModuleSourceInfo import org.jetbrains.kotlin.idea.base.projectStructure.moduleInfo.SourceForBinaryModuleInfo import org.jetbrains.kotlin.idea.base.projectStructure.scope.KotlinSourceFilterScope import org.jetbrains.kotlin.idea.base.util.K1ModeProjectStructureApi +import org.jetbrains.kotlin.idea.core.script.k1.modules.ScriptModuleInfo import org.jetbrains.kotlin.psi.KtCodeFragment import org.jetbrains.kotlin.psi.KtFile diff --git a/plugins/kotlin/base/fe10/analysis/src/org/jetbrains/kotlin/idea/decompiler/navigation/SourceNavigationHelper.kt b/plugins/kotlin/base/fe10/analysis/src/org/jetbrains/kotlin/idea/decompiler/navigation/SourceNavigationHelper.kt index c0961452246d..75145718e7d1 100644 --- a/plugins/kotlin/base/fe10/analysis/src/org/jetbrains/kotlin/idea/decompiler/navigation/SourceNavigationHelper.kt +++ b/plugins/kotlin/base/fe10/analysis/src/org/jetbrains/kotlin/idea/decompiler/navigation/SourceNavigationHelper.kt @@ -19,9 +19,9 @@ import org.jetbrains.kotlin.fileClasses.fileClassInfo import org.jetbrains.kotlin.idea.base.projectStructure.* import org.jetbrains.kotlin.idea.base.projectStructure.moduleInfo.BinaryModuleInfo import org.jetbrains.kotlin.idea.base.projectStructure.moduleInfo.LibraryInfo -import org.jetbrains.kotlin.idea.base.scripting.projectStructure.ScriptDependenciesInfo import org.jetbrains.kotlin.idea.caches.project.binariesScope import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptorIfAny +import org.jetbrains.kotlin.idea.core.script.k1.modules.ScriptDependenciesInfo import org.jetbrains.kotlin.idea.decompiler.navigation.MemberMatching.receiverAndParametersShortTypesMatch import org.jetbrains.kotlin.idea.decompiler.navigation.MemberMatching.sameReceiverPresenceAndParametersCount import org.jetbrains.kotlin.idea.stubindex.* diff --git a/plugins/kotlin/base/fir/scripting/src/org/jetbrains/kotlin/base/fir/scripting/projectStructure/modules/KaScriptModuleImpl.kt b/plugins/kotlin/base/fir/scripting/src/org/jetbrains/kotlin/base/fir/scripting/projectStructure/modules/KaScriptModuleImpl.kt index 3177743ba207..75e6de4e4994 100644 --- a/plugins/kotlin/base/fir/scripting/src/org/jetbrains/kotlin/base/fir/scripting/projectStructure/modules/KaScriptModuleImpl.kt +++ b/plugins/kotlin/base/fir/scripting/src/org/jetbrains/kotlin/base/fir/scripting/projectStructure/modules/KaScriptModuleImpl.kt @@ -19,9 +19,9 @@ import org.jetbrains.kotlin.idea.base.projectStructure.toKaSourceModuleForProduc import org.jetbrains.kotlin.idea.base.projectStructure.toKaSourceModuleForTest import org.jetbrains.kotlin.idea.base.scripting.getLanguageVersionSettings import org.jetbrains.kotlin.idea.base.scripting.getPlatform +import org.jetbrains.kotlin.idea.base.scripting.projectStructure.KotlinScriptSearchScope import org.jetbrains.kotlin.idea.base.scripting.projectStructure.scriptModuleEntity import org.jetbrains.kotlin.idea.core.script.ScriptDependencyAware -import org.jetbrains.kotlin.idea.core.script.dependencies.KotlinScriptSearchScope import org.jetbrains.kotlin.idea.core.script.dependencies.ScriptAdditionalIdeaDependenciesProvider import org.jetbrains.kotlin.idea.core.script.k2.modules.K2IdeScriptAdditionalIdeaDependenciesProvider import org.jetbrains.kotlin.platform.TargetPlatform diff --git a/plugins/kotlin/base/scripting.k1/BUILD.bazel b/plugins/kotlin/base/scripting.k1/BUILD.bazel new file mode 100644 index 000000000000..9354fc5ad0da --- /dev/null +++ b/plugins/kotlin/base/scripting.k1/BUILD.bazel @@ -0,0 +1,64 @@ +### auto-generated section `build kotlin.base.scripting.k1` start +load("@rules_jvm//:jvm.bzl", "jvm_library", "jvm_resources") + +jvm_resources( + name = "scripting.k1_resources", + files = glob(["resources/**/*"]), + strip_prefix = "resources" +) + +jvm_library( + name = "scripting.k1", + module_name = "kotlin.base.scripting.k1", + visibility = ["//visibility:public"], + srcs = glob(["src/**/*.kt", "src/**/*.java"], allow_empty = True), + deps = [ + "//plugins/kotlin/base/scripting", + "@lib//:kotlin-stdlib", + "@lib//:kotlinc-kotlin-compiler-common", + "@lib//:kotlinc-kotlin-jps-common", + "@lib//:kotlinc-analysis-api", + "@lib//:kotlinc-analysis-api-platform-interface", + "@lib//:kotlinc-kotlin-script-runtime", + "@lib//:kotlinc-kotlin-scripting-common", + "@lib//:kotlinc-kotlin-scripting-jvm", + "@lib//:kotlinc-kotlin-scripting-compiler-impl", + "@lib//:kotlinx-coroutines-core", + "//platform/indexing-api:indexing", + "//jps/model-api:model", + "//platform/workspace/storage", + "//plugins/kotlin/base/compiler-configuration", + "//platform/util/progress", + "//plugins/kotlin/base/util", + "//plugins/kotlin/base/psi", + "//platform/platform-impl:ide-impl", + "//plugins/kotlin/base/plugin", + "//plugins/kotlin/base/resources:kotlin-base-resources", + "//plugins/kotlin/base/platforms", + "//plugins/kotlin/base/facet", + "//plugins/kotlin/base/project-structure", + "//platform/core-ui", + "//platform/util/jdom", + "//platform/util-class-loader:util-classLoader", + "//platform/projectModel-impl", + "//platform/analysis-api:analysis", + "//platform/editor-ui-api:editor-ui", + "//platform/lang-impl", + "//platform/diff-impl", + "//platform/ide-core", + "//platform/ide-core-impl", + "//java/openapi:java", + "//java/java-indexing-impl:indexing-impl", + "//platform/collaboration-tools", + "//java/java-impl:impl", + "//platform/backend/workspace", + "//plugins/kotlin/code-insight/utils", + "//platform/workspace/jps", + "//platform/external-system-impl:externalSystem-impl", + "//java/idea-ui:ui", + "@lib//:kotlinc-kotlin-scripting-dependencies", + "//plugins/kotlin/scripting", + ], + runtime_deps = [":scripting.k1_resources"] +) +### auto-generated section `build kotlin.base.scripting.k1` end \ No newline at end of file diff --git a/plugins/kotlin/base/scripting.k1/kotlin.base.scripting.k1.iml b/plugins/kotlin/base/scripting.k1/kotlin.base.scripting.k1.iml new file mode 100644 index 000000000000..abb21793616f --- /dev/null +++ b/plugins/kotlin/base/scripting.k1/kotlin.base.scripting.k1.iml @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/plugins/kotlin/base/scripting.k1/resources/kotlin.base.scripting.k1.xml b/plugins/kotlin/base/scripting.k1/resources/kotlin.base.scripting.k1.xml new file mode 100644 index 000000000000..ef01c1174e5d --- /dev/null +++ b/plugins/kotlin/base/scripting.k1/resources/kotlin.base.scripting.k1.xml @@ -0,0 +1,11 @@ + + + + + + + + + + diff --git a/plugins/kotlin/base/scripting/src/org/jetbrains/kotlin/idea/core/script/dependencies/KotlinScriptResolveScopeProvider.kt b/plugins/kotlin/base/scripting.k1/src/org/jetbrains/kotlin/idea/core/script/k1/dependencies/KotlinScriptResolveScopeProvider.kt similarity index 95% rename from plugins/kotlin/base/scripting/src/org/jetbrains/kotlin/idea/core/script/dependencies/KotlinScriptResolveScopeProvider.kt rename to plugins/kotlin/base/scripting.k1/src/org/jetbrains/kotlin/idea/core/script/k1/dependencies/KotlinScriptResolveScopeProvider.kt index 39d7f430a4d2..83bece87d6e6 100644 --- a/plugins/kotlin/base/scripting/src/org/jetbrains/kotlin/idea/core/script/dependencies/KotlinScriptResolveScopeProvider.kt +++ b/plugins/kotlin/base/scripting.k1/src/org/jetbrains/kotlin/idea/core/script/k1/dependencies/KotlinScriptResolveScopeProvider.kt @@ -1,6 +1,6 @@ -// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. -package org.jetbrains.kotlin.idea.core.script.dependencies +package org.jetbrains.kotlin.idea.core.script.k1.dependencies import com.intellij.codeInsight.multiverse.CodeInsightContext import com.intellij.codeInsight.multiverse.defaultContext @@ -8,29 +8,27 @@ import com.intellij.openapi.project.Project import com.intellij.openapi.vfs.VirtualFile import com.intellij.psi.PsiManager import com.intellij.psi.ResolveScopeProvider -import com.intellij.psi.search.DelegatingGlobalSearchScope import com.intellij.psi.search.GlobalSearchScope import org.jetbrains.kotlin.config.LanguageFeature import org.jetbrains.kotlin.idea.base.projectStructure.moduleInfoOrNull -import org.jetbrains.kotlin.idea.base.scripting.projectStructure.ScriptModuleInfo +import org.jetbrains.kotlin.idea.base.scripting.projectStructure.KotlinScriptSearchScope import org.jetbrains.kotlin.idea.base.util.K1ModeProjectStructureApi import org.jetbrains.kotlin.idea.base.util.isUnderKotlinSourceRootTypes import org.jetbrains.kotlin.idea.base.util.module import org.jetbrains.kotlin.idea.compilerAllowsAnyScriptsInSourceRoots import org.jetbrains.kotlin.idea.core.script.ScriptDependencyAware +import org.jetbrains.kotlin.idea.core.script.k1.modules.ScriptModuleInfo import org.jetbrains.kotlin.idea.core.script.scriptingDebugLog import org.jetbrains.kotlin.idea.hasNoExceptionsToBeUnderSourceRoot import org.jetbrains.kotlin.idea.isEnabled import org.jetbrains.kotlin.idea.util.isKotlinFileType import org.jetbrains.kotlin.psi.KtFile -import org.jetbrains.kotlin.scripting.definitions.ScriptDefinition import org.jetbrains.kotlin.scripting.definitions.ScriptConfigurationsProvider +import org.jetbrains.kotlin.scripting.definitions.ScriptDefinition import org.jetbrains.kotlin.scripting.definitions.findScriptDefinition import kotlin.script.experimental.api.ScriptCompilationConfiguration import kotlin.script.experimental.api.isStandalone -class KotlinScriptSearchScope(project: Project, baseScope: GlobalSearchScope) : DelegatingGlobalSearchScope(project, baseScope) - class KotlinScriptResolveScopeProvider : ResolveScopeProvider() { override fun getResolveScope(file: VirtualFile, project: Project): GlobalSearchScope? = diff --git a/plugins/kotlin/base/scripting/src/org/jetbrains/kotlin/idea/core/script/dependencies/ScriptDependenciesResolveScopeProvider.kt b/plugins/kotlin/base/scripting.k1/src/org/jetbrains/kotlin/idea/core/script/k1/dependencies/ScriptDependenciesResolveScopeProvider.kt similarity index 87% rename from plugins/kotlin/base/scripting/src/org/jetbrains/kotlin/idea/core/script/dependencies/ScriptDependenciesResolveScopeProvider.kt rename to plugins/kotlin/base/scripting.k1/src/org/jetbrains/kotlin/idea/core/script/k1/dependencies/ScriptDependenciesResolveScopeProvider.kt index bdd8b0e8ce6a..a8a2cf550712 100644 --- a/plugins/kotlin/base/scripting/src/org/jetbrains/kotlin/idea/core/script/dependencies/ScriptDependenciesResolveScopeProvider.kt +++ b/plugins/kotlin/base/scripting.k1/src/org/jetbrains/kotlin/idea/core/script/k1/dependencies/ScriptDependenciesResolveScopeProvider.kt @@ -1,6 +1,6 @@ -// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. -package org.jetbrains.kotlin.idea.core.script.dependencies +package org.jetbrains.kotlin.idea.core.script.k1.dependencies import com.intellij.openapi.project.Project import com.intellij.openapi.vfs.VirtualFile @@ -8,9 +8,10 @@ import com.intellij.psi.ResolveScopeProvider import com.intellij.psi.search.GlobalSearchScope import org.jetbrains.kotlin.idea.base.projectStructure.RootKindFilter import org.jetbrains.kotlin.idea.base.projectStructure.RootKindMatcher -import org.jetbrains.kotlin.idea.base.scripting.projectStructure.ScriptDependenciesInfo +import org.jetbrains.kotlin.idea.base.scripting.projectStructure.KotlinScriptSearchScope import org.jetbrains.kotlin.idea.base.util.K1ModeProjectStructureApi import org.jetbrains.kotlin.idea.core.script.ScriptDependencyAware +import org.jetbrains.kotlin.idea.core.script.k1.modules.ScriptDependenciesInfo /** * @see KotlinScriptResolveScopeProvider diff --git a/plugins/kotlin/base/scripting/src/org/jetbrains/kotlin/idea/base/scripting/projectStructure/ScriptDependenciesInfo.kt b/plugins/kotlin/base/scripting.k1/src/org/jetbrains/kotlin/idea/core/script/k1/modules/ScriptDependenciesInfo.kt similarity index 96% rename from plugins/kotlin/base/scripting/src/org/jetbrains/kotlin/idea/base/scripting/projectStructure/ScriptDependenciesInfo.kt rename to plugins/kotlin/base/scripting.k1/src/org/jetbrains/kotlin/idea/core/script/k1/modules/ScriptDependenciesInfo.kt index fbc4d191e4f8..8b493e02511c 100644 --- a/plugins/kotlin/base/scripting/src/org/jetbrains/kotlin/idea/base/scripting/projectStructure/ScriptDependenciesInfo.kt +++ b/plugins/kotlin/base/scripting.k1/src/org/jetbrains/kotlin/idea/core/script/k1/modules/ScriptDependenciesInfo.kt @@ -1,5 +1,5 @@ -// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. -package org.jetbrains.kotlin.idea.base.scripting.projectStructure +// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +package org.jetbrains.kotlin.idea.core.script.k1.modules import com.intellij.openapi.project.Project import com.intellij.openapi.projectRoots.Sdk @@ -14,9 +14,9 @@ import org.jetbrains.kotlin.idea.base.projectStructure.scope.KotlinSourceFilterS import org.jetbrains.kotlin.idea.base.scripting.KotlinBaseScriptingBundle import org.jetbrains.kotlin.idea.base.scripting.getLanguageVersionSettings import org.jetbrains.kotlin.idea.base.scripting.getTargetPlatformVersion +import org.jetbrains.kotlin.idea.base.scripting.projectStructure.KotlinScriptSearchScope import org.jetbrains.kotlin.idea.base.util.K1ModeProjectStructureApi import org.jetbrains.kotlin.idea.core.script.ScriptDependencyAware -import org.jetbrains.kotlin.idea.core.script.dependencies.KotlinScriptSearchScope import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.platform.TargetPlatform import org.jetbrains.kotlin.platform.TargetPlatformVersion diff --git a/plugins/kotlin/base/scripting/src/org/jetbrains/kotlin/idea/base/scripting/projectStructure/ScriptDependenciesSourceInfo.kt b/plugins/kotlin/base/scripting.k1/src/org/jetbrains/kotlin/idea/core/script/k1/modules/ScriptDependenciesSourceInfo.kt similarity index 97% rename from plugins/kotlin/base/scripting/src/org/jetbrains/kotlin/idea/base/scripting/projectStructure/ScriptDependenciesSourceInfo.kt rename to plugins/kotlin/base/scripting.k1/src/org/jetbrains/kotlin/idea/core/script/k1/modules/ScriptDependenciesSourceInfo.kt index 1cb6889a49ab..3c98f51b2754 100644 --- a/plugins/kotlin/base/scripting/src/org/jetbrains/kotlin/idea/base/scripting/projectStructure/ScriptDependenciesSourceInfo.kt +++ b/plugins/kotlin/base/scripting.k1/src/org/jetbrains/kotlin/idea/core/script/k1/modules/ScriptDependenciesSourceInfo.kt @@ -1,5 +1,5 @@ // Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. -package org.jetbrains.kotlin.idea.base.scripting.projectStructure +package org.jetbrains.kotlin.idea.core.script.k1.modules import com.intellij.openapi.project.Project import com.intellij.psi.search.GlobalSearchScope diff --git a/plugins/kotlin/base/scripting/src/org/jetbrains/kotlin/idea/base/scripting/projectStructure/ScriptModuleInfo.kt b/plugins/kotlin/base/scripting.k1/src/org/jetbrains/kotlin/idea/core/script/k1/modules/ScriptModuleInfo.kt similarity index 91% rename from plugins/kotlin/base/scripting/src/org/jetbrains/kotlin/idea/base/scripting/projectStructure/ScriptModuleInfo.kt rename to plugins/kotlin/base/scripting.k1/src/org/jetbrains/kotlin/idea/core/script/k1/modules/ScriptModuleInfo.kt index 22cd7ba463d8..27f609c8a622 100644 --- a/plugins/kotlin/base/scripting/src/org/jetbrains/kotlin/idea/base/scripting/projectStructure/ScriptModuleInfo.kt +++ b/plugins/kotlin/base/scripting.k1/src/org/jetbrains/kotlin/idea/core/script/k1/modules/ScriptModuleInfo.kt @@ -1,5 +1,5 @@ -// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. -package org.jetbrains.kotlin.idea.base.scripting.projectStructure +// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +package org.jetbrains.kotlin.idea.core.script.k1.modules import com.intellij.openapi.project.Project import com.intellij.openapi.vfs.VirtualFile @@ -24,9 +24,10 @@ import org.jetbrains.kotlin.idea.base.projectStructure.sourceModuleInfos import org.jetbrains.kotlin.idea.base.scripting.getLanguageVersionSettings import org.jetbrains.kotlin.idea.base.scripting.getPlatform import org.jetbrains.kotlin.idea.base.scripting.getTargetPlatformVersion +import org.jetbrains.kotlin.idea.base.scripting.projectStructure.KotlinScriptSearchScope +import org.jetbrains.kotlin.idea.base.scripting.projectStructure.scriptModuleEntity import org.jetbrains.kotlin.idea.base.util.K1ModeProjectStructureApi import org.jetbrains.kotlin.idea.core.script.ScriptDependencyAware -import org.jetbrains.kotlin.idea.core.script.dependencies.KotlinScriptSearchScope import org.jetbrains.kotlin.idea.core.script.dependencies.ScriptAdditionalIdeaDependenciesProvider import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.platform.TargetPlatform @@ -59,7 +60,7 @@ data class ScriptModuleInfo( val snapshot = WorkspaceModel.getInstance(project).currentSnapshot scriptFile.workspaceEntities(project, snapshot).filterIsInstance().firstOrNull() - ?.let { + ?.let { it.findModule(snapshot)?.let { module -> val scope = KotlinResolveScopeEnlarger.enlargeScope( module.getModuleWithDependenciesAndLibrariesScope(false), @@ -141,13 +142,6 @@ fun VirtualFile.workspaceEntities(project: Project, snapshot: EntityStorage): Se return snapshot.getVirtualFileUrlIndex().findEntitiesByUrl(virtualFileUrl) } -@ApiStatus.Internal -fun VirtualFile.scriptModuleEntity(project: Project, snapshot: EntityStorage): ModuleEntity? { - val virtualFileUrlManager = WorkspaceModel.getInstance(project).getVirtualFileUrlManager() - val virtualFileUrl = toVirtualFileUrl(virtualFileUrlManager) - return snapshot.getVirtualFileUrlIndex().findEntitiesByUrl(virtualFileUrl).firstNotNullOfOrNull { it as? ModuleEntity } -} - @K1ModeProjectStructureApi internal fun VirtualFile.scriptLibraryDependencies(project: Project): Sequence { val storage = WorkspaceModel.getInstance(project).currentSnapshot diff --git a/plugins/kotlin/base/scripting/src/org/jetbrains/kotlin/idea/base/scripting/projectStructure/ScriptingKaModuleFactory.kt b/plugins/kotlin/base/scripting.k1/src/org/jetbrains/kotlin/idea/core/script/k1/modules/ScriptingKaModuleFactory.kt similarity index 92% rename from plugins/kotlin/base/scripting/src/org/jetbrains/kotlin/idea/base/scripting/projectStructure/ScriptingKaModuleFactory.kt rename to plugins/kotlin/base/scripting.k1/src/org/jetbrains/kotlin/idea/core/script/k1/modules/ScriptingKaModuleFactory.kt index edaf1250885b..60181409c580 100644 --- a/plugins/kotlin/base/scripting/src/org/jetbrains/kotlin/idea/base/scripting/projectStructure/ScriptingKaModuleFactory.kt +++ b/plugins/kotlin/base/scripting.k1/src/org/jetbrains/kotlin/idea/core/script/k1/modules/ScriptingKaModuleFactory.kt @@ -1,14 +1,14 @@ -// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. -@file:OptIn(K1ModeProjectStructureApi::class) +// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +@file:OptIn(K1ModeProjectStructureApi::class, KaPlatformInterface::class) -package org.jetbrains.kotlin.idea.base.scripting.projectStructure +package org.jetbrains.kotlin.idea.core.script.k1.modules import com.intellij.openapi.project.Project import com.intellij.openapi.vfs.VirtualFile import com.intellij.psi.PsiManager import com.intellij.psi.search.GlobalSearchScope import org.jetbrains.kotlin.analysis.api.KaExperimentalApi -import org.jetbrains.kotlin.analysis.api.platform.projectStructure.KaContentScopeProvider +import org.jetbrains.kotlin.analysis.api.KaPlatformInterface import org.jetbrains.kotlin.analysis.api.projectStructure.* import org.jetbrains.kotlin.analyzer.ModuleInfo import org.jetbrains.kotlin.config.LanguageVersionSettings @@ -20,7 +20,6 @@ import org.jetbrains.kotlin.idea.core.script.KotlinScriptEntitySource import org.jetbrains.kotlin.idea.core.script.ScriptDependencyAware import org.jetbrains.kotlin.idea.core.script.dependencies.ScriptAdditionalIdeaDependenciesProvider import org.jetbrains.kotlin.psi.KtFile -import org.jetbrains.kotlin.utils.addToStdlib.safeAs import java.nio.file.Path internal class ScriptingKaModuleFactory : KaModuleFactory { @@ -29,10 +28,10 @@ internal class ScriptingKaModuleFactory : KaModuleFactory { is ScriptModuleInfo -> KtScriptModuleByModuleInfo(moduleInfo) is ScriptDependenciesInfo -> KtScriptDependencyModuleByModuleInfo(moduleInfo) is ScriptDependenciesSourceInfo -> KtScriptDependencySourceModuleByModuleInfo(moduleInfo) - is JvmLibraryInfo -> moduleInfo.source?.safeAs()?.let { + is JvmLibraryInfo -> (moduleInfo.source as? KotlinScriptEntitySource)?.let { KtScriptLibraryModuleByModuleInfo(moduleInfo) } - is LibrarySourceInfo -> moduleInfo.source?.safeAs()?.let { + is LibrarySourceInfo -> (moduleInfo.source as? KotlinScriptEntitySource)?.let { KtScriptLibrarySourceModuleByModuleInfo(moduleInfo) } else -> null diff --git a/plugins/kotlin/base/scripting/src/org/jetbrains/kotlin/idea/base/scripting/ScriptingModuleInfoProviderExtension.kt b/plugins/kotlin/base/scripting.k1/src/org/jetbrains/kotlin/idea/core/script/k1/modules/ScriptingModuleInfoProviderExtension.kt similarity index 84% rename from plugins/kotlin/base/scripting/src/org/jetbrains/kotlin/idea/base/scripting/ScriptingModuleInfoProviderExtension.kt rename to plugins/kotlin/base/scripting.k1/src/org/jetbrains/kotlin/idea/core/script/k1/modules/ScriptingModuleInfoProviderExtension.kt index 1d1a6982e32d..ac3e3eb500c1 100644 --- a/plugins/kotlin/base/scripting/src/org/jetbrains/kotlin/idea/base/scripting/ScriptingModuleInfoProviderExtension.kt +++ b/plugins/kotlin/base/scripting.k1/src/org/jetbrains/kotlin/idea/core/script/k1/modules/ScriptingModuleInfoProviderExtension.kt @@ -1,5 +1,5 @@ -// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. -package org.jetbrains.kotlin.idea.base.scripting +// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +package org.jetbrains.kotlin.idea.core.script.k1.modules import com.intellij.ide.scratch.ScratchFileService import com.intellij.ide.scratch.ScratchRootType @@ -15,9 +15,6 @@ import org.jetbrains.kotlin.idea.base.projectStructure.ModuleInfoProviderExtensi import org.jetbrains.kotlin.idea.base.projectStructure.isKotlinBinary import org.jetbrains.kotlin.idea.base.projectStructure.moduleInfo.IdeaModuleInfo import org.jetbrains.kotlin.idea.base.projectStructure.register -import org.jetbrains.kotlin.idea.base.scripting.projectStructure.ScriptDependenciesInfo -import org.jetbrains.kotlin.idea.base.scripting.projectStructure.ScriptDependenciesSourceInfo -import org.jetbrains.kotlin.idea.base.scripting.projectStructure.ScriptModuleInfo import org.jetbrains.kotlin.idea.base.util.K1ModeProjectStructureApi import org.jetbrains.kotlin.idea.core.script.ScriptDependencyAware import org.jetbrains.kotlin.idea.core.script.ScriptRelatedModuleNameFile @@ -29,9 +26,9 @@ import org.jetbrains.kotlin.utils.yieldIfNotNull @OptIn(K1ModeProjectStructureApi::class) internal class ScriptingModuleInfoProviderExtension : ModuleInfoProviderExtension { override suspend fun SequenceScope>.collectByElement( - element: PsiElement, - file: PsiFile, - virtualFile: VirtualFile + element: PsiElement, + file: PsiFile, + virtualFile: VirtualFile ) { val ktFile = file as? KtFile ?: return val isScript = runReadAction { ktFile.isValid && ktFile.isScript() } @@ -45,10 +42,10 @@ internal class ScriptingModuleInfoProviderExtension : ModuleInfoProviderExtensio } override suspend fun SequenceScope>.collectByFile( - project: Project, - virtualFile: VirtualFile, - isLibrarySource: Boolean, - config: ModuleInfoProvider.Configuration, + project: Project, + virtualFile: VirtualFile, + isLibrarySource: Boolean, + config: ModuleInfoProvider.Configuration, ) { val isBinary = virtualFile.fileType.isKotlinBinary @@ -89,7 +86,7 @@ internal class ScriptingModuleInfoProviderExtension : ModuleInfoProviderExtensio override suspend fun SequenceScope.findContainingModules(project: Project, virtualFile: VirtualFile) { if (ScratchFileService.getInstance().getRootType(virtualFile) is ScratchRootType) { - ScriptRelatedModuleNameFile[project, virtualFile]?.let { scratchModuleName -> + ScriptRelatedModuleNameFile.Companion[project, virtualFile]?.let { scratchModuleName -> val moduleManager = ModuleManager.getInstance(project) yieldIfNotNull(moduleManager.findModuleByName(scratchModuleName)) } diff --git a/plugins/kotlin/base/scripting.k2/resources/kotlin.base.scripting.k2.xml b/plugins/kotlin/base/scripting.k2/resources/kotlin.base.scripting.k2.xml index 41af8db29a6d..dbb22f12056c 100644 --- a/plugins/kotlin/base/scripting.k2/resources/kotlin.base.scripting.k2.xml +++ b/plugins/kotlin/base/scripting.k2/resources/kotlin.base.scripting.k2.xml @@ -18,6 +18,9 @@ + + + @@ -61,6 +64,7 @@ + in-module" } + null // as designed + } else { + calculateScopeForStandaloneScript(file, project) // the compiler doesn't forbid this, so do we + } + } + + private fun KtFile.getScopeForStandaloneScript(file: VirtualFile, project: Project): KotlinScriptSearchScope? { + val underSourceRoot = isUnderKotlinSourceRootTypes() + debugLog { "under-source-root: $underSourceRoot" } + + return if (underSourceRoot) { + getScopeForStandaloneScriptUnderSourceRoot(file, project) + } else { + calculateScopeForStandaloneScript(file, project) // as designed + } + } + + private fun KtFile.getScopeForStandaloneScriptUnderSourceRoot(file: VirtualFile, project: Project): KotlinScriptSearchScope? { + val hasNoExceptionToBeUnderSourceRoot = file.hasNoExceptionsToBeUnderSourceRoot() + debugLog { "exception-to-be-under-source-root: ${!hasNoExceptionToBeUnderSourceRoot}" } + + return if (hasNoExceptionToBeUnderSourceRoot) { + // We show the editor notification panel (file will be ignored at compilation), but allow resolution/highlighting work. + calculateScopeForStandaloneScript(file, project) + } else { + debugLog { "=> in-module" } + null // scripts not yet supporting "isStandalone" flag + } + } + + private fun KtFile.isStandaloneScriptByDesign(project: Project, definition: ScriptDefinition): Boolean { + val configuration = ScriptConfigurationsProvider.getInstance(project)?.getScriptConfiguration(this)?.configuration + ?: definition.compilationConfiguration + val isStandalone = configuration[ScriptCompilationConfiguration.isStandalone] == true + debugLog { "standalone-by-design: $isStandalone" } + return isStandalone + } + + private fun KtFile.calculateScopeForStandaloneScript(file: VirtualFile, project: Project): KotlinScriptSearchScope { + val vFile = virtualFile ?: viewProvider.virtualFile + val dependenciesScope = + ScriptDependencyAware.getInstance(project).getScriptDependenciesClassFilesScope(vFile) + debugLog { "=> standalone" } + return KotlinScriptSearchScope(project, GlobalSearchScope.fileScope(project, file).uniteWith(dependenciesScope)) + } + + private fun KtFile.debugLog(message: () -> String) { + scriptingDebugLog(this) { "[resolve-scope] ${message.invoke()}"} + } +} \ No newline at end of file diff --git a/plugins/kotlin/base/scripting.k2/src/org/jetbrains/kotlin/idea/core/script/k2/dependencies/ScriptDependenciesResolveScopeProvider.kt b/plugins/kotlin/base/scripting.k2/src/org/jetbrains/kotlin/idea/core/script/k2/dependencies/ScriptDependenciesResolveScopeProvider.kt new file mode 100644 index 000000000000..193c2f434af1 --- /dev/null +++ b/plugins/kotlin/base/scripting.k2/src/org/jetbrains/kotlin/idea/core/script/k2/dependencies/ScriptDependenciesResolveScopeProvider.kt @@ -0,0 +1,42 @@ +// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. + +package org.jetbrains.kotlin.idea.core.script.k2.dependencies + +import com.intellij.openapi.project.Project +import com.intellij.openapi.vfs.VirtualFile +import com.intellij.psi.ResolveScopeProvider +import com.intellij.psi.search.GlobalSearchScope +import org.jetbrains.kotlin.idea.base.projectStructure.RootKindFilter +import org.jetbrains.kotlin.idea.base.projectStructure.RootKindMatcher +import org.jetbrains.kotlin.idea.base.scripting.projectStructure.KotlinScriptSearchScope +import org.jetbrains.kotlin.idea.core.script.ScriptDependencyAware + +/** + * @see KotlinScriptResolveScopeProvider + */ +class ScriptDependenciesResolveScopeProvider : ResolveScopeProvider() { + + /** + * @param file is a file belonging to dependencies of a script being analysed + */ + override fun getResolveScope(file: VirtualFile, project: Project): GlobalSearchScope? { + /* + Unfortunately, we cannot limit the scope to the concrete script dependencies. There is no way to say, what .kts is being analysed. + Some facts to consider: + - dependencies are analysed first, .kts file itself goes last + - multiple editors can be opened (selected is only one of them) + */ + + if (RootKindMatcher.matches(project, file, RootKindFilter.libraryFiles.copy(includeScriptDependencies = false))) + return null + + if (ScriptDependencyAware.getInstance(project).getAllScriptsDependenciesClassFiles().isEmpty()) return null + + if (file !in ScriptDependencyAware.getInstance(project).getAllScriptsDependenciesClassFilesScope() + && file !in ScriptDependencyAware.getInstance(project).getAllScriptDependenciesSourcesScope()) { + return null + } + + return KotlinScriptSearchScope(project, GlobalSearchScope.fileScope(project, file)) + } +} diff --git a/plugins/kotlin/base/scripting.k2/src/org/jetbrains/kotlin/idea/core/script/k2/modules/ScriptingKaModuleFactory.kt b/plugins/kotlin/base/scripting.k2/src/org/jetbrains/kotlin/idea/core/script/k2/modules/ScriptingKaModuleFactory.kt new file mode 100644 index 000000000000..bebb15c27fdf --- /dev/null +++ b/plugins/kotlin/base/scripting.k2/src/org/jetbrains/kotlin/idea/core/script/k2/modules/ScriptingKaModuleFactory.kt @@ -0,0 +1,30 @@ +// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +@file:OptIn(K1ModeProjectStructureApi::class, KaPlatformInterface::class) + +package org.jetbrains.kotlin.idea.core.script.k2.modules + +import org.jetbrains.kotlin.analysis.api.KaPlatformInterface +import org.jetbrains.kotlin.analysis.api.projectStructure.KaModule +import org.jetbrains.kotlin.analyzer.ModuleInfo +import org.jetbrains.kotlin.idea.base.projectStructure.KaModuleFactory +import org.jetbrains.kotlin.idea.base.projectStructure.KtScriptLibraryModuleByModuleInfo +import org.jetbrains.kotlin.idea.base.projectStructure.KtScriptLibrarySourceModuleByModuleInfo +import org.jetbrains.kotlin.idea.base.projectStructure.moduleInfo.JvmLibraryInfo +import org.jetbrains.kotlin.idea.base.projectStructure.moduleInfo.LibrarySourceInfo +import org.jetbrains.kotlin.idea.base.util.K1ModeProjectStructureApi +import org.jetbrains.kotlin.idea.core.script.KotlinScriptEntitySource + +internal class ScriptingKaModuleFactory : KaModuleFactory { + override fun createModule(moduleInfo: ModuleInfo): KaModule? { + return when (moduleInfo) { + is JvmLibraryInfo -> (moduleInfo.source as? KotlinScriptEntitySource)?.let { + KtScriptLibraryModuleByModuleInfo(moduleInfo) + } + is LibrarySourceInfo -> (moduleInfo.source as? KotlinScriptEntitySource)?.let { + KtScriptLibrarySourceModuleByModuleInfo(moduleInfo) + } + else -> null + } + } + +} diff --git a/plugins/kotlin/base/scripting/BUILD.bazel b/plugins/kotlin/base/scripting/BUILD.bazel index 4c6b688ebd51..5d77dccae2f8 100644 --- a/plugins/kotlin/base/scripting/BUILD.bazel +++ b/plugins/kotlin/base/scripting/BUILD.bazel @@ -76,7 +76,7 @@ jvm_library( jvm_library( name = "scripting_test_lib", visibility = ["//visibility:public"], - srcs = glob(["test/**/*.kt", "test/**/*.java"], allow_empty = True), + srcs = glob(["test/**/*.kt", "test/**/*.java", "testGen/**/*.kt", "testGen/**/*.java"], allow_empty = True), kotlinc_opts = ":custom", associates = [":scripting"], deps = [ diff --git a/plugins/kotlin/base/scripting/gen/org/jetbrains/kotlin/idea/core/script/ucache/impl/KotlinScriptEntityImpl.kt b/plugins/kotlin/base/scripting/gen/org/jetbrains/kotlin/idea/core/script/ucache/impl/KotlinScriptEntityImpl.kt index c1c99ac049d8..872a71398305 100644 --- a/plugins/kotlin/base/scripting/gen/org/jetbrains/kotlin/idea/core/script/ucache/impl/KotlinScriptEntityImpl.kt +++ b/plugins/kotlin/base/scripting/gen/org/jetbrains/kotlin/idea/core/script/ucache/impl/KotlinScriptEntityImpl.kt @@ -1,4 +1,4 @@ -// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package org.jetbrains.kotlin.idea.core.script.ucache.impl import com.intellij.platform.workspace.storage.* @@ -20,282 +20,282 @@ import org.jetbrains.kotlin.idea.core.script.ucache.KotlinScriptLibraryId @GeneratedCodeApiVersion(3) @GeneratedCodeImplVersion(6) @OptIn(WorkspaceEntityInternalApi::class) -internal class KotlinScriptEntityImpl(private val dataSource: KotlinScriptEntityData) : KotlinScriptEntity, - WorkspaceEntityBase(dataSource) { +internal class KotlinScriptEntityImpl(private val dataSource: KotlinScriptEntityData) : KotlinScriptEntity, WorkspaceEntityBase( + dataSource) { - private companion object { + private companion object { - private val connections = listOf( - ) + private val connections = listOf( + ) + } + + override val symbolicId: KotlinScriptId = super.symbolicId + + override val path: String + get() { + readField("path") + return dataSource.path } - override val symbolicId: KotlinScriptId = super.symbolicId + override val dependencies: Set + get() { + readField("dependencies") + return dataSource.dependencies + } - override val path: String - get() { - readField("path") - return dataSource.path - } + override val entitySource: EntitySource + get() { + readField("entitySource") + return dataSource.entitySource + } - override val dependencies: Set - get() { - readField("dependencies") - return dataSource.dependencies - } + override fun connectionIdList(): List { + return connections + } - override val entitySource: EntitySource - get() { - readField("entitySource") - return dataSource.entitySource + + internal class Builder(result: KotlinScriptEntityData?) : ModifiableWorkspaceEntityBase( + result), KotlinScriptEntity.Builder { + internal constructor() : this(KotlinScriptEntityData()) + + override fun applyToBuilder(builder: MutableEntityStorage) { + if (this.diff != null) { + if (existsInBuilder(builder)) { + this.diff = builder + return } + else { + error("Entity KotlinScriptEntity is already created in a different builder") + } + } + + this.diff = builder + addToBuilder() + this.id = getEntityData().createEntityId() + // After adding entity data to the builder, we need to unbind it and move the control over entity data to builder + // Builder may switch to snapshot at any moment and lock entity data to modification + this.currentEntityData = null + + // Process linked entities that are connected without a builder + processLinkedEntities(builder) + checkInitialization() // TODO uncomment and check failed tests + } + + private fun checkInitialization() { + val _diff = diff + if (!getEntityData().isEntitySourceInitialized()) { + error("Field WorkspaceEntity#entitySource should be initialized") + } + if (!getEntityData().isPathInitialized()) { + error("Field KotlinScriptEntity#path should be initialized") + } + if (!getEntityData().isDependenciesInitialized()) { + error("Field KotlinScriptEntity#dependencies should be initialized") + } + } override fun connectionIdList(): List { - return connections + return connections + } + + override fun afterModification() { + val collection_dependencies = getEntityData().dependencies + if (collection_dependencies is MutableWorkspaceSet<*>) { + collection_dependencies.cleanModificationUpdateAction() + } + } + + // Relabeling code, move information from dataSource to this builder + override fun relabel(dataSource: WorkspaceEntity, parents: Set?) { + dataSource as KotlinScriptEntity + if (this.entitySource != dataSource.entitySource) this.entitySource = dataSource.entitySource + if (this.path != dataSource.path) this.path = dataSource.path + if (this.dependencies != dataSource.dependencies) this.dependencies = dataSource.dependencies.toMutableSet() + updateChildToParentReferences(parents) } - internal class Builder(result: KotlinScriptEntityData?) : - ModifiableWorkspaceEntityBase(result), KotlinScriptEntity.Builder { - internal constructor() : this(KotlinScriptEntityData()) + override var entitySource: EntitySource + get() = getEntityData().entitySource + set(value) { + checkModificationAllowed() + getEntityData(true).entitySource = value + changedProperty.add("entitySource") - override fun applyToBuilder(builder: MutableEntityStorage) { - if (this.diff != null) { - if (existsInBuilder(builder)) { - this.diff = builder - return - } - else { - error("Entity KotlinScriptEntity is already created in a different builder") - } - } + } - this.diff = builder - addToBuilder() - this.id = getEntityData().createEntityId() - // After adding entity data to the builder, we need to unbind it and move the control over entity data to builder - // Builder may switch to snapshot at any moment and lock entity data to modification - this.currentEntityData = null + override var path: String + get() = getEntityData().path + set(value) { + checkModificationAllowed() + getEntityData(true).path = value + changedProperty.add("path") + } - // Process linked entities that are connected without a builder - processLinkedEntities(builder) - checkInitialization() // TODO uncomment and check failed tests - } + private val dependenciesUpdater: (value: Set) -> Unit = { value -> - private fun checkInitialization() { - val _diff = diff - if (!getEntityData().isEntitySourceInitialized()) { - error("Field WorkspaceEntity#entitySource should be initialized") - } - if (!getEntityData().isPathInitialized()) { - error("Field KotlinScriptEntity#path should be initialized") - } - if (!getEntityData().isDependenciesInitialized()) { - error("Field KotlinScriptEntity#dependencies should be initialized") - } - } - - override fun connectionIdList(): List { - return connections - } - - override fun afterModification() { - val collection_dependencies = getEntityData().dependencies - if (collection_dependencies is MutableWorkspaceSet<*>) { - collection_dependencies.cleanModificationUpdateAction() - } - } - - // Relabeling code, move information from dataSource to this builder - override fun relabel(dataSource: WorkspaceEntity, parents: Set?) { - dataSource as KotlinScriptEntity - if (this.entitySource != dataSource.entitySource) this.entitySource = dataSource.entitySource - if (this.path != dataSource.path) this.path = dataSource.path - if (this.dependencies != dataSource.dependencies) this.dependencies = dataSource.dependencies.toMutableSet() - updateChildToParentReferences(parents) - } - - - override var entitySource: EntitySource - get() = getEntityData().entitySource - set(value) { - checkModificationAllowed() - getEntityData(true).entitySource = value - changedProperty.add("entitySource") - - } - - override var path: String - get() = getEntityData().path - set(value) { - checkModificationAllowed() - getEntityData(true).path = value - changedProperty.add("path") - } - - private val dependenciesUpdater: (value: Set) -> Unit = { value -> - - changedProperty.add("dependencies") - } - override var dependencies: MutableSet - get() { - val collection_dependencies = getEntityData().dependencies - if (collection_dependencies !is MutableWorkspaceSet) return collection_dependencies - if (diff == null || modifiable.get()) { - collection_dependencies.setModificationUpdateAction(dependenciesUpdater) - } - else { - collection_dependencies.cleanModificationUpdateAction() - } - return collection_dependencies - } - set(value) { - checkModificationAllowed() - getEntityData(true).dependencies = value - dependenciesUpdater.invoke(value) - } - - override fun getEntityClass(): Class = KotlinScriptEntity::class.java + changedProperty.add("dependencies") } + override var dependencies: MutableSet + get() { + val collection_dependencies = getEntityData().dependencies + if (collection_dependencies !is MutableWorkspaceSet) return collection_dependencies + if (diff == null || modifiable.get()) { + collection_dependencies.setModificationUpdateAction(dependenciesUpdater) + } + else { + collection_dependencies.cleanModificationUpdateAction() + } + return collection_dependencies + } + set(value) { + checkModificationAllowed() + getEntityData(true).dependencies = value + dependenciesUpdater.invoke(value) + } + + override fun getEntityClass(): Class = KotlinScriptEntity::class.java + } } @OptIn(WorkspaceEntityInternalApi::class) internal class KotlinScriptEntityData : WorkspaceEntityData(), SoftLinkable { - lateinit var path: String - lateinit var dependencies: MutableSet + lateinit var path: String + lateinit var dependencies: MutableSet - internal fun isPathInitialized(): Boolean = ::path.isInitialized - internal fun isDependenciesInitialized(): Boolean = ::dependencies.isInitialized + internal fun isPathInitialized(): Boolean = ::path.isInitialized + internal fun isDependenciesInitialized(): Boolean = ::dependencies.isInitialized - override fun getLinks(): Set> { - val result = HashSet>() - for (item in dependencies) { - result.add(item) - } - return result + override fun getLinks(): Set> { + val result = HashSet>() + for (item in dependencies) { + result.add(item) } + return result + } - override fun index(index: WorkspaceMutableIndex>) { - for (item in dependencies) { - index.index(this, item) - } + override fun index(index: WorkspaceMutableIndex>) { + for (item in dependencies) { + index.index(this, item) } + } - override fun updateLinksIndex(prev: Set>, index: WorkspaceMutableIndex>) { - // TODO verify logic - val mutablePreviousSet = HashSet(prev) - for (item in dependencies) { - val removedItem_item = mutablePreviousSet.remove(item) - if (!removedItem_item) { - index.index(this, item) - } - } - for (removed in mutablePreviousSet) { - index.remove(this, removed) - } + override fun updateLinksIndex(prev: Set>, index: WorkspaceMutableIndex>) { + // TODO verify logic + val mutablePreviousSet = HashSet(prev) + for (item in dependencies) { + val removedItem_item = mutablePreviousSet.remove(item) + if (!removedItem_item) { + index.index(this, item) + } } - - override fun updateLink(oldLink: SymbolicEntityId<*>, newLink: SymbolicEntityId<*>): Boolean { - var changed = false - val dependencies_data = dependencies.map { - val it_data = if (it == oldLink) { - changed = true - newLink as KotlinScriptLibraryId - } - else { - null - } - if (it_data != null) { - it_data - } - else { - it - } - } - if (dependencies_data != null) { - dependencies = dependencies_data as MutableSet - } - return changed + for (removed in mutablePreviousSet) { + index.remove(this, removed) } + } - override fun wrapAsModifiable(diff: MutableEntityStorage): WorkspaceEntity.Builder { - val modifiable = KotlinScriptEntityImpl.Builder(null) - modifiable.diff = diff - modifiable.id = createEntityId() - return modifiable + override fun updateLink(oldLink: SymbolicEntityId<*>, newLink: SymbolicEntityId<*>): Boolean { + var changed = false + val dependencies_data = dependencies.map { + val it_data = if (it == oldLink) { + changed = true + newLink as KotlinScriptLibraryId + } + else { + null + } + if (it_data != null) { + it_data + } + else { + it + } } - - @OptIn(EntityStorageInstrumentationApi::class) - override fun createEntity(snapshot: EntityStorageInstrumentation): KotlinScriptEntity { - val entityId = createEntityId() - return snapshot.initializeEntity(entityId) { - val entity = KotlinScriptEntityImpl(this) - entity.snapshot = snapshot - entity.id = entityId - entity - } + if (dependencies_data != null) { + dependencies = dependencies_data as MutableSet } + return changed + } - override fun getMetadata(): EntityMetadata { - return MetadataStorageImpl.getMetadataByTypeFqn("org.jetbrains.kotlin.idea.core.script.ucache.KotlinScriptEntity") as EntityMetadata + override fun wrapAsModifiable(diff: MutableEntityStorage): WorkspaceEntity.Builder { + val modifiable = KotlinScriptEntityImpl.Builder(null) + modifiable.diff = diff + modifiable.id = createEntityId() + return modifiable + } + + @OptIn(EntityStorageInstrumentationApi::class) + override fun createEntity(snapshot: EntityStorageInstrumentation): KotlinScriptEntity { + val entityId = createEntityId() + return snapshot.initializeEntity(entityId) { + val entity = KotlinScriptEntityImpl(this) + entity.snapshot = snapshot + entity.id = entityId + entity } + } - override fun clone(): KotlinScriptEntityData { - val clonedEntity = super.clone() - clonedEntity as KotlinScriptEntityData - clonedEntity.dependencies = clonedEntity.dependencies.toMutableWorkspaceSet() - return clonedEntity + override fun getMetadata(): EntityMetadata { + return MetadataStorageImpl.getMetadataByTypeFqn("org.jetbrains.kotlin.idea.core.script.ucache.KotlinScriptEntity") as EntityMetadata + } + + override fun clone(): KotlinScriptEntityData { + val clonedEntity = super.clone() + clonedEntity as KotlinScriptEntityData + clonedEntity.dependencies = clonedEntity.dependencies.toMutableWorkspaceSet() + return clonedEntity + } + + override fun getEntityInterface(): Class { + return KotlinScriptEntity::class.java + } + + override fun createDetachedEntity(parents: List>): WorkspaceEntity.Builder<*> { + return KotlinScriptEntity(path, dependencies, entitySource) { } + } - override fun getEntityInterface(): Class { - return KotlinScriptEntity::class.java - } + override fun getRequiredParents(): List> { + val res = mutableListOf>() + return res + } - override fun createDetachedEntity(parents: List>): WorkspaceEntity.Builder<*> { - return KotlinScriptEntity(path, dependencies, entitySource) { - } - } + override fun equals(other: Any?): Boolean { + if (other == null) return false + if (this.javaClass != other.javaClass) return false - override fun getRequiredParents(): List> { - val res = mutableListOf>() - return res - } + other as KotlinScriptEntityData - override fun equals(other: Any?): Boolean { - if (other == null) return false - if (this.javaClass != other.javaClass) return false + if (this.entitySource != other.entitySource) return false + if (this.path != other.path) return false + if (this.dependencies != other.dependencies) return false + return true + } - other as KotlinScriptEntityData + override fun equalsIgnoringEntitySource(other: Any?): Boolean { + if (other == null) return false + if (this.javaClass != other.javaClass) return false - if (this.entitySource != other.entitySource) return false - if (this.path != other.path) return false - if (this.dependencies != other.dependencies) return false - return true - } + other as KotlinScriptEntityData - override fun equalsIgnoringEntitySource(other: Any?): Boolean { - if (other == null) return false - if (this.javaClass != other.javaClass) return false + if (this.path != other.path) return false + if (this.dependencies != other.dependencies) return false + return true + } - other as KotlinScriptEntityData + override fun hashCode(): Int { + var result = entitySource.hashCode() + result = 31 * result + path.hashCode() + result = 31 * result + dependencies.hashCode() + return result + } - if (this.path != other.path) return false - if (this.dependencies != other.dependencies) return false - return true - } - - override fun hashCode(): Int { - var result = entitySource.hashCode() - result = 31 * result + path.hashCode() - result = 31 * result + dependencies.hashCode() - return result - } - - override fun hashCodeIgnoringEntitySource(): Int { - var result = javaClass.hashCode() - result = 31 * result + path.hashCode() - result = 31 * result + dependencies.hashCode() - return result - } + override fun hashCodeIgnoringEntitySource(): Int { + var result = javaClass.hashCode() + result = 31 * result + path.hashCode() + result = 31 * result + dependencies.hashCode() + return result + } } diff --git a/plugins/kotlin/base/scripting/gen/org/jetbrains/kotlin/idea/core/script/ucache/impl/KotlinScriptLibraryEntityImpl.kt b/plugins/kotlin/base/scripting/gen/org/jetbrains/kotlin/idea/core/script/ucache/impl/KotlinScriptLibraryEntityImpl.kt index 67cb4869a788..25fa646e9a54 100644 --- a/plugins/kotlin/base/scripting/gen/org/jetbrains/kotlin/idea/core/script/ucache/impl/KotlinScriptLibraryEntityImpl.kt +++ b/plugins/kotlin/base/scripting/gen/org/jetbrains/kotlin/idea/core/script/ucache/impl/KotlinScriptLibraryEntityImpl.kt @@ -1,4 +1,4 @@ -// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package org.jetbrains.kotlin.idea.core.script.ucache.impl import com.intellij.platform.workspace.storage.* @@ -24,353 +24,352 @@ import org.jetbrains.kotlin.idea.core.script.ucache.KotlinScriptLibraryRoot @GeneratedCodeApiVersion(3) @GeneratedCodeImplVersion(6) @OptIn(WorkspaceEntityInternalApi::class) -internal class KotlinScriptLibraryEntityImpl(private val dataSource: KotlinScriptLibraryEntityData) : KotlinScriptLibraryEntity, - WorkspaceEntityBase(dataSource) { +internal class KotlinScriptLibraryEntityImpl(private val dataSource: KotlinScriptLibraryEntityData) : KotlinScriptLibraryEntity, WorkspaceEntityBase( + dataSource) { - private companion object { + private companion object { - private val connections = listOf( - ) + private val connections = listOf( + ) + } + + override val symbolicId: KotlinScriptLibraryId = super.symbolicId + + override val name: String + get() { + readField("name") + return dataSource.name } - override val symbolicId: KotlinScriptLibraryId = super.symbolicId + override val roots: List + get() { + readField("roots") + return dataSource.roots + } - override val name: String - get() { - readField("name") - return dataSource.name - } + override val indexSourceRoots: Boolean + get() { + readField("indexSourceRoots") + return dataSource.indexSourceRoots + } + override val usedInScripts: Set + get() { + readField("usedInScripts") + return dataSource.usedInScripts + } - override val roots: List - get() { - readField("roots") - return dataSource.roots - } + override val entitySource: EntitySource + get() { + readField("entitySource") + return dataSource.entitySource + } - override val indexSourceRoots: Boolean - get() { - readField("indexSourceRoots") - return dataSource.indexSourceRoots - } - override val usedInScripts: Set - get() { - readField("usedInScripts") - return dataSource.usedInScripts - } + override fun connectionIdList(): List { + return connections + } - override val entitySource: EntitySource - get() { - readField("entitySource") - return dataSource.entitySource + + internal class Builder(result: KotlinScriptLibraryEntityData?) : ModifiableWorkspaceEntityBase( + result), KotlinScriptLibraryEntity.Builder { + internal constructor() : this(KotlinScriptLibraryEntityData()) + + override fun applyToBuilder(builder: MutableEntityStorage) { + if (this.diff != null) { + if (existsInBuilder(builder)) { + this.diff = builder + return } + else { + error("Entity KotlinScriptLibraryEntity is already created in a different builder") + } + } + + this.diff = builder + addToBuilder() + this.id = getEntityData().createEntityId() + // After adding entity data to the builder, we need to unbind it and move the control over entity data to builder + // Builder may switch to snapshot at any moment and lock entity data to modification + this.currentEntityData = null + + // Process linked entities that are connected without a builder + processLinkedEntities(builder) + checkInitialization() // TODO uncomment and check failed tests + } + + private fun checkInitialization() { + val _diff = diff + if (!getEntityData().isEntitySourceInitialized()) { + error("Field WorkspaceEntity#entitySource should be initialized") + } + if (!getEntityData().isNameInitialized()) { + error("Field KotlinScriptLibraryEntity#name should be initialized") + } + if (!getEntityData().isRootsInitialized()) { + error("Field KotlinScriptLibraryEntity#roots should be initialized") + } + if (!getEntityData().isUsedInScriptsInitialized()) { + error("Field KotlinScriptLibraryEntity#usedInScripts should be initialized") + } + } override fun connectionIdList(): List { - return connections + return connections + } + + override fun afterModification() { + val collection_roots = getEntityData().roots + if (collection_roots is MutableWorkspaceList<*>) { + collection_roots.cleanModificationUpdateAction() + } + val collection_usedInScripts = getEntityData().usedInScripts + if (collection_usedInScripts is MutableWorkspaceSet<*>) { + collection_usedInScripts.cleanModificationUpdateAction() + } + } + + // Relabeling code, move information from dataSource to this builder + override fun relabel(dataSource: WorkspaceEntity, parents: Set?) { + dataSource as KotlinScriptLibraryEntity + if (this.entitySource != dataSource.entitySource) this.entitySource = dataSource.entitySource + if (this.name != dataSource.name) this.name = dataSource.name + if (this.roots != dataSource.roots) this.roots = dataSource.roots.toMutableList() + if (this.indexSourceRoots != dataSource.indexSourceRoots) this.indexSourceRoots = dataSource.indexSourceRoots + if (this.usedInScripts != dataSource.usedInScripts) this.usedInScripts = dataSource.usedInScripts.toMutableSet() + updateChildToParentReferences(parents) } - internal class Builder(result: KotlinScriptLibraryEntityData?) : - ModifiableWorkspaceEntityBase(result), KotlinScriptLibraryEntity.Builder { - internal constructor() : this(KotlinScriptLibraryEntityData()) + override var entitySource: EntitySource + get() = getEntityData().entitySource + set(value) { + checkModificationAllowed() + getEntityData(true).entitySource = value + changedProperty.add("entitySource") - override fun applyToBuilder(builder: MutableEntityStorage) { - if (this.diff != null) { - if (existsInBuilder(builder)) { - this.diff = builder - return - } - else { - error("Entity KotlinScriptLibraryEntity is already created in a different builder") - } - } + } - this.diff = builder - addToBuilder() - this.id = getEntityData().createEntityId() - // After adding entity data to the builder, we need to unbind it and move the control over entity data to builder - // Builder may switch to snapshot at any moment and lock entity data to modification - this.currentEntityData = null + override var name: String + get() = getEntityData().name + set(value) { + checkModificationAllowed() + getEntityData(true).name = value + changedProperty.add("name") + } - // Process linked entities that are connected without a builder - processLinkedEntities(builder) - checkInitialization() // TODO uncomment and check failed tests - } + private val rootsUpdater: (value: List) -> Unit = { value -> - private fun checkInitialization() { - val _diff = diff - if (!getEntityData().isEntitySourceInitialized()) { - error("Field WorkspaceEntity#entitySource should be initialized") - } - if (!getEntityData().isNameInitialized()) { - error("Field KotlinScriptLibraryEntity#name should be initialized") - } - if (!getEntityData().isRootsInitialized()) { - error("Field KotlinScriptLibraryEntity#roots should be initialized") - } - if (!getEntityData().isUsedInScriptsInitialized()) { - error("Field KotlinScriptLibraryEntity#usedInScripts should be initialized") - } - } - - override fun connectionIdList(): List { - return connections - } - - override fun afterModification() { - val collection_roots = getEntityData().roots - if (collection_roots is MutableWorkspaceList<*>) { - collection_roots.cleanModificationUpdateAction() - } - val collection_usedInScripts = getEntityData().usedInScripts - if (collection_usedInScripts is MutableWorkspaceSet<*>) { - collection_usedInScripts.cleanModificationUpdateAction() - } - } - - // Relabeling code, move information from dataSource to this builder - override fun relabel(dataSource: WorkspaceEntity, parents: Set?) { - dataSource as KotlinScriptLibraryEntity - if (this.entitySource != dataSource.entitySource) this.entitySource = dataSource.entitySource - if (this.name != dataSource.name) this.name = dataSource.name - if (this.roots != dataSource.roots) this.roots = dataSource.roots.toMutableList() - if (this.indexSourceRoots != dataSource.indexSourceRoots) this.indexSourceRoots = dataSource.indexSourceRoots - if (this.usedInScripts != dataSource.usedInScripts) this.usedInScripts = dataSource.usedInScripts.toMutableSet() - updateChildToParentReferences(parents) - } - - - override var entitySource: EntitySource - get() = getEntityData().entitySource - set(value) { - checkModificationAllowed() - getEntityData(true).entitySource = value - changedProperty.add("entitySource") - - } - - override var name: String - get() = getEntityData().name - set(value) { - checkModificationAllowed() - getEntityData(true).name = value - changedProperty.add("name") - } - - private val rootsUpdater: (value: List) -> Unit = { value -> - - changedProperty.add("roots") - } - override var roots: MutableList - get() { - val collection_roots = getEntityData().roots - if (collection_roots !is MutableWorkspaceList) return collection_roots - if (diff == null || modifiable.get()) { - collection_roots.setModificationUpdateAction(rootsUpdater) - } - else { - collection_roots.cleanModificationUpdateAction() - } - return collection_roots - } - set(value) { - checkModificationAllowed() - getEntityData(true).roots = value - rootsUpdater.invoke(value) - } - - override var indexSourceRoots: Boolean - get() = getEntityData().indexSourceRoots - set(value) { - checkModificationAllowed() - getEntityData(true).indexSourceRoots = value - changedProperty.add("indexSourceRoots") - } - - private val usedInScriptsUpdater: (value: Set) -> Unit = { value -> - - changedProperty.add("usedInScripts") - } - override var usedInScripts: MutableSet - get() { - val collection_usedInScripts = getEntityData().usedInScripts - if (collection_usedInScripts !is MutableWorkspaceSet) return collection_usedInScripts - if (diff == null || modifiable.get()) { - collection_usedInScripts.setModificationUpdateAction(usedInScriptsUpdater) - } - else { - collection_usedInScripts.cleanModificationUpdateAction() - } - return collection_usedInScripts - } - set(value) { - checkModificationAllowed() - getEntityData(true).usedInScripts = value - usedInScriptsUpdater.invoke(value) - } - - override fun getEntityClass(): Class = KotlinScriptLibraryEntity::class.java + changedProperty.add("roots") } + override var roots: MutableList + get() { + val collection_roots = getEntityData().roots + if (collection_roots !is MutableWorkspaceList) return collection_roots + if (diff == null || modifiable.get()) { + collection_roots.setModificationUpdateAction(rootsUpdater) + } + else { + collection_roots.cleanModificationUpdateAction() + } + return collection_roots + } + set(value) { + checkModificationAllowed() + getEntityData(true).roots = value + rootsUpdater.invoke(value) + } + + override var indexSourceRoots: Boolean + get() = getEntityData().indexSourceRoots + set(value) { + checkModificationAllowed() + getEntityData(true).indexSourceRoots = value + changedProperty.add("indexSourceRoots") + } + + private val usedInScriptsUpdater: (value: Set) -> Unit = { value -> + + changedProperty.add("usedInScripts") + } + override var usedInScripts: MutableSet + get() { + val collection_usedInScripts = getEntityData().usedInScripts + if (collection_usedInScripts !is MutableWorkspaceSet) return collection_usedInScripts + if (diff == null || modifiable.get()) { + collection_usedInScripts.setModificationUpdateAction(usedInScriptsUpdater) + } + else { + collection_usedInScripts.cleanModificationUpdateAction() + } + return collection_usedInScripts + } + set(value) { + checkModificationAllowed() + getEntityData(true).usedInScripts = value + usedInScriptsUpdater.invoke(value) + } + + override fun getEntityClass(): Class = KotlinScriptLibraryEntity::class.java + } } @OptIn(WorkspaceEntityInternalApi::class) internal class KotlinScriptLibraryEntityData : WorkspaceEntityData(), SoftLinkable { - lateinit var name: String - lateinit var roots: MutableList - var indexSourceRoots: Boolean = false - lateinit var usedInScripts: MutableSet + lateinit var name: String + lateinit var roots: MutableList + var indexSourceRoots: Boolean = false + lateinit var usedInScripts: MutableSet - internal fun isNameInitialized(): Boolean = ::name.isInitialized - internal fun isRootsInitialized(): Boolean = ::roots.isInitialized + internal fun isNameInitialized(): Boolean = ::name.isInitialized + internal fun isRootsInitialized(): Boolean = ::roots.isInitialized - internal fun isUsedInScriptsInitialized(): Boolean = ::usedInScripts.isInitialized + internal fun isUsedInScriptsInitialized(): Boolean = ::usedInScripts.isInitialized - override fun getLinks(): Set> { - val result = HashSet>() - for (item in roots) { - } - for (item in usedInScripts) { - result.add(item) - } - return result + override fun getLinks(): Set> { + val result = HashSet>() + for (item in roots) { } - - override fun index(index: WorkspaceMutableIndex>) { - for (item in roots) { - } - for (item in usedInScripts) { - index.index(this, item) - } + for (item in usedInScripts) { + result.add(item) } + return result + } - override fun updateLinksIndex(prev: Set>, index: WorkspaceMutableIndex>) { - // TODO verify logic - val mutablePreviousSet = HashSet(prev) - for (item in roots) { - } - for (item in usedInScripts) { - val removedItem_item = mutablePreviousSet.remove(item) - if (!removedItem_item) { - index.index(this, item) - } - } - for (removed in mutablePreviousSet) { - index.remove(this, removed) - } + override fun index(index: WorkspaceMutableIndex>) { + for (item in roots) { } - - override fun updateLink(oldLink: SymbolicEntityId<*>, newLink: SymbolicEntityId<*>): Boolean { - var changed = false - val usedInScripts_data = usedInScripts.map { - val it_data = if (it == oldLink) { - changed = true - newLink as KotlinScriptId - } - else { - null - } - if (it_data != null) { - it_data - } - else { - it - } - } - if (usedInScripts_data != null) { - usedInScripts = usedInScripts_data as MutableSet - } - return changed + for (item in usedInScripts) { + index.index(this, item) } + } - override fun wrapAsModifiable(diff: MutableEntityStorage): WorkspaceEntity.Builder { - val modifiable = KotlinScriptLibraryEntityImpl.Builder(null) - modifiable.diff = diff - modifiable.id = createEntityId() - return modifiable + override fun updateLinksIndex(prev: Set>, index: WorkspaceMutableIndex>) { + // TODO verify logic + val mutablePreviousSet = HashSet(prev) + for (item in roots) { } - - @OptIn(EntityStorageInstrumentationApi::class) - override fun createEntity(snapshot: EntityStorageInstrumentation): KotlinScriptLibraryEntity { - val entityId = createEntityId() - return snapshot.initializeEntity(entityId) { - val entity = KotlinScriptLibraryEntityImpl(this) - entity.snapshot = snapshot - entity.id = entityId - entity - } + for (item in usedInScripts) { + val removedItem_item = mutablePreviousSet.remove(item) + if (!removedItem_item) { + index.index(this, item) + } } - - override fun getMetadata(): EntityMetadata { - return MetadataStorageImpl.getMetadataByTypeFqn( - "org.jetbrains.kotlin.idea.core.script.ucache.KotlinScriptLibraryEntity" - ) as EntityMetadata + for (removed in mutablePreviousSet) { + index.remove(this, removed) } + } - override fun clone(): KotlinScriptLibraryEntityData { - val clonedEntity = super.clone() - clonedEntity as KotlinScriptLibraryEntityData - clonedEntity.roots = clonedEntity.roots.toMutableWorkspaceList() - clonedEntity.usedInScripts = clonedEntity.usedInScripts.toMutableWorkspaceSet() - return clonedEntity + override fun updateLink(oldLink: SymbolicEntityId<*>, newLink: SymbolicEntityId<*>): Boolean { + var changed = false + val usedInScripts_data = usedInScripts.map { + val it_data = if (it == oldLink) { + changed = true + newLink as KotlinScriptId + } + else { + null + } + if (it_data != null) { + it_data + } + else { + it + } } - - override fun getEntityInterface(): Class { - return KotlinScriptLibraryEntity::class.java + if (usedInScripts_data != null) { + usedInScripts = usedInScripts_data as MutableSet } + return changed + } - override fun createDetachedEntity(parents: List>): WorkspaceEntity.Builder<*> { - return KotlinScriptLibraryEntity(name, roots, indexSourceRoots, usedInScripts, entitySource) { - } + override fun wrapAsModifiable(diff: MutableEntityStorage): WorkspaceEntity.Builder { + val modifiable = KotlinScriptLibraryEntityImpl.Builder(null) + modifiable.diff = diff + modifiable.id = createEntityId() + return modifiable + } + + @OptIn(EntityStorageInstrumentationApi::class) + override fun createEntity(snapshot: EntityStorageInstrumentation): KotlinScriptLibraryEntity { + val entityId = createEntityId() + return snapshot.initializeEntity(entityId) { + val entity = KotlinScriptLibraryEntityImpl(this) + entity.snapshot = snapshot + entity.id = entityId + entity } + } - override fun getRequiredParents(): List> { - val res = mutableListOf>() - return res + override fun getMetadata(): EntityMetadata { + return MetadataStorageImpl.getMetadataByTypeFqn( + "org.jetbrains.kotlin.idea.core.script.ucache.KotlinScriptLibraryEntity") as EntityMetadata + } + + override fun clone(): KotlinScriptLibraryEntityData { + val clonedEntity = super.clone() + clonedEntity as KotlinScriptLibraryEntityData + clonedEntity.roots = clonedEntity.roots.toMutableWorkspaceList() + clonedEntity.usedInScripts = clonedEntity.usedInScripts.toMutableWorkspaceSet() + return clonedEntity + } + + override fun getEntityInterface(): Class { + return KotlinScriptLibraryEntity::class.java + } + + override fun createDetachedEntity(parents: List>): WorkspaceEntity.Builder<*> { + return KotlinScriptLibraryEntity(name, roots, indexSourceRoots, usedInScripts, entitySource) { } + } - override fun equals(other: Any?): Boolean { - if (other == null) return false - if (this.javaClass != other.javaClass) return false + override fun getRequiredParents(): List> { + val res = mutableListOf>() + return res + } - other as KotlinScriptLibraryEntityData + override fun equals(other: Any?): Boolean { + if (other == null) return false + if (this.javaClass != other.javaClass) return false - if (this.entitySource != other.entitySource) return false - if (this.name != other.name) return false - if (this.roots != other.roots) return false - if (this.indexSourceRoots != other.indexSourceRoots) return false - if (this.usedInScripts != other.usedInScripts) return false - return true - } + other as KotlinScriptLibraryEntityData - override fun equalsIgnoringEntitySource(other: Any?): Boolean { - if (other == null) return false - if (this.javaClass != other.javaClass) return false + if (this.entitySource != other.entitySource) return false + if (this.name != other.name) return false + if (this.roots != other.roots) return false + if (this.indexSourceRoots != other.indexSourceRoots) return false + if (this.usedInScripts != other.usedInScripts) return false + return true + } - other as KotlinScriptLibraryEntityData + override fun equalsIgnoringEntitySource(other: Any?): Boolean { + if (other == null) return false + if (this.javaClass != other.javaClass) return false - if (this.name != other.name) return false - if (this.roots != other.roots) return false - if (this.indexSourceRoots != other.indexSourceRoots) return false - if (this.usedInScripts != other.usedInScripts) return false - return true - } + other as KotlinScriptLibraryEntityData - override fun hashCode(): Int { - var result = entitySource.hashCode() - result = 31 * result + name.hashCode() - result = 31 * result + roots.hashCode() - result = 31 * result + indexSourceRoots.hashCode() - result = 31 * result + usedInScripts.hashCode() - return result - } + if (this.name != other.name) return false + if (this.roots != other.roots) return false + if (this.indexSourceRoots != other.indexSourceRoots) return false + if (this.usedInScripts != other.usedInScripts) return false + return true + } - override fun hashCodeIgnoringEntitySource(): Int { - var result = javaClass.hashCode() - result = 31 * result + name.hashCode() - result = 31 * result + roots.hashCode() - result = 31 * result + indexSourceRoots.hashCode() - result = 31 * result + usedInScripts.hashCode() - return result - } + override fun hashCode(): Int { + var result = entitySource.hashCode() + result = 31 * result + name.hashCode() + result = 31 * result + roots.hashCode() + result = 31 * result + indexSourceRoots.hashCode() + result = 31 * result + usedInScripts.hashCode() + return result + } + + override fun hashCodeIgnoringEntitySource(): Int { + var result = javaClass.hashCode() + result = 31 * result + name.hashCode() + result = 31 * result + roots.hashCode() + result = 31 * result + indexSourceRoots.hashCode() + result = 31 * result + usedInScripts.hashCode() + return result + } } diff --git a/plugins/kotlin/base/scripting/kotlin.base.scripting.iml b/plugins/kotlin/base/scripting/kotlin.base.scripting.iml index b3617135a5bf..a758d1ecfd23 100644 --- a/plugins/kotlin/base/scripting/kotlin.base.scripting.iml +++ b/plugins/kotlin/base/scripting/kotlin.base.scripting.iml @@ -23,6 +23,7 @@ + diff --git a/plugins/kotlin/base/scripting/src/org/jetbrains/kotlin/idea/base/scripting/projectStructure/KotlinScriptSearchScope.kt b/plugins/kotlin/base/scripting/src/org/jetbrains/kotlin/idea/base/scripting/projectStructure/KotlinScriptSearchScope.kt new file mode 100644 index 000000000000..afde0a7ff6e6 --- /dev/null +++ b/plugins/kotlin/base/scripting/src/org/jetbrains/kotlin/idea/base/scripting/projectStructure/KotlinScriptSearchScope.kt @@ -0,0 +1,8 @@ +// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +package org.jetbrains.kotlin.idea.base.scripting.projectStructure + +import com.intellij.openapi.project.Project +import com.intellij.psi.search.DelegatingGlobalSearchScope +import com.intellij.psi.search.GlobalSearchScope + +class KotlinScriptSearchScope(project: Project, baseScope: GlobalSearchScope) : DelegatingGlobalSearchScope(project, baseScope) \ No newline at end of file diff --git a/plugins/kotlin/base/scripting/src/org/jetbrains/kotlin/idea/base/scripting/projectStructure/scriptModuleEntity.kt b/plugins/kotlin/base/scripting/src/org/jetbrains/kotlin/idea/base/scripting/projectStructure/scriptModuleEntity.kt new file mode 100644 index 000000000000..7f8a7afc3c42 --- /dev/null +++ b/plugins/kotlin/base/scripting/src/org/jetbrains/kotlin/idea/base/scripting/projectStructure/scriptModuleEntity.kt @@ -0,0 +1,17 @@ +// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +package org.jetbrains.kotlin.idea.base.scripting.projectStructure + +import com.intellij.openapi.project.Project +import com.intellij.openapi.vfs.VirtualFile +import com.intellij.platform.backend.workspace.WorkspaceModel +import com.intellij.platform.backend.workspace.toVirtualFileUrl +import com.intellij.platform.workspace.jps.entities.ModuleEntity +import com.intellij.platform.workspace.storage.EntityStorage +import org.jetbrains.annotations.ApiStatus + +@ApiStatus.Internal +fun VirtualFile.scriptModuleEntity(project: Project, snapshot: EntityStorage): ModuleEntity? { + val virtualFileUrlManager = WorkspaceModel.getInstance(project).getVirtualFileUrlManager() + val virtualFileUrl = toVirtualFileUrl(virtualFileUrlManager) + return snapshot.getVirtualFileUrlIndex().findEntitiesByUrl(virtualFileUrl).firstNotNullOfOrNull { it as? ModuleEntity } +} \ No newline at end of file diff --git a/plugins/kotlin/base/scripting/src/org/jetbrains/kotlin/idea/core/script/ucache/KotlinScriptEntity.kt b/plugins/kotlin/base/scripting/src/org/jetbrains/kotlin/idea/core/script/ucache/KotlinScriptEntity.kt index b6ac65bbc7ea..40e26d93460c 100644 --- a/plugins/kotlin/base/scripting/src/org/jetbrains/kotlin/idea/core/script/ucache/KotlinScriptEntity.kt +++ b/plugins/kotlin/base/scripting/src/org/jetbrains/kotlin/idea/core/script/ucache/KotlinScriptEntity.kt @@ -16,42 +16,42 @@ interface KotlinScriptEntity : WorkspaceEntityWithSymbolicId { override val symbolicId: KotlinScriptId get() = KotlinScriptId(path) - //region generated code - @GeneratedCodeApiVersion(3) - interface Builder : WorkspaceEntity.Builder { - override var entitySource: EntitySource - var path: String - var dependencies: MutableSet - } + //region generated code + @GeneratedCodeApiVersion(3) + interface Builder : WorkspaceEntity.Builder { + override var entitySource: EntitySource + var path: String + var dependencies: MutableSet + } - companion object : EntityType() { - @JvmOverloads - @JvmStatic - @JvmName("create") - operator fun invoke( - path: String, - dependencies: Set, - entitySource: EntitySource, - init: (Builder.() -> Unit)? = null, - ): Builder { - val builder = builder() - builder.path = path - builder.dependencies = dependencies.toMutableWorkspaceSet() - builder.entitySource = entitySource - init?.invoke(builder) - return builder - } + companion object : EntityType() { + @JvmOverloads + @JvmStatic + @JvmName("create") + operator fun invoke( + path: String, + dependencies: Set, + entitySource: EntitySource, + init: (Builder.() -> Unit)? = null, + ): Builder { + val builder = builder() + builder.path = path + builder.dependencies = dependencies.toMutableWorkspaceSet() + builder.entitySource = entitySource + init?.invoke(builder) + return builder } - //endregion + } + //endregion } //region generated code fun MutableEntityStorage.modifyKotlinScriptEntity( - entity: KotlinScriptEntity, - modification: KotlinScriptEntity.Builder.() -> Unit, + entity: KotlinScriptEntity, + modification: KotlinScriptEntity.Builder.() -> Unit, ): KotlinScriptEntity { - return modifyEntity(KotlinScriptEntity.Builder::class.java, entity, modification) + return modifyEntity(KotlinScriptEntity.Builder::class.java, entity, modification) } //endregion diff --git a/plugins/kotlin/base/scripting/src/org/jetbrains/kotlin/idea/core/script/ucache/KotlinScriptLibraryEntity.kt b/plugins/kotlin/base/scripting/src/org/jetbrains/kotlin/idea/core/script/ucache/KotlinScriptLibraryEntity.kt index 8bc4328dced5..eb8d5b1b4205 100644 --- a/plugins/kotlin/base/scripting/src/org/jetbrains/kotlin/idea/core/script/ucache/KotlinScriptLibraryEntity.kt +++ b/plugins/kotlin/base/scripting/src/org/jetbrains/kotlin/idea/core/script/ucache/KotlinScriptLibraryEntity.kt @@ -38,46 +38,46 @@ interface KotlinScriptLibraryEntity : WorkspaceEntityWithSymbolicId { override val symbolicId: KotlinScriptLibraryId get() = KotlinScriptLibraryId(name) - //region generated code - @GeneratedCodeApiVersion(3) - interface Builder : WorkspaceEntity.Builder { - override var entitySource: EntitySource - var name: String - var roots: MutableList - var indexSourceRoots: Boolean - var usedInScripts: MutableSet - } + //region generated code + @GeneratedCodeApiVersion(3) + interface Builder : WorkspaceEntity.Builder { + override var entitySource: EntitySource + var name: String + var roots: MutableList + var indexSourceRoots: Boolean + var usedInScripts: MutableSet + } - companion object : EntityType() { - @JvmOverloads - @JvmStatic - @JvmName("create") - operator fun invoke( - name: String, - roots: List, - indexSourceRoots: Boolean, - usedInScripts: Set, - entitySource: EntitySource, - init: (Builder.() -> Unit)? = null, - ): Builder { - val builder = builder() - builder.name = name - builder.roots = roots.toMutableWorkspaceList() - builder.indexSourceRoots = indexSourceRoots - builder.usedInScripts = usedInScripts.toMutableWorkspaceSet() - builder.entitySource = entitySource - init?.invoke(builder) - return builder - } + companion object : EntityType() { + @JvmOverloads + @JvmStatic + @JvmName("create") + operator fun invoke( + name: String, + roots: List, + indexSourceRoots: Boolean, + usedInScripts: Set, + entitySource: EntitySource, + init: (Builder.() -> Unit)? = null, + ): Builder { + val builder = builder() + builder.name = name + builder.roots = roots.toMutableWorkspaceList() + builder.indexSourceRoots = indexSourceRoots + builder.usedInScripts = usedInScripts.toMutableWorkspaceSet() + builder.entitySource = entitySource + init?.invoke(builder) + return builder } - //endregion + } + //endregion } //region generated code fun MutableEntityStorage.modifyKotlinScriptLibraryEntity( - entity: KotlinScriptLibraryEntity, - modification: KotlinScriptLibraryEntity.Builder.() -> Unit, + entity: KotlinScriptLibraryEntity, + modification: KotlinScriptLibraryEntity.Builder.() -> Unit, ): KotlinScriptLibraryEntity { - return modifyEntity(KotlinScriptLibraryEntity.Builder::class.java, entity, modification) + return modifyEntity(KotlinScriptLibraryEntity.Builder::class.java, entity, modification) } //endregion diff --git a/plugins/kotlin/compiler-plugins/assignment/common-k1/BUILD.bazel b/plugins/kotlin/compiler-plugins/assignment/common-k1/BUILD.bazel index 20fa42872d25..b32475f200eb 100644 --- a/plugins/kotlin/compiler-plugins/assignment/common-k1/BUILD.bazel +++ b/plugins/kotlin/compiler-plugins/assignment/common-k1/BUILD.bazel @@ -38,6 +38,7 @@ jvm_library( "//plugins/kotlin/code-insight/api", "//plugins/kotlin/base/fe10/analysis", "//platform/lang-impl", + "//plugins/kotlin/base/scripting.k1", ], runtime_deps = [":kotlin-compiler-plugins-assignment-common-k1_resources"] ) diff --git a/plugins/kotlin/compiler-plugins/assignment/common-k1/kotlin.compiler-plugins.assignment.common.k1.iml b/plugins/kotlin/compiler-plugins/assignment/common-k1/kotlin.compiler-plugins.assignment.common.k1.iml index 5dd76965d1e2..b1acab9c25e7 100644 --- a/plugins/kotlin/compiler-plugins/assignment/common-k1/kotlin.compiler-plugins.assignment.common.k1.iml +++ b/plugins/kotlin/compiler-plugins/assignment/common-k1/kotlin.compiler-plugins.assignment.common.k1.iml @@ -42,5 +42,6 @@ + \ No newline at end of file diff --git a/plugins/kotlin/compiler-plugins/assignment/common-k1/resources/kotlin.compiler-plugins.assignment.common.k1.xml b/plugins/kotlin/compiler-plugins/assignment/common-k1/resources/kotlin.compiler-plugins.assignment.common.k1.xml index 859881a3fd89..6b07bf644e67 100644 --- a/plugins/kotlin/compiler-plugins/assignment/common-k1/resources/kotlin.compiler-plugins.assignment.common.k1.xml +++ b/plugins/kotlin/compiler-plugins/assignment/common-k1/resources/kotlin.compiler-plugins.assignment.common.k1.xml @@ -1,4 +1,7 @@ + + + diff --git a/plugins/kotlin/compiler-plugins/assignment/common-k1/src/org/jetbrains/kotlin/idea/compilerPlugin/assignment/k1/IdeAssignmentContainerContributor.kt b/plugins/kotlin/compiler-plugins/assignment/common-k1/src/org/jetbrains/kotlin/idea/compilerPlugin/assignment/k1/IdeAssignmentContainerContributor.kt index b5c4a7876ff9..f94432d7b58e 100644 --- a/plugins/kotlin/compiler-plugins/assignment/common-k1/src/org/jetbrains/kotlin/idea/compilerPlugin/assignment/k1/IdeAssignmentContainerContributor.kt +++ b/plugins/kotlin/compiler-plugins/assignment/common-k1/src/org/jetbrains/kotlin/idea/compilerPlugin/assignment/k1/IdeAssignmentContainerContributor.kt @@ -11,8 +11,8 @@ import org.jetbrains.kotlin.container.useInstance import org.jetbrains.kotlin.descriptors.ModuleDescriptor import org.jetbrains.kotlin.extensions.StorageComponentContainerContributor import org.jetbrains.kotlin.idea.base.projectStructure.moduleInfo.ModuleProductionSourceInfo -import org.jetbrains.kotlin.idea.base.scripting.projectStructure.ScriptDependenciesInfo -import org.jetbrains.kotlin.idea.base.scripting.projectStructure.ScriptModuleInfo +import org.jetbrains.kotlin.idea.core.script.k1.modules.ScriptDependenciesInfo +import org.jetbrains.kotlin.idea.core.script.k1.modules.ScriptModuleInfo import org.jetbrains.kotlin.platform.TargetPlatform class IdeAssignmentContainerContributor(private val project: Project) : StorageComponentContainerContributor { diff --git a/plugins/kotlin/compiler-plugins/sam-with-receiver/common/BUILD.bazel b/plugins/kotlin/compiler-plugins/sam-with-receiver/common/BUILD.bazel index e04aa3dcfc5d..a6954a39bd1f 100644 --- a/plugins/kotlin/compiler-plugins/sam-with-receiver/common/BUILD.bazel +++ b/plugins/kotlin/compiler-plugins/sam-with-receiver/common/BUILD.bazel @@ -30,6 +30,7 @@ jvm_library( "//platform/util", "//plugins/kotlin/compiler-plugins/compiler-plugin-support/common", "//platform/core-api:core", + "//plugins/kotlin/base/scripting.k1", ] ) ### auto-generated section `build kotlin.compiler-plugins.sam-with-receiver.common` end \ No newline at end of file diff --git a/plugins/kotlin/compiler-plugins/sam-with-receiver/common/kotlin.compiler-plugins.sam-with-receiver.common.iml b/plugins/kotlin/compiler-plugins/sam-with-receiver/common/kotlin.compiler-plugins.sam-with-receiver.common.iml index 798f7d3f4ec1..7525beb66c9b 100644 --- a/plugins/kotlin/compiler-plugins/sam-with-receiver/common/kotlin.compiler-plugins.sam-with-receiver.common.iml +++ b/plugins/kotlin/compiler-plugins/sam-with-receiver/common/kotlin.compiler-plugins.sam-with-receiver.common.iml @@ -34,5 +34,6 @@ + \ No newline at end of file diff --git a/plugins/kotlin/compiler-plugins/sam-with-receiver/common/src/org/jetbrains/kotlin/idea/compilerPlugin/samWithReceiver/IdeSamWithReceiverComponentContributor.kt b/plugins/kotlin/compiler-plugins/sam-with-receiver/common/src/org/jetbrains/kotlin/idea/compilerPlugin/samWithReceiver/IdeSamWithReceiverComponentContributor.kt index 282b66833e63..94f7ae38ff26 100644 --- a/plugins/kotlin/compiler-plugins/sam-with-receiver/common/src/org/jetbrains/kotlin/idea/compilerPlugin/samWithReceiver/IdeSamWithReceiverComponentContributor.kt +++ b/plugins/kotlin/compiler-plugins/sam-with-receiver/common/src/org/jetbrains/kotlin/idea/compilerPlugin/samWithReceiver/IdeSamWithReceiverComponentContributor.kt @@ -15,9 +15,9 @@ import org.jetbrains.kotlin.container.useInstance import org.jetbrains.kotlin.descriptors.ModuleDescriptor import org.jetbrains.kotlin.extensions.StorageComponentContainerContributor import org.jetbrains.kotlin.idea.base.projectStructure.moduleInfo.ModuleProductionSourceInfo -import org.jetbrains.kotlin.idea.base.scripting.projectStructure.ScriptDependenciesInfo -import org.jetbrains.kotlin.idea.base.scripting.projectStructure.ScriptModuleInfo import org.jetbrains.kotlin.idea.compilerPlugin.getSpecialAnnotations +import org.jetbrains.kotlin.idea.core.script.k1.modules.ScriptDependenciesInfo +import org.jetbrains.kotlin.idea.core.script.k1.modules.ScriptModuleInfo import org.jetbrains.kotlin.platform.TargetPlatform import org.jetbrains.kotlin.platform.jvm.isJvm import org.jetbrains.kotlin.samWithReceiver.SamWithReceiverPluginNames.ANNOTATION_OPTION_NAME diff --git a/plugins/kotlin/idea/BUILD.bazel b/plugins/kotlin/idea/BUILD.bazel index eaaa4d4c205d..1492c47d5ea0 100644 --- a/plugins/kotlin/idea/BUILD.bazel +++ b/plugins/kotlin/idea/BUILD.bazel @@ -75,6 +75,7 @@ jvm_library( "//plugins/kotlin/base/platforms", "//plugins/kotlin/base/project-structure", "//plugins/kotlin/base/scripting", + "//plugins/kotlin/base/scripting.k1", "//platform/util/progress", "//plugins/kotlin/base/external-build-system", "//plugins/kotlin/base/analysis", diff --git a/plugins/kotlin/idea/kotlin.idea.iml b/plugins/kotlin/idea/kotlin.idea.iml index b92235bf7a69..28dd7a9ed50a 100644 --- a/plugins/kotlin/idea/kotlin.idea.iml +++ b/plugins/kotlin/idea/kotlin.idea.iml @@ -64,6 +64,7 @@ + diff --git a/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/imports/KotlinImportOptimizer.kt b/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/imports/KotlinImportOptimizer.kt index 237bca85041d..412150e58b4c 100644 --- a/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/imports/KotlinImportOptimizer.kt +++ b/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/imports/KotlinImportOptimizer.kt @@ -16,9 +16,9 @@ import org.jetbrains.kotlin.idea.base.projectStructure.languageVersionSettings import org.jetbrains.kotlin.idea.base.projectStructure.moduleInfo.ModuleSourceInfo import org.jetbrains.kotlin.idea.base.projectStructure.moduleInfoOrNull import org.jetbrains.kotlin.idea.base.resources.KotlinBundle -import org.jetbrains.kotlin.idea.base.scripting.projectStructure.ScriptModuleInfo import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade import org.jetbrains.kotlin.idea.caches.resolve.safeAnalyzeNonSourceRootCode +import org.jetbrains.kotlin.idea.core.script.k1.modules.ScriptModuleInfo import org.jetbrains.kotlin.idea.formatter.kotlinCustomSettings import org.jetbrains.kotlin.idea.references.* import org.jetbrains.kotlin.idea.util.getResolutionScope diff --git a/plugins/kotlin/idea/tests/BUILD.bazel b/plugins/kotlin/idea/tests/BUILD.bazel index 69c7c10905be..0b14da561567 100644 --- a/plugins/kotlin/idea/tests/BUILD.bazel +++ b/plugins/kotlin/idea/tests/BUILD.bazel @@ -175,6 +175,7 @@ jvm_library( "//plugins/kotlin/code-insight/live-templates-shared:kotlin-code-insight-live-templates-shared", "//plugins/kotlin/code-insight/live-templates-shared:kotlin-code-insight-live-templates-shared_test_lib", "//plugins/kotlin/jvm/k1", + "//plugins/kotlin/base/scripting.k1", ], runtime_deps = [ "//plugins/kotlin/gradle/gradle", diff --git a/plugins/kotlin/idea/tests/kotlin.idea.tests.iml b/plugins/kotlin/idea/tests/kotlin.idea.tests.iml index 35164bf152b9..ecea0e62a3ec 100644 --- a/plugins/kotlin/idea/tests/kotlin.idea.tests.iml +++ b/plugins/kotlin/idea/tests/kotlin.idea.tests.iml @@ -181,5 +181,6 @@ + \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/caches/resolve/IdeaModuleInfoTest.kt b/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/caches/resolve/IdeaModuleInfoTest.kt index 94489f1623f9..5c440c64b429 100644 --- a/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/caches/resolve/IdeaModuleInfoTest.kt +++ b/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/caches/resolve/IdeaModuleInfoTest.kt @@ -26,6 +26,7 @@ import com.intellij.testFramework.PsiTestUtil import com.intellij.testFramework.UsefulTestCase import com.intellij.util.ThrowableRunnable import com.intellij.util.ui.UIUtil +import org.jetbrains.kotlin.base.fe10.analysis.ResolutionAnchorCacheService import org.jetbrains.kotlin.base.fe10.analysis.ResolutionAnchorCacheServiceImpl import org.jetbrains.kotlin.idea.base.platforms.KotlinCommonLibraryKind import org.jetbrains.kotlin.idea.base.platforms.KotlinJavaScriptLibraryKind @@ -33,15 +34,13 @@ import org.jetbrains.kotlin.idea.base.platforms.KotlinWasmJsLibraryKind import org.jetbrains.kotlin.idea.base.platforms.KotlinWasmWasiLibraryKind import org.jetbrains.kotlin.idea.base.plugin.artifacts.TestKotlinArtifacts import org.jetbrains.kotlin.idea.base.projectStructure.* -import org.jetbrains.kotlin.base.fe10.analysis.ResolutionAnchorCacheService import org.jetbrains.kotlin.idea.base.projectStructure.libraryToSourceAnalysis.withLibraryToSourceAnalysis import org.jetbrains.kotlin.idea.base.projectStructure.moduleInfo.* -import org.jetbrains.kotlin.idea.base.projectStructure.moduleInfo.ModuleTestSourceInfo -import org.jetbrains.kotlin.idea.base.scripting.projectStructure.ScriptDependenciesInfo import org.jetbrains.kotlin.idea.caches.project.getDependentModules import org.jetbrains.kotlin.idea.caches.project.getIdeaModelInfosCache import org.jetbrains.kotlin.idea.caches.project.getModuleInfosFromIdeaModel import org.jetbrains.kotlin.idea.core.script.ScriptConfigurationManager.Companion.updateScriptDependenciesSynchronously +import org.jetbrains.kotlin.idea.core.script.k1.modules.ScriptDependenciesInfo import org.jetbrains.kotlin.idea.framework.KotlinSdkType import org.jetbrains.kotlin.idea.test.KotlinTestUtils.allowProjectRootAccess import org.jetbrains.kotlin.idea.test.KotlinTestUtils.disposeVfsRootAccess diff --git a/plugins/kotlin/intellij.kotlin.plugin.community.main.iml b/plugins/kotlin/intellij.kotlin.plugin.community.main.iml index 903295f08012..186404066297 100644 --- a/plugins/kotlin/intellij.kotlin.plugin.community.main.iml +++ b/plugins/kotlin/intellij.kotlin.plugin.community.main.iml @@ -22,6 +22,7 @@ + diff --git a/plugins/kotlin/plugin/common/resources/META-INF/scripting-base.xml b/plugins/kotlin/plugin/common/resources/META-INF/scripting-base.xml index 3f15048f9f4c..a1e74b625104 100644 --- a/plugins/kotlin/plugin/common/resources/META-INF/scripting-base.xml +++ b/plugins/kotlin/plugin/common/resources/META-INF/scripting-base.xml @@ -46,8 +46,6 @@ - - diff --git a/plugins/kotlin/plugin/k1/BUILD.bazel b/plugins/kotlin/plugin/k1/BUILD.bazel index 6cd9676b1ca6..16dc9e40e73b 100644 --- a/plugins/kotlin/plugin/k1/BUILD.bazel +++ b/plugins/kotlin/plugin/k1/BUILD.bazel @@ -31,6 +31,7 @@ java_library( "//plugins/kotlin/base/platforms", "//plugins/kotlin/base/project-structure", "//plugins/kotlin/base/scripting", + "//plugins/kotlin/base/scripting.k1", "//plugins/kotlin/base/analysis", "//plugins/kotlin/base/analysis-api-platform", "//plugins/kotlin/base/facet", diff --git a/plugins/kotlin/plugin/k1/kotlin.plugin.k1.iml b/plugins/kotlin/plugin/k1/kotlin.plugin.k1.iml index 524ec9f57a40..04fd47c04d98 100644 --- a/plugins/kotlin/plugin/k1/kotlin.plugin.k1.iml +++ b/plugins/kotlin/plugin/k1/kotlin.plugin.k1.iml @@ -25,6 +25,7 @@ + diff --git a/plugins/kotlin/plugin/k1/resources/META-INF/scripting-k1.xml b/plugins/kotlin/plugin/k1/resources/META-INF/scripting-k1.xml index 307d23623be2..54ecb6c31d39 100644 --- a/plugins/kotlin/plugin/k1/resources/META-INF/scripting-k1.xml +++ b/plugins/kotlin/plugin/k1/resources/META-INF/scripting-k1.xml @@ -80,10 +80,6 @@ order="last" implementation="org.jetbrains.kotlin.idea.core.script.BundledScriptDefinitionSource"/> - - - - diff --git a/plugins/kotlin/plugin/k1/resources/kotlin.plugin.k1.xml b/plugins/kotlin/plugin/k1/resources/kotlin.plugin.k1.xml index 2223af7df2f6..2135d1bf306e 100644 --- a/plugins/kotlin/plugin/k1/resources/kotlin.plugin.k1.xml +++ b/plugins/kotlin/plugin/k1/resources/kotlin.plugin.k1.xml @@ -121,5 +121,7 @@ + + \ No newline at end of file diff --git a/plugins/kotlin/plugin/plugin-content.yaml b/plugins/kotlin/plugin/plugin-content.yaml index a80d2aa2aead..8740f62dbc6d 100644 --- a/plugins/kotlin/plugin/plugin-content.yaml +++ b/plugins/kotlin/plugin/plugin-content.yaml @@ -106,6 +106,7 @@ - name: kotlin.base.project-structure - name: kotlin.base.external-build-system - name: kotlin.base.scripting + - name: kotlin.base.scripting.k1 - name: kotlin.base.scripting.k2 - name: kotlin.base.analysis-api-platform - name: kotlin.base.analysis