gradle.kts standalone scripts: show actions inside single notification

This commit is contained in:
Sergey Rostov
2020-06-16 19:35:08 +03:00
parent 64b1cc7fd4
commit 3d86e92bf5
7 changed files with 121 additions and 17 deletions
@@ -175,14 +175,15 @@ class DefaultScriptingSupport(manager: CompositeScriptConfigurationManager) : De
loaders.firstOrNull { it.loadDependencies(isFirstLoad, file, scriptDefinition, loadingContext) }
} else {
val autoReloadEnabled = KotlinScriptingSettings.getInstance(project).autoReloadConfigurations(scriptDefinition)
val postponeLoading = !skipNotification && !autoReloadEnabled && async.any { it.isPostponedLoad(virtualFile) }
val forceSkipNotification = skipNotification || autoReloadEnabled || postponeLoading
val forceSkipNotification = skipNotification || autoReloadEnabled
if (postponeLoading) {
LoadScriptConfigurationNotificationFactory.showNotification(virtualFile, project) {
runAsyncLoaders(file, virtualFile, scriptDefinition, async, forceSkipNotification)
val intercepted = !forceSkipNotification && async.any {
it.interceptBackgroundLoading(virtualFile) {
runAsyncLoaders(file, virtualFile, scriptDefinition, listOf(it), true)
}
} else {
}
if (!intercepted) {
runAsyncLoaders(file, virtualFile, scriptDefinition, async, forceSkipNotification)
}
}
@@ -15,15 +15,10 @@ import org.jetbrains.kotlin.scripting.definitions.ScriptDefinition
* @see [org.jetbrains.kotlin.idea.core.script.configuration.DefaultScriptConfigurationManager] for more details.
*/
interface ScriptConfigurationLoader {
/**
* Show notification before doing load
*
* (by default loading notification will be shown only after loading, to check that configuration is changed)
*/
fun isPostponedLoad(virtualFile: VirtualFile): Boolean = false
fun shouldRunInBackground(scriptDefinition: ScriptDefinition): Boolean = false
fun interceptBackgroundLoading(file: VirtualFile, doLoad: () -> Unit): Boolean = false
/**
* Implementation should load configuration and call `context.suggestNewConfiguration` or `saveNewConfiguration`.
*