From d9a30c652089cc403ba9fba79556eccc5368a931 Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Wed, 20 Nov 2013 14:17:22 +0100 Subject: [PATCH] platform: detect case-only name changes in case-insensitive FS only --- .../vfs/newvfs/persistent/RefreshWorker.java | 16 ++++++++++------ .../util/text/FilePathHashingStrategy.java | 13 ++++++++----- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/persistent/RefreshWorker.java b/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/persistent/RefreshWorker.java index 0178a8168347..6dfe3082fd57 100644 --- a/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/persistent/RefreshWorker.java +++ b/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/persistent/RefreshWorker.java @@ -32,6 +32,8 @@ import com.intellij.openapi.vfs.newvfs.impl.VirtualDirectoryImpl; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.containers.OpenTHashSet; import com.intellij.util.containers.Queue; +import com.intellij.util.text.FilePathHashingStrategy; +import gnu.trove.TObjectHashingStrategy; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -92,6 +94,8 @@ public class RefreshWorker { } private void processQueue(NewVirtualFileSystem fs, PersistentFS persistence) throws RefreshCancelledException { + TObjectHashingStrategy strategy = FilePathHashingStrategy.create(fs.isCaseSensitive()); + while (!myRefreshQueue.isEmpty()) { checkCancelled(); @@ -120,13 +124,13 @@ public class RefreshWorker { if (fullSync) { String[] currentNames = persistence.list(file); String[] upToDateNames = VfsUtil.filterNames(fs.list(file)); - Set newNames = newTroveSet(FileUtil.PATH_HASHING_STRATEGY, upToDateNames); + Set newNames = newTroveSet(strategy, upToDateNames); ContainerUtil.removeAll(newNames, currentNames); - Set deletedNames = newTroveSet(FileUtil.PATH_HASHING_STRATEGY, currentNames); + Set deletedNames = newTroveSet(strategy, currentNames); ContainerUtil.removeAll(deletedNames, upToDateNames); OpenTHashSet actualNames = null; - if (!SystemInfo.isFileSystemCaseSensitive) { - actualNames = new OpenTHashSet(FileUtil.PATH_HASHING_STRATEGY, upToDateNames); + if (!fs.isCaseSensitive()) { + actualNames = new OpenTHashSet(strategy, upToDateNames); } debug(LOG, "current=%s +%s -%s", currentNames, newNames, deletedNames); @@ -163,8 +167,8 @@ public class RefreshWorker { else { Collection cachedChildren = file.getCachedChildren(); OpenTHashSet actualNames = null; - if (!SystemInfo.isFileSystemCaseSensitive) { - actualNames = new OpenTHashSet(FileUtil.PATH_HASHING_STRATEGY, VfsUtil.filterNames(fs.list(file))); + if (!fs.isCaseSensitive()) { + actualNames = new OpenTHashSet(strategy, VfsUtil.filterNames(fs.list(file))); } debug(LOG, "cached=%s actual=%s", cachedChildren, actualNames); diff --git a/platform/util/src/com/intellij/util/text/FilePathHashingStrategy.java b/platform/util/src/com/intellij/util/text/FilePathHashingStrategy.java index b91b718295eb..bad768477e58 100644 --- a/platform/util/src/com/intellij/util/text/FilePathHashingStrategy.java +++ b/platform/util/src/com/intellij/util/text/FilePathHashingStrategy.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package com.intellij.util.text; import com.intellij.openapi.util.SystemInfo; @@ -25,11 +24,15 @@ import org.jetbrains.annotations.NotNull; * @author max */ public class FilePathHashingStrategy { - private FilePathHashingStrategy() { - } + private FilePathHashingStrategy() { } @NotNull public static TObjectHashingStrategy create() { - return SystemInfo.isFileSystemCaseSensitive ? ContainerUtil.canonicalStrategy() : new CaseInsensitiveStringHashingStrategy(); + return create(SystemInfo.isFileSystemCaseSensitive); + } + + @NotNull + public static TObjectHashingStrategy create(boolean caseSensitive) { + return caseSensitive ? ContainerUtil.canonicalStrategy() : new CaseInsensitiveStringHashingStrategy(); } }