KotlinScriptConfigurationManager: run caching code in smart mode
This commit is contained in:
+16
-13
@@ -53,22 +53,25 @@ class KotlinScriptConfigurationManager(
|
|||||||
|
|
||||||
init {
|
init {
|
||||||
reloadScriptDefinitions()
|
reloadScriptDefinitions()
|
||||||
// TODO: sort out read/write action business and if possible make it lazy (e.g. move to getAllScriptsClasspath)
|
|
||||||
runReadAction { cacheAllScriptsExtraImports() }
|
|
||||||
|
|
||||||
project.messageBus.connect().subscribe(VirtualFileManager.VFS_CHANGES, object : BulkFileListener.Adapter() {
|
dumbService.runWhenSmart {
|
||||||
override fun after(events: List<VFileEvent>) {
|
// TODO: sort out read/write action business and if possible make it lazy (e.g. move to getAllScriptsClasspath)
|
||||||
val isChanged = scriptExternalImportsProvider?.updateExternalImportsCache(events.mapNotNull { it.file })?.any() ?: false
|
runReadAction { cacheAllScriptsExtraImports() }
|
||||||
if (isChanged) {
|
|
||||||
// TODO: consider more fine-grained update
|
project.messageBus.connect().subscribe(VirtualFileManager.VFS_CHANGES, object : BulkFileListener.Adapter() {
|
||||||
cacheLock.write {
|
override fun after(events: List<VFileEvent>) {
|
||||||
allScriptsClasspathCache = null
|
val isChanged = scriptExternalImportsProvider?.updateExternalImportsCache(events.mapNotNull { it.file })?.any() ?: false
|
||||||
allLibrarySourcesCache = null
|
if (isChanged) {
|
||||||
|
// TODO: consider more fine-grained update
|
||||||
|
cacheLock.write {
|
||||||
|
allScriptsClasspathCache = null
|
||||||
|
allLibrarySourcesCache = null
|
||||||
|
}
|
||||||
|
notifyRootsChanged()
|
||||||
}
|
}
|
||||||
notifyRootsChanged()
|
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
})
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private var allScriptsClasspathCache: List<VirtualFile>? = null
|
private var allScriptsClasspathCache: List<VirtualFile>? = null
|
||||||
|
|||||||
Reference in New Issue
Block a user