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:
+9
-1
@@ -74,6 +74,7 @@ class ScriptDefinitionsManager(private val project: Project) : LazyScriptDefinit
|
||||
|
||||
override fun findScriptDefinition(fileName: String): KotlinScriptDefinition? {
|
||||
if (nonScriptFileName(fileName)) return null
|
||||
if (!isReady()) return null
|
||||
|
||||
val cached = synchronized(scriptDefinitionsCacheLock) { scriptDefinitionsCache.get(fileName) }
|
||||
if (cached != null) return cached
|
||||
@@ -144,6 +145,12 @@ class ScriptDefinitionsManager(private val project: Project) : LazyScriptDefinit
|
||||
}
|
||||
}
|
||||
|
||||
fun isReady(): Boolean {
|
||||
return definitionsByContributor.keys.all { contributor ->
|
||||
contributor.isReady()
|
||||
}
|
||||
}
|
||||
|
||||
override fun getDefaultScriptDefinition(): KotlinScriptDefinition {
|
||||
val standardScriptDefinitionContributor = ScriptDefinitionContributor.find<StandardScriptDefinitionContributor>(project)
|
||||
?: error("StandardScriptDefinitionContributor should be registered is plugin.xml")
|
||||
@@ -271,6 +278,7 @@ interface ScriptDefinitionContributor {
|
||||
val id: String
|
||||
|
||||
fun getDefinitions(): List<KotlinScriptDefinition>
|
||||
fun isReady() = true
|
||||
|
||||
companion object {
|
||||
val EP_NAME: ExtensionPointName<ScriptDefinitionContributor> =
|
||||
@@ -328,4 +336,4 @@ class BundledKotlinScriptDependenciesResolver(private val project: Project) : De
|
||||
?: PathUtilEx.getAnyJdk(project)
|
||||
return jdk?.homePath
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user