gradle.kts legacy: out of project script notification
This commit is contained in:
+8
@@ -30,6 +30,14 @@ class GradleScriptNotificationProvider(private val project: Project) :
|
|||||||
val scriptUnderRoot = rootsManager.findScriptBuildRoot(file) ?: return null
|
val scriptUnderRoot = rootsManager.findScriptBuildRoot(file) ?: return null
|
||||||
return when (scriptUnderRoot.notificationKind) {
|
return when (scriptUnderRoot.notificationKind) {
|
||||||
dontCare -> null
|
dontCare -> null
|
||||||
|
legacyOutside -> EditorNotificationPanel().apply {
|
||||||
|
text("Out of project script")
|
||||||
|
createActionLabel(KotlinIdeaGradleBundle.message("notification.notEvaluatedInLastImport.addAsStandaloneAction")) {
|
||||||
|
rootsManager.updateStandaloneScripts {
|
||||||
|
addStandaloneScript(file.path)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
outsideAnything -> EditorNotificationPanel().apply {
|
outsideAnything -> EditorNotificationPanel().apply {
|
||||||
text(KotlinIdeaGradleBundle.message("notification.outsideAnything.text"))
|
text(KotlinIdeaGradleBundle.message("notification.outsideAnything.text"))
|
||||||
createActionLabel(KotlinIdeaGradleBundle.message("notification.outsideAnything.linkAction")) {
|
createActionLabel(KotlinIdeaGradleBundle.message("notification.outsideAnything.linkAction")) {
|
||||||
|
|||||||
+9
-10
@@ -89,7 +89,10 @@ abstract class GradleBuildRootsLocator {
|
|||||||
nearest == null -> NotificationKind.outsideAnything
|
nearest == null -> NotificationKind.outsideAnything
|
||||||
importing -> NotificationKind.dontCare
|
importing -> NotificationKind.dontCare
|
||||||
else -> when (nearest) {
|
else -> when (nearest) {
|
||||||
is Legacy -> NotificationKind.dontCare
|
is Legacy -> when {
|
||||||
|
root == null -> NotificationKind.legacyOutside
|
||||||
|
else -> NotificationKind.dontCare
|
||||||
|
}
|
||||||
is New -> NotificationKind.wasNotImportedAfterCreation
|
is New -> NotificationKind.wasNotImportedAfterCreation
|
||||||
is Imported -> when {
|
is Imported -> when {
|
||||||
wasImportedAndNotEvaluated -> NotificationKind.notEvaluatedInLastImport
|
wasImportedAndNotEvaluated -> NotificationKind.notEvaluatedInLastImport
|
||||||
@@ -141,14 +144,10 @@ abstract class GradleBuildRootsLocator {
|
|||||||
return ScriptUnderRoot(filePath, standaloneScriptRoot, standalone = true)
|
return ScriptUnderRoot(filePath, standaloneScriptRoot, standalone = true)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (searchNearestLegacy) {
|
val nearest =
|
||||||
val nearest = roots.findNearestRoot(filePath)
|
if (searchNearestLegacy) roots.findNearestRoot(filePath)
|
||||||
return when (nearest) {
|
else null
|
||||||
is Legacy -> ScriptUnderRoot(filePath, nearest)
|
|
||||||
else -> ScriptUnderRoot(filePath, null, nearest = nearest)
|
return ScriptUnderRoot(filePath, null, nearest = nearest)
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return ScriptUnderRoot(filePath, null)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+1
-1
@@ -83,7 +83,7 @@ class GradleBuildRootsManager(val project: Project) : GradleBuildRootsLocator(),
|
|||||||
|
|
||||||
override fun isApplicable(file: VirtualFile): Boolean {
|
override fun isApplicable(file: VirtualFile): Boolean {
|
||||||
val scriptUnderRoot = findScriptBuildRoot(file) ?: return false
|
val scriptUnderRoot = findScriptBuildRoot(file) ?: return false
|
||||||
if (scriptUnderRoot.root is Legacy) return false
|
if (scriptUnderRoot.nearest is Legacy) return false
|
||||||
if (roots.isStandaloneScript(file.path)) return false
|
if (roots.isStandaloneScript(file.path)) return false
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ fun getGradleScriptInputsStamp(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val buildRoot = GradleBuildRootsManager.getInstance(project).findScriptBuildRoot(file)?.root as? GradleBuildRoot
|
val buildRoot = GradleBuildRootsManager.getInstance(project).findScriptBuildRoot(file)?.nearest as? GradleBuildRoot
|
||||||
GradleKotlinScriptConfigurationInputs(result.toString(), givenTimeStamp, buildRoot?.pathPrefix)
|
GradleKotlinScriptConfigurationInputs(result.toString(), givenTimeStamp, buildRoot?.pathPrefix)
|
||||||
} else null
|
} else null
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user