gradle.kts: remove useless gradle build root kinds

This commit is contained in:
Sergey Rostov
2020-04-30 23:38:13 +03:00
parent aca1771619
commit 4de1381649
3 changed files with 29 additions and 10 deletions
@@ -25,23 +25,43 @@ import kotlin.script.experimental.jvm.jvm
sealed class GradleBuildRoot {
abstract val pathPrefix: String
abstract class Unlinked : GradleBuildRoot()
class UnlinkedUnknown(override val pathPrefix: String) : Unlinked()
class UnlinkedLegacy(override val pathPrefix: String) : Unlinked()
class UnlinkedSupported(override val pathPrefix: String) : Unlinked()
/**
* Add Gradle Project
* for other scripts too
*
* definitely not precompiled scripts (it is detected as in sources roots)
* may be also included scripts not returned by gradle: todo proper notification
*/
class Unlinked(override val pathPrefix: String) : GradleBuildRoot()
abstract class Linked : GradleBuildRoot() {
@Volatile
var importing = false
}
/**
* Notification: please update to Gradle 6.0
* default loader, cases:
* - not loaded: todo: Notification: Load configration to get code insights
* - loaded, not up-to-date: Notifaction: Reload configuraiton
* - loaded, up-to-date: Nothing
*/
class Legacy(override val pathPrefix: String) : Linked()
/**
* not imported:
* Notification: Import Gradle project to get code insights
* during import:
* - todo: disable action on importing. don't miss failed import
* - pause analyzing, todo: change status text to: importing gradle project
*
* todo:
* detect precompiled scripts (in sources roots)
*/
class New(override val pathPrefix: String) : Linked()
// precompiled scripts not detected by gradle
class Imported(
val project: Project,
val dir: VirtualFile,
@@ -48,7 +48,6 @@ class GradleScriptingSupportProvider(val project: Project) : ScriptingSupport.Pr
override fun isApplicable(file: VirtualFile): Boolean {
val buildRoot = findScriptBuildRoot(file) ?: return false
if (buildRoot is GradleBuildRoot.Legacy) return false
if (buildRoot is GradleBuildRoot.UnlinkedLegacy) return false
return true
}
@@ -130,7 +129,7 @@ class GradleScriptingSupportProvider(val project: Project) : ScriptingSupport.Pr
}
private fun detectUnlinkedGradleBuildRoot(file: String): GradleBuildRoot.Unlinked =
GradleBuildRoot.UnlinkedUnknown(file)
GradleBuildRoot.Unlinked(file)
init {
getGradleProjectSettings(project).forEach {
@@ -29,7 +29,7 @@ class MissingGradleScriptConfigurationNotificationProvider(private val project:
if (file.fileType != KotlinFileType.INSTANCE) return null
return when (GradleScriptingSupportProvider.getInstance(project).findScriptBuildRoot(file)) {
is GradleBuildRoot.UnlinkedSupported -> EditorNotificationPanel().apply {
is GradleBuildRoot.Unlinked -> EditorNotificationPanel().apply {
text(KotlinIdeaGradleBundle.message("text.the.associated.gradle.project.isn.t.imported"))
val linkProjectText = KotlinIdeaGradleBundle.message("action.label.text.load.script.configuration")