Scripting: minor changes
This commit is contained in:
+1
-1
@@ -522,7 +522,7 @@ abstract class DefaultScriptingSupportBase(val manager: CompositeScriptConfigura
|
|||||||
|
|
||||||
// own builder for saving to storage
|
// own builder for saving to storage
|
||||||
val rootsStorage = ScriptClassRootsStorage.getInstance(project)
|
val rootsStorage = ScriptClassRootsStorage.getInstance(project)
|
||||||
val ownBuilder = ScriptClassRootsBuilder.fromStorage(rootsStorage)
|
val ownBuilder = ScriptClassRootsBuilder.fromStorage(project, rootsStorage)
|
||||||
cache.allApplied().forEach { (vFile, configuration) -> ownBuilder.add(vFile, configuration) }
|
cache.allApplied().forEach { (vFile, configuration) -> ownBuilder.add(vFile, configuration) }
|
||||||
ownBuilder.toStorage(rootsStorage)
|
ownBuilder.toStorage(rootsStorage)
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -18,7 +18,7 @@ import com.intellij.util.xmlb.XmlSerializerUtil
|
|||||||
name = "ScriptClassRootsStorage",
|
name = "ScriptClassRootsStorage",
|
||||||
storages = [Storage(StoragePathMacros.CACHE_FILE)]
|
storages = [Storage(StoragePathMacros.CACHE_FILE)]
|
||||||
)
|
)
|
||||||
class ScriptClassRootsStorage(val project: Project) : PersistentStateComponent<ScriptClassRootsStorage> {
|
class ScriptClassRootsStorage : PersistentStateComponent<ScriptClassRootsStorage> {
|
||||||
var classpath: Set<String> = hashSetOf()
|
var classpath: Set<String> = hashSetOf()
|
||||||
var sources: Set<String> = hashSetOf()
|
var sources: Set<String> = hashSetOf()
|
||||||
var sdks: Set<String> = hashSetOf()
|
var sdks: Set<String> = hashSetOf()
|
||||||
|
|||||||
+2
-2
@@ -73,8 +73,8 @@ class ScriptClassRootsBuilder(
|
|||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun fromStorage(storage: ScriptClassRootsStorage) = ScriptClassRootsBuilder(
|
fun fromStorage(project: Project, storage: ScriptClassRootsStorage) = ScriptClassRootsBuilder(
|
||||||
storage.project,
|
project,
|
||||||
storage.classpath.toMutableSet(),
|
storage.classpath.toMutableSet(),
|
||||||
storage.sources.toMutableSet(),
|
storage.sources.toMutableSet(),
|
||||||
).also { roots ->
|
).also { roots ->
|
||||||
|
|||||||
+1
-1
@@ -137,7 +137,7 @@ class ScriptClassRootsUpdater(
|
|||||||
private fun ensureUpdateScheduled() {
|
private fun ensureUpdateScheduled() {
|
||||||
scheduledUpdate?.cancel()
|
scheduledUpdate?.cancel()
|
||||||
runReadAction {
|
runReadAction {
|
||||||
if (project.isDisposed && !Disposer.isDisposing(project)) {
|
if (!Disposer.isDisposing(project)) {
|
||||||
scheduledUpdate = BackgroundTaskUtil.executeOnPooledThread(project) {
|
scheduledUpdate = BackgroundTaskUtil.executeOnPooledThread(project) {
|
||||||
doUpdate()
|
doUpdate()
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-1
@@ -340,7 +340,11 @@ class GradleBuildRootsManager(val project: Project) : ScriptingSupport() {
|
|||||||
|
|
||||||
private fun add(newRoot: GradleBuildRoot.Linked) {
|
private fun add(newRoot: GradleBuildRoot.Linked) {
|
||||||
val old = roots.add(newRoot)
|
val old = roots.add(newRoot)
|
||||||
if (old is GradleBuildRoot.Imported) removeData(old.pathPrefix)
|
|
||||||
|
if (old is GradleBuildRoot.Imported && newRoot !is GradleBuildRoot.Imported) {
|
||||||
|
removeData(old.pathPrefix)
|
||||||
|
}
|
||||||
|
|
||||||
if (old is GradleBuildRoot.Imported || newRoot is GradleBuildRoot.Imported) {
|
if (old is GradleBuildRoot.Imported || newRoot is GradleBuildRoot.Imported) {
|
||||||
updater.invalidateAndCommit()
|
updater.invalidateAndCommit()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user