From fa2b9b11d6329261bc71b279525b09b2f828e2fb Mon Sep 17 00:00:00 2001 From: Natalia Selezneva Date: Wed, 19 Jun 2019 15:20:07 +0300 Subject: [PATCH] Check classpath jars before applying script compilation result from file attributes ^KT-32061 Fixed --- ...omFileAttributeScriptDependenciesLoader.kt | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/idea/idea-core/src/org/jetbrains/kotlin/idea/core/script/dependencies/FromFileAttributeScriptDependenciesLoader.kt b/idea/idea-core/src/org/jetbrains/kotlin/idea/core/script/dependencies/FromFileAttributeScriptDependenciesLoader.kt index 726e0e0cd78..1d79f0bfb84 100644 --- a/idea/idea-core/src/org/jetbrains/kotlin/idea/core/script/dependencies/FromFileAttributeScriptDependenciesLoader.kt +++ b/idea/idea-core/src/org/jetbrains/kotlin/idea/core/script/dependencies/FromFileAttributeScriptDependenciesLoader.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ @@ -30,9 +30,25 @@ class FromFileAttributeScriptDependenciesLoader(project: Project) : ScriptDepend debug(file) { "dependencies from fileAttributes = $it" } } }?.let { - saveToCache(file, it.asSuccess(), skipSaveToAttributes = true) + if (areDependenciesValid(file, it)) { + saveToCache(file, it.asSuccess(), skipSaveToAttributes = true) + } } } override fun shouldShowNotification(): Boolean = false + + private fun areDependenciesValid(file: VirtualFile, configuration: ScriptCompilationConfigurationWrapper.FromLegacy): Boolean { + return configuration.dependenciesClassPath.all { + if (it.exists()) { + true + } else { + debug(file) { + "classpath root saved to file attribute doesn't exist: ${it.path}" + } + false + } + + } + } } \ No newline at end of file