Check files is valid before searching for children (EA-113417)

This commit is contained in:
Nikolay Krasko
2018-06-27 13:00:05 +03:00
parent 8c8d0eefbb
commit c68284030d
2 changed files with 6 additions and 4 deletions
@@ -17,7 +17,6 @@ import com.intellij.openapi.project.rootManager
import com.intellij.openapi.roots.ModuleRootEvent
import com.intellij.openapi.roots.ModuleRootListener
import com.intellij.openapi.util.Disposer
import com.intellij.openapi.vfs.InvalidVirtualFileAccessException
import com.intellij.openapi.vfs.VfsUtilCore
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.openapi.vfs.VirtualFileManager
@@ -62,6 +61,7 @@ class KotlinPackageContentModificationListener(private val project: Project) {
} else {
events
.asSequence()
.filter { it.isValid }
.filter { it.file != null }
.filter(::isRelevant)
.filter {
@@ -64,9 +64,11 @@ class ScriptTemplatesFromDependenciesProvider(private val project: Project) : Sc
if (!processedRoots.contains(vfile)) {
processedRoots.add(vfile)
val root = JarFileSystem.getInstance().getJarRootForLocalFile(vfile) ?: vfile
root.findFileByRelativePath(templatesPath)?.takeIf { it.isDirectory }?.children?.forEach {
if (it.isValid && !it.isDirectory && templates.add(it.name)) {
newTemplatesFound = true
if (root.isValid) {
root.findFileByRelativePath(templatesPath)?.takeIf { it.isDirectory }?.children?.forEach {
if (it.isValid && !it.isDirectory && templates.add(it.name)) {
newTemplatesFound = true
}
}
}
}