From 848266ad5c87365d26113ce48c41856d2433bbae Mon Sep 17 00:00:00 2001 From: Sergey Malenkov Date: Wed, 24 Mar 2021 17:01:26 +0300 Subject: [PATCH] WEB-47997: A *.ts file isn't removed from the Project Errors tab in the Problems view, after deleting it GitOrigin-RevId: 5e5b5024e578e18c7dbed1412b72a5a4e559ed42 --- .../toolWindow/ProjectErrorsCollector.kt | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/platform/lang-impl/src/com/intellij/analysis/problemsView/toolWindow/ProjectErrorsCollector.kt b/platform/lang-impl/src/com/intellij/analysis/problemsView/toolWindow/ProjectErrorsCollector.kt index e5b95a71e6ca..4200ada6ec8a 100644 --- a/platform/lang-impl/src/com/intellij/analysis/problemsView/toolWindow/ProjectErrorsCollector.kt +++ b/platform/lang-impl/src/com/intellij/analysis/problemsView/toolWindow/ProjectErrorsCollector.kt @@ -1,4 +1,4 @@ -// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.analysis.problemsView.toolWindow import com.intellij.analysis.problemsView.FileProblem @@ -9,6 +9,10 @@ import com.intellij.analysis.problemsView.ProblemsListener import com.intellij.icons.AllIcons.Toolwindows import com.intellij.openapi.project.Project import com.intellij.openapi.vfs.VirtualFile +import com.intellij.openapi.vfs.VirtualFileManager +import com.intellij.openapi.vfs.newvfs.events.VFileDeleteEvent +import com.intellij.openapi.vfs.newvfs.events.VFileEvent +import com.intellij.openapi.vfs.newvfs.events.VFileMoveEvent import com.intellij.ui.AppUIUtil import java.util.concurrent.atomic.AtomicInteger @@ -114,4 +118,15 @@ private class ProjectErrorsCollector(val project: Project) : ProblemsCollector { true -> Toolwindows.ToolWindowProblemsEmpty else -> Toolwindows.ToolWindowProblems } + + private fun onVfsChanges(events: List) = events + .filter { it is VFileDeleteEvent || it is VFileMoveEvent } + .mapNotNull { it.file } + .distinct() + .flatMap { getFileProblems(it) } + .forEach { problemDisappeared(it) } + + init { + VirtualFileManager.getInstance().addAsyncFileListener({ onVfsChanges(it);null }, project) + } }