Skip to content

Commit ff39162

Browse files
committed
KSCM: fix wrong update on null return from Template.getDependenciesFor
1 parent 1834721 commit ff39162

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

idea/idea-core/src/org/jetbrains/kotlin/idea/core/script/KotlinScriptConfigurationManager.kt

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ class KotlinScriptConfigurationManager(
224224
val currentTimeStamp = TimeStamps.next()
225225
val scriptContents = scriptDefinition.makeScriptContents(file, project)
226226
val newFuture = supplyAsync(Supplier {
227-
val newDependencies = scriptDefinition.getDependenciesFor(oldDataAndRequest?.dependencies, scriptContents)
227+
val newDependencies = scriptDefinition.getDependenciesFor(oldDataAndRequest?.dependencies, scriptContents) ?: EmptyDependencies
228228
cacheLock.read {
229229
val lastTimeStamp = cache[path]?.requestInProgress?.timeStamp
230230
if (lastTimeStamp == currentTimeStamp) {
@@ -254,31 +254,27 @@ class KotlinScriptConfigurationManager(
254254
private fun <TF : Any> updateSync(file: TF, scriptDef: KotlinScriptDefinition): Boolean {
255255
val path = getFilePath(file)
256256
val oldDeps = cache[path]?.dependencies
257-
val deps = scriptDef.getDependenciesFor(file, project, oldDeps)
257+
val deps = scriptDef.getDependenciesFor(file, project, oldDeps) ?: EmptyDependencies
258258
return cacheSync(deps, oldDeps, path, file as? VirtualFile)
259259
}
260260

261261
private fun cacheSync(
262-
new: KotlinScriptExternalDependencies?,
262+
new: KotlinScriptExternalDependencies,
263263
old: KotlinScriptExternalDependencies?,
264264
path: String,
265265
file: VirtualFile?
266266
): Boolean {
267267
return when {
268-
new != null && (old == null || !(new.match(old))) -> {
268+
old == null || !(new.match(old)) -> {
269269
// changed or new
270270
save(path, new, file, persist = true)
271271
true
272272
}
273-
new != null -> {
273+
else -> {
274274
save(path, new, file, persist = false)
275+
// same
275276
false
276-
} // same
277-
cache.remove(path) != null -> {
278-
save(path, null, file, persist = true)
279-
true
280277
}
281-
else -> false // unknown
282278
}
283279
}
284280

@@ -384,3 +380,5 @@ object TimeStamps {
384380

385381
fun next() = TimeStamp(current++)
386382
}
383+
384+
private object EmptyDependencies: KotlinScriptExternalDependencies

0 commit comments

Comments
 (0)