gradle.kts legacy: out of project script notification

This commit is contained in:
Sergey Rostov
2020-06-16 19:01:27 +03:00
parent cc95c16ac2
commit 64b1cc7fd4
4 changed files with 19 additions and 12 deletions
@@ -30,6 +30,14 @@ class GradleScriptNotificationProvider(private val project: Project) :
val scriptUnderRoot = rootsManager.findScriptBuildRoot(file) ?: return null
return when (scriptUnderRoot.notificationKind) {
dontCare -> null
legacyOutside -> EditorNotificationPanel().apply {
text("Out of project script")
createActionLabel(KotlinIdeaGradleBundle.message("notification.notEvaluatedInLastImport.addAsStandaloneAction")) {
rootsManager.updateStandaloneScripts {
addStandaloneScript(file.path)
}
}
}
outsideAnything -> EditorNotificationPanel().apply {
text(KotlinIdeaGradleBundle.message("notification.outsideAnything.text"))
createActionLabel(KotlinIdeaGradleBundle.message("notification.outsideAnything.linkAction")) {
@@ -89,7 +89,10 @@ abstract class GradleBuildRootsLocator {
nearest == null -> NotificationKind.outsideAnything
importing -> NotificationKind.dontCare
else -> when (nearest) {
is Legacy -> NotificationKind.dontCare
is Legacy -> when {
root == null -> NotificationKind.legacyOutside
else -> NotificationKind.dontCare
}
is New -> NotificationKind.wasNotImportedAfterCreation
is Imported -> when {
wasImportedAndNotEvaluated -> NotificationKind.notEvaluatedInLastImport
@@ -141,14 +144,10 @@ abstract class GradleBuildRootsLocator {
return ScriptUnderRoot(filePath, standaloneScriptRoot, standalone = true)
}
if (searchNearestLegacy) {
val nearest = roots.findNearestRoot(filePath)
return when (nearest) {
is Legacy -> ScriptUnderRoot(filePath, nearest)
else -> ScriptUnderRoot(filePath, null, nearest = nearest)
}
} else {
return ScriptUnderRoot(filePath, null)
}
val nearest =
if (searchNearestLegacy) roots.findNearestRoot(filePath)
else null
return ScriptUnderRoot(filePath, null, nearest = nearest)
}
}
@@ -83,7 +83,7 @@ class GradleBuildRootsManager(val project: Project) : GradleBuildRootsLocator(),
override fun isApplicable(file: VirtualFile): Boolean {
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
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)
} else null
}