fileNameChangedEvent: do not notify BuildManager if file name has not actually changed;

ensure deleted-changed notification sequence (relevant for case-insensitive file systems)
This commit is contained in:
Eugene Zhuravlev
2018-09-17 13:38:41 +02:00
parent da37073304
commit 98bf054a7a
@@ -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<? super File> filesDeleted,
@NotNull Collection<? super File> 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() {