diff --git a/idea/idea-gradle/res/messages/KotlinIdeaGradleBundle.properties b/idea/idea-gradle/res/messages/KotlinIdeaGradleBundle.properties
index b9ad76dfa70..9ccfb3dfaf4 100644
--- a/idea/idea-gradle/res/messages/KotlinIdeaGradleBundle.properties
+++ b/idea/idea-gradle/res/messages/KotlinIdeaGradleBundle.properties
@@ -1,4 +1,4 @@
-action.label.text.load.script.configuration=Load script configuration
+action.label.text.load.script.configuration=Load related Gradle project
action.text.install=Install
action.text.show.kotlin.gradle.dsl.logs.in=Show Kotlin Gradle DSL Logs in {0}
build.0.project=Build {0}
@@ -42,7 +42,7 @@ text.was.modified={0} was modified
title.configure.kotlin.gradle.plugin=Configure Kotlin-Gradle Plugin
title.kotlin.build.script=Gradle Kotlin DSL Scripts errors
title.update.language.version=Update Language Version
-tool.tip.text.the.external.gradle.project.needs.to.be.imported.to.get.this.script.analyzed=The external Gradle project needs to be imported to get this script analyzed.
You can import the related Gradle project or click "{0}" to get code insight without importing.
+tool.tip.text.the.external.gradle.project.needs.to.be.imported.to.get.this.script.analyzed=The external Gradle project needs to be imported to get this script analyzed.
Load related Gradle project to add it to the list of imported Gradle Projects.
display.name.kotlin.multiplatform=Kotlin/Multiplatform
display.name.kotlin.jvm=Kotlin/JVM
display.name.kotlin.js.for.node.js=Kotlin/JS for Node.js
diff --git a/idea/idea-gradle/src/org/jetbrains/kotlin/idea/scripting/gradle/GradleScriptOutOfSourceNotificationProvider.kt b/idea/idea-gradle/src/org/jetbrains/kotlin/idea/scripting/gradle/GradleScriptOutOfSourceNotificationProvider.kt
index d3bbae5e4a2..072065b7ea4 100644
--- a/idea/idea-gradle/src/org/jetbrains/kotlin/idea/scripting/gradle/GradleScriptOutOfSourceNotificationProvider.kt
+++ b/idea/idea-gradle/src/org/jetbrains/kotlin/idea/scripting/gradle/GradleScriptOutOfSourceNotificationProvider.kt
@@ -6,6 +6,8 @@
package org.jetbrains.kotlin.idea.scripting.gradle
import com.intellij.icons.AllIcons
+import com.intellij.openapi.externalSystem.service.execution.ProgressExecutionMode
+import com.intellij.openapi.externalSystem.util.ExternalSystemUtil
import com.intellij.openapi.fileEditor.FileEditor
import com.intellij.openapi.project.Project
import com.intellij.openapi.util.Key
@@ -14,7 +16,8 @@ import com.intellij.ui.EditorNotificationPanel
import com.intellij.ui.EditorNotifications
import org.jetbrains.kotlin.idea.KotlinFileType
import org.jetbrains.kotlin.idea.KotlinIdeaGradleBundle
-import org.jetbrains.kotlin.idea.core.script.ScriptConfigurationManager
+import org.jetbrains.plugins.gradle.settings.GradleProjectSettings
+import org.jetbrains.plugins.gradle.util.GradleConstants
class GradleScriptOutOfSourceNotificationProvider(private val project: Project) : EditorNotifications.Provider() {
override fun getKey(): Key = KEY
@@ -26,16 +29,28 @@ class GradleScriptOutOfSourceNotificationProvider(private val project: Project)
if (!isInAffectedGradleProjectFiles(project, file.path)) {
return EditorNotificationPanel().apply {
text(KotlinIdeaGradleBundle.message("text.the.associated.gradle.project.isn.t.imported"))
- val loadScriptConfigurationText = KotlinIdeaGradleBundle.message("action.label.text.load.script.configuration")
- createActionLabel(loadScriptConfigurationText) {
- ScriptConfigurationManager.getInstance(project).forceReloadConfiguration(file, loaderForOutOfProjectScripts)
+
+ val linkProjectText = KotlinIdeaGradleBundle.message("action.label.text.load.script.configuration")
+ createActionLabel(linkProjectText) {
+ val newProjectSettings = GradleProjectSettings()
+ newProjectSettings.externalProjectPath = file.parent.path
+ ExternalSystemUtil.linkExternalProject(
+ GradleConstants.SYSTEM_ID,
+ newProjectSettings,
+ project,
+ {
+
+ },
+ false,
+ ProgressExecutionMode.IN_BACKGROUND_ASYNC
+ )
}
val link = createActionLabel("") {}
link.setIcon(AllIcons.General.ContextHelp)
link.setUseIconAsLink(true)
link.toolTipText = KotlinIdeaGradleBundle.message(
"tool.tip.text.the.external.gradle.project.needs.to.be.imported.to.get.this.script.analyzed",
- loadScriptConfigurationText
+ linkProjectText
)
}
}