From 98bf054a7a0a91dad42b1de3083caceac261f35a Mon Sep 17 00:00:00 2001 From: Eugene Zhuravlev Date: Mon, 17 Sep 2018 13:38:06 +0200 Subject: [PATCH] fileNameChangedEvent: do not notify BuildManager if file name has not actually changed; ensure deleted-changed notification sequence (relevant for case-insensitive file systems) --- .../impl/TranslatingCompilerFilesMonitor.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/java/compiler/impl/src/com/intellij/compiler/impl/TranslatingCompilerFilesMonitor.java b/java/compiler/impl/src/com/intellij/compiler/impl/TranslatingCompilerFilesMonitor.java index 15509e2469c5..7e117cbe8b12 100644 --- a/java/compiler/impl/src/com/intellij/compiler/impl/TranslatingCompilerFilesMonitor.java +++ b/java/compiler/impl/src/com/intellij/compiler/impl/TranslatingCompilerFilesMonitor.java @@ -149,8 +149,12 @@ public class TranslatingCompilerFilesMonitor implements BulkFileListener { checkIntersection(filesChanged, filesDeleted); - notifyFilesChanged(filesChanged); + // If a file name differs ony in case, on case-insensitive file systems such name denotes still the same file. + // In this situation filesDeleted and filesChanged sets will contain paths differing only in case. + // Thus the order in which BuildManager is notified, is important: + // first deleted paths notification and only then changed paths notification notifyFilesDeleted(filesDeleted); + notifyFilesChanged(filesChanged); } // todo: temporary check to verify events correctess @@ -194,11 +198,16 @@ public class TranslatingCompilerFilesMonitor implements BulkFileListener { @NotNull Collection filesDeleted, @NotNull Collection filesChanged) { if (VirtualFile.PROP_NAME.equals(event.getPropertyName())) { + final String oldName = (String)event.getOldValue(); + final String newName = (String)event.getNewValue(); + if (Comparing.equal(oldName, newName)) { + // Old and new names may actually be the same: sometimes such events are sent by VFS + return; + } final VirtualFile eventFile = event.getFile(); if (isInContentOfOpenedProject(eventFile)) { final VirtualFile parent = eventFile.getParent(); if (parent != null) { - final String oldName = (String)event.getOldValue(); final String root = parent.getPath() + "/" + oldName; if (eventFile.isDirectory()) { VfsUtilCore.visitChildrenRecursively(eventFile, new VirtualFileVisitor() {