From e0bc54cd82e85504f46e09ee5ff05aa2e5883193 Mon Sep 17 00:00:00 2001 From: Natalia Selezneva Date: Tue, 7 Jul 2020 22:49:16 +0300 Subject: [PATCH] gradle.kts: update notification messages after proofreading --- .../KotlinIdeaGradleBundle.properties | 74 +++++++++++-------- .../scripting/gradle/GradleImportHelper.kt | 2 + .../gradle/GradleImportHelper.kt.193 | 2 + .../GradleScriptNotificationProvider.kt | 22 ++++-- .../gradle/roots/GradleBuildRootsLocator.kt | 8 +- 5 files changed, 71 insertions(+), 37 deletions(-) diff --git a/idea/idea-gradle/res/messages/KotlinIdeaGradleBundle.properties b/idea/idea-gradle/res/messages/KotlinIdeaGradleBundle.properties index d5725b6c359..08bfd414a74 100644 --- a/idea/idea-gradle/res/messages/KotlinIdeaGradleBundle.properties +++ b/idea/idea-gradle/res/messages/KotlinIdeaGradleBundle.properties @@ -1,40 +1,56 @@ -notification.oldGradle.firstLoad=Code insight is disabled to avoid Gradle build configuration -notification.oldGradle.firstLoad.info=
\ -

The Gradle configuration phase is required to be run to get the Script Configuration \ - It is disabled by default since it can be expensive for large Gradle projects.

\ -
\ -

Click "Load Configuration" to evaluate Gradle build scripts.

\ -
\ -

Alternatively, you can "Enable auto-reload" for all files to automatically load \ - configuration on the first opening and reload it on each change of build script configuration blocks. \ - This option is not recommended for a big Gradle project with a long configuration time.

\ +gradle.script.configurations.importing.feature=Load Gradle Kotlin DSL script configurations during Gradle project import +notification.gradle.legacy.firstLoad=Code insight is disabled to avoid the Gradle build configuration. +notification.gradle.legacy.firstLoad.info=

The Gradle configuration phase needs to be run to get the Script Configuration. \ +Loading the script configuration is disabled by default, since it can be resource-intensive for large Gradle projects.

\ +

Click "Load Configuration" to evaluate the Gradle Kotlin DSL script.

\ +

Alternatively, to automatically load the configuration when the script first opens \ +and reload it each time build script configuration blocks are changed, you can enable "auto-reload" for all scripts. \ +This option is not recommended for large Gradle projects with long configuration times.

\ +
+notification.gradle.legacy.outsideProject=Code insight unavailable (related Gradle project not linked). +notification.gradle.legacy.outsideProject.addToStandaloneHelp=
\ +

The Gradle project that evaluates this script needs to be imported to have it analyzed by the IDE. \ + Try re-importing the linked Gradle project or link a new Gradle project that evaluates this script.

\ +

Alternatively, you can add it to standalone scripts, and its configuration will be loaded automatically.

\ +

NOTE: Each standalone script requires a separate Gradle configuration phase to be executed on update. \ + This can be resource intensive for large Gradle projects.

\
-gradle.script.configurations.importing.feature=Load gradle kotlin scripts configuration from project importing -notification.outsideAnything.text=Code insight unavailable (related Gradle project not linked) +notification.gradle.legacy.standalone.info=
\ +

The Gradle project that evaluates this script isn't imported in IDE. \ +
\ +

NOTE: Each standalone script requires a separate Gradle configuration phase to be executed on update. \ + This can be resource intensive for large Gradle projects.

\ +
+notification.outsideAnything.text=Code insight unavailable (related Gradle project not linked). notification.outsideAnything.linkAction=Link Gradle project -notification.wasNotImportedAfterCreation.text=Code insight unavailable (Gradle project not imported) +notification.wasNotImportedAfterCreation.193.text=Code insight unavailable (Gradle project not imported). +notification.wasNotImportedAfterCreation.text=Code insight unavailable (Script Configurations not loaded). +notification.wasNotImportedAfterCreation.help=
\ +

The Gradle Kotlin DSL script configurations are missing. \ + Import the external Gradle project or load the configurations \ + to get script code insight.

\ +
action.label.import.project=Import Project action.text.load.script.configurations=Load Script Configurations -action.description.load.script.configurations=Gradle Kotlin DSL script configuration has been changed. Load changes to get script code insight without loading the external Gradle project. +action.description.load.script.configurations=The Gradle Kotlin DSL script configuration has been changed. Load the changes to get code insight without importing the external Gradle project. action.label.enable.auto.import=Enable Auto-Import -notification.notEvaluatedInLastImport.text=Code insight unavailable (configuration for this script wasn't received during last import) -notification.notEvaluatedInLastImport.addAsStandaloneAction=Add as standalone script +notification.notEvaluatedInLastImport.text=Code insight unavailable (configuration for this script wasn't received during the last Gradle project import). +notification.notEvaluatedInLastImport.addAsStandaloneAction=Add to standalone scripts notification.notEvaluatedInLastImport.info=
\ -

The Gradle project that evaluates this script needs to be imported to get it analyzed by the IDE.\ -Try reimport linked Gradle project or link a new Gradle project that evaluates this script.

\ -
\ -

Alternatively, you can mark this script as standalone and its configuration will be loaded separately.

\ -
\ -

NOTE: Each standalone script requires separate Gradle configuration phase to be executed on update. \ -This can be expensive for large Gradle projects.

\ -
+

The Gradle project that evaluates this script needs to be imported to have it analyzed by the IDE. \ + Try re-importing the linked Gradle project or link a new Gradle project that evaluates this script.

\ +

Alternatively, you can add it to standalone scripts, and its configuration will be loaded separately.

\ +

NOTE: Each standalone script requires a separate Gradle configuration phase to be executed on update. \ + This can be resource intensive for large Gradle projects.

\ +
notification.standalone.text=Standalone script -notification.standalone.disableScriptAction=Disable script +notification.standalone.disableScriptAction=Remove from standalone scripts notification.standalone.info=
\ -

Configuration for this script will be loaded separately from Gradle project Sync. \ -
\ -

This can be expensive for large Gradle projects.

\ -
+

The configuration for this script will be loaded separately from Gradle project sync.\ +
\ +

NOTE: Each standalone script requires a separate Gradle configuration phase to be executed on update. \ + This can be resource intensive for large Gradle projects.

\ + action.text.install=Install action.text.show.kotlin.gradle.dsl.logs.in=Show Kotlin Gradle DSL Logs in {0} build.0.project=Build {0} diff --git a/idea/idea-gradle/src/org/jetbrains/kotlin/idea/scripting/gradle/GradleImportHelper.kt b/idea/idea-gradle/src/org/jetbrains/kotlin/idea/scripting/gradle/GradleImportHelper.kt index 96a50e237ff..a5d2b062500 100644 --- a/idea/idea-gradle/src/org/jetbrains/kotlin/idea/scripting/gradle/GradleImportHelper.kt +++ b/idea/idea-gradle/src/org/jetbrains/kotlin/idea/scripting/gradle/GradleImportHelper.kt @@ -53,7 +53,9 @@ fun runPartialGradleImport(project: Project, root: GradleBuildRoot) { ) } +fun getMissingConfigurationsDescription() = KotlinIdeaGradleBundle.message("notification.wasNotImportedAfterCreation.text") fun getMissingConfigurationActionText() = KotlinIdeaGradleBundle.message("action.text.load.script.configurations") +fun getMissingConfigurationsHelp(): String? = KotlinIdeaGradleBundle.message("notification.wasNotImportedAfterCreation.help") fun autoReloadScriptConfigurations(project: Project, file: VirtualFile): Boolean { val definition = file.findScriptDefinition(project) ?: return false diff --git a/idea/idea-gradle/src/org/jetbrains/kotlin/idea/scripting/gradle/GradleImportHelper.kt.193 b/idea/idea-gradle/src/org/jetbrains/kotlin/idea/scripting/gradle/GradleImportHelper.kt.193 index 472e342dfef..ed399de8d81 100644 --- a/idea/idea-gradle/src/org/jetbrains/kotlin/idea/scripting/gradle/GradleImportHelper.kt.193 +++ b/idea/idea-gradle/src/org/jetbrains/kotlin/idea/scripting/gradle/GradleImportHelper.kt.193 @@ -49,7 +49,9 @@ fun runPartialGradleImport(project: Project, root: GradleBuildRoot) { ) } +fun getMissingConfigurationsDescription() = KotlinIdeaGradleBundle.message("notification.wasNotImportedAfterCreation.193.text") fun getMissingConfigurationActionText() = KotlinIdeaGradleBundle.message("action.label.import.project") +fun getMissingConfigurationsHelp(): String? = null fun autoReloadScriptConfigurations(project: Project, root: GradleBuildRoot): Boolean { return ExternalSystemApiUtil diff --git a/idea/idea-gradle/src/org/jetbrains/kotlin/idea/scripting/gradle/GradleScriptNotificationProvider.kt b/idea/idea-gradle/src/org/jetbrains/kotlin/idea/scripting/gradle/GradleScriptNotificationProvider.kt index a617bd471b7..1adb48e4bac 100644 --- a/idea/idea-gradle/src/org/jetbrains/kotlin/idea/scripting/gradle/GradleScriptNotificationProvider.kt +++ b/idea/idea-gradle/src/org/jetbrains/kotlin/idea/scripting/gradle/GradleScriptNotificationProvider.kt @@ -66,11 +66,11 @@ class GradleScriptNotificationProvider(private val project: Project) : if (actions == null) null else { object : EditorNotificationPanel() { - val contextHelp = KotlinIdeaGradleBundle.message("notification.oldGradle.firstLoad.info") + val contextHelp = KotlinIdeaGradleBundle.message("notification.gradle.legacy.firstLoad.info") init { if (actions.isFirstLoad) { - text(KotlinIdeaGradleBundle.message("notification.oldGradle.firstLoad")) + text(KotlinIdeaGradleBundle.message("notification.gradle.legacy.firstLoad")) toolTipText = contextHelp } else { text(KotlinIdeaCoreBundle.message("notification.text.script.configuration.has.been.changed")) @@ -92,12 +92,13 @@ class GradleScriptNotificationProvider(private val project: Project) : } } legacyOutside -> EditorNotificationPanel().apply { - text("Out of project script") + text(KotlinIdeaGradleBundle.message("notification.gradle.legacy.outsideProject")) createActionLabel(KotlinIdeaGradleBundle.message("notification.notEvaluatedInLastImport.addAsStandaloneAction")) { rootsManager.updateStandaloneScripts { addStandaloneScript(file.path) } } + contextHelp(KotlinIdeaGradleBundle.message("notification.gradle.legacy.outsideProject.addToStandaloneHelp")) } outsideAnything -> EditorNotificationPanel().apply { text(KotlinIdeaGradleBundle.message("notification.outsideAnything.text")) @@ -106,13 +107,17 @@ class GradleScriptNotificationProvider(private val project: Project) : } } wasNotImportedAfterCreation -> EditorNotificationPanel().apply { - text(KotlinIdeaGradleBundle.message("notification.wasNotImportedAfterCreation.text")) + text(getMissingConfigurationsDescription()) createActionLabel(getMissingConfigurationActionText()) { val root = scriptUnderRoot.nearest if (root != null) { runPartialGradleImport(project, root) } } + val help = getMissingConfigurationsHelp() + if (help != null) { + contextHelp(help) + } } notEvaluatedInLastImport -> EditorNotificationPanel().apply { text(KotlinIdeaGradleBundle.message("notification.notEvaluatedInLastImport.text")) @@ -128,7 +133,7 @@ class GradleScriptNotificationProvider(private val project: Project) : contextHelp(KotlinIdeaGradleBundle.message("notification.notEvaluatedInLastImport.info")) } - standalone -> EditorNotificationPanel().apply { + standalone, standaloneLegacy -> EditorNotificationPanel().apply { val actions = standaloneScriptActions[file] if (actions != null) { text( @@ -153,7 +158,12 @@ class GradleScriptNotificationProvider(private val project: Project) : removeStandaloneScript(file.path) } } - contextHelp(KotlinIdeaGradleBundle.message("notification.standalone.info")) + + if (scriptUnderRoot.notificationKind == standaloneLegacy) { + contextHelp(KotlinIdeaGradleBundle.message("notification.gradle.legacy.standalone.info")) + } else { + contextHelp(KotlinIdeaGradleBundle.message("notification.standalone.info")) + } } } } diff --git a/idea/idea-gradle/src/org/jetbrains/kotlin/idea/scripting/gradle/roots/GradleBuildRootsLocator.kt b/idea/idea-gradle/src/org/jetbrains/kotlin/idea/scripting/gradle/roots/GradleBuildRootsLocator.kt index 6561bfa55d9..5c67eb2f3c3 100644 --- a/idea/idea-gradle/src/org/jetbrains/kotlin/idea/scripting/gradle/roots/GradleBuildRootsLocator.kt +++ b/idea/idea-gradle/src/org/jetbrains/kotlin/idea/scripting/gradle/roots/GradleBuildRootsLocator.kt @@ -69,7 +69,8 @@ abstract class GradleBuildRootsLocator { outsideAnything, // suggest link related gradle build or just say that there is no one wasNotImportedAfterCreation, // project not yet imported after this file was created notEvaluatedInLastImport, // all other scripts, suggest to sync or mark as standalone - standalone + standalone, + standaloneLegacy } /** @@ -88,7 +89,10 @@ abstract class GradleBuildRootsLocator { val notificationKind: NotificationKind get() = when { isImported -> NotificationKind.dontCare - standalone -> NotificationKind.standalone + standalone -> when (nearest) { + is Legacy -> NotificationKind.standaloneLegacy + else -> NotificationKind.standalone + } nearest == null -> NotificationKind.outsideAnything importing -> NotificationKind.dontCare else -> when (nearest) {