Always scan root for script templates in background
^KT-29893 Fixed Provide AsyncScriptDefinitionsContributor. Show a notification if the highlighting for script is requested when not all script templates are loaded
This commit is contained in:
@@ -20,6 +20,7 @@ import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.idea.caches.project.NotUnderContentRootModuleInfo
|
||||
import org.jetbrains.kotlin.idea.caches.project.getModuleInfo
|
||||
import org.jetbrains.kotlin.idea.core.script.IdeScriptReportSink
|
||||
import org.jetbrains.kotlin.idea.core.script.ScriptDefinitionsManager
|
||||
import org.jetbrains.kotlin.idea.core.script.scriptDependencies
|
||||
import org.jetbrains.kotlin.idea.util.ProjectRootsUtil
|
||||
import org.jetbrains.kotlin.psi.KtCodeFragment
|
||||
@@ -69,6 +70,8 @@ object KotlinHighlightingUtil {
|
||||
return false
|
||||
}
|
||||
|
||||
if (!ScriptDefinitionsManager.getInstance(ktFile.project).isReady()) return false
|
||||
|
||||
return ProjectRootsUtil.isInProjectSource(ktFile, includeScriptsOutsideSourceRoots = true)
|
||||
}
|
||||
}
|
||||
+22
@@ -31,8 +31,13 @@ import com.intellij.openapi.editor.Document
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.openapi.progress.ProgressIndicator
|
||||
import com.intellij.openapi.project.DumbAware
|
||||
import com.intellij.openapi.ui.MessageType
|
||||
import com.intellij.openapi.wm.WindowManager
|
||||
import com.intellij.openapi.wm.ex.StatusBarEx
|
||||
import com.intellij.psi.PsiFile
|
||||
import com.intellij.util.ui.UIUtil
|
||||
import org.jetbrains.kotlin.idea.core.script.IdeScriptReportSink
|
||||
import org.jetbrains.kotlin.idea.core.script.ScriptDefinitionsManager
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import kotlin.script.experimental.dependencies.ScriptReport
|
||||
|
||||
@@ -45,6 +50,23 @@ class ScriptExternalHighlightingPass(
|
||||
override fun doApplyInformationToEditor() {
|
||||
val document = document ?: return
|
||||
|
||||
if (!file.isScript()) return
|
||||
|
||||
if (!ScriptDefinitionsManager.getInstance(file.project).isReady()) {
|
||||
UIUtil.invokeLaterIfNeeded {
|
||||
val ideFrame = WindowManager.getInstance().getIdeFrame(file.project)
|
||||
if (ideFrame != null) {
|
||||
val statusBar = ideFrame.statusBar as StatusBarEx
|
||||
statusBar.notifyProgressByBalloon(
|
||||
MessageType.WARNING,
|
||||
"Highlighting in scripts is not available until all Script Definitions are loaded",
|
||||
null,
|
||||
null
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val reports = file.virtualFile.getUserData(IdeScriptReportSink.Reports) ?: return
|
||||
|
||||
val annotations = reports.mapNotNull { (message, severity, position) ->
|
||||
|
||||
Reference in New Issue
Block a user