cleanup
authorAlexey Kudravtsev <cdr@intellij.com>
Thu, 26 Nov 2020 13:11:56 +0000 (14:11 +0100)
committerintellij-monorepo-bot <intellij-monorepo-bot-no-reply@jetbrains.com>
Thu, 26 Nov 2020 13:23:11 +0000 (13:23 +0000)
GitOrigin-RevId: 437502e9a329daf52a00256975d0980cf2f09b18

platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/VfsImplUtil.java
platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/impl/VirtualDirectoryImpl.java

index cea47534b5762253f28b519973f43d9a9ced75b6..dc18e311ae2c224b1a1e78d997d2c1b93793eda3 100644 (file)
@@ -300,11 +300,11 @@ public final class VfsImplUtil {
    * Otherwise, return null.
    */
   public static VFileEvent generateCaseSensitivityChangedEventForUnknownCase(@NotNull VirtualFile parent, @NotNull String childName) {
-    if (((VirtualDirectoryImpl)parent).getChildrenCaseSensitivity() == FileAttributes.CaseSensitivity.UNKNOWN) {
-      FileAttributes.CaseSensitivity sensitivity = FileSystemUtil.readParentCaseSensitivity(new File(parent.getPath(), childName));
-      return generateCaseSensitivityChangedEvent(parent, sensitivity);
+    if (((VirtualDirectoryImpl)parent).getChildrenCaseSensitivity() != FileAttributes.CaseSensitivity.UNKNOWN) {
+      return null;
     }
-    return null;
+    FileAttributes.CaseSensitivity sensitivity = FileSystemUtil.readParentCaseSensitivity(new File(parent.getPath(), childName));
+    return generateCaseSensitivityChangedEvent(parent, sensitivity);
   }
 
   public static VFilePropertyChangeEvent generateCaseSensitivityChangedEvent(@NotNull VirtualFile dir, @NotNull FileAttributes.CaseSensitivity actualCaseSensitivity) {
index 9b8371aacba95fb74dcd3c233386a0811a7a70e2..1d870b1b3dfc1d160888a30d69336918ad43ba3f 100644 (file)
@@ -74,10 +74,9 @@ public class VirtualDirectoryImpl extends VirtualFileSystemEntry {
                                            boolean ensureCanonicalName,
                                            @NotNull NewVirtualFileSystem delegate) {
     if (doRefresh) {
-      refreshCaseSensitivity(name);
+      updateCaseSensitivityIfUnknown(name);
     }
-    boolean caseSensitive = isCaseSensitive();
-    VirtualFileSystemEntry result = doFindChild(name, ensureCanonicalName, delegate, caseSensitive);
+    VirtualFileSystemEntry result = doFindChild(name, ensureCanonicalName, delegate, isCaseSensitive());
 
     //noinspection UseVirtualFileEquals
     if (result == NULL_VIRTUAL_FILE) {
@@ -272,7 +271,14 @@ public class VirtualDirectoryImpl extends VirtualFileSystemEntry {
                    (PersistentFS.isHidden(attributes) ? VfsDataFlags.IS_HIDDEN_FLAG : 0) |
                    (sensitivity != FileAttributes.CaseSensitivity.UNKNOWN ? VfsDataFlags.CHILDREN_CASE_SENSITIVITY_CACHED : 0) |
                    (sensitivity == FileAttributes.CaseSensitivity.SENSITIVE ? VfsDataFlags.CHILDREN_CASE_SENSITIVE : 0);
-    segment.setFlags(id, VfsDataFlags.IS_SYMLINK_FLAG | VfsDataFlags.IS_SPECIAL_FLAG  | VfsDataFlags.STRICT_PARENT_HAS_SYMLINK_FLAG | VfsDataFlags.IS_WRITABLE_FLAG | VfsDataFlags.IS_HIDDEN_FLAG | VfsDataFlags.CHILDREN_CASE_SENSITIVE | VfsDataFlags.CHILDREN_CASE_SENSITIVITY_CACHED, newFlags);
+    int relevantFlagsMask = VfsDataFlags.IS_SYMLINK_FLAG |
+               VfsDataFlags.IS_SPECIAL_FLAG |
+               VfsDataFlags.STRICT_PARENT_HAS_SYMLINK_FLAG |
+               VfsDataFlags.IS_WRITABLE_FLAG |
+               VfsDataFlags.IS_HIDDEN_FLAG |
+               VfsDataFlags.CHILDREN_CASE_SENSITIVE |
+               VfsDataFlags.CHILDREN_CASE_SENSITIVITY_CACHED;
+    segment.setFlags(id, relevantFlagsMask, newFlags);
     child.updateLinkStatus(this);
 
     if (delegate.markNewFilesAsDirty()) {
@@ -302,11 +308,11 @@ public class VirtualDirectoryImpl extends VirtualFileSystemEntry {
     ChildInfo[] children = isEmptyDirectory ? ChildInfo.EMPTY_ARRAY : null;
     VFileCreateEvent event = new VFileCreateEvent(null, this, realName, isDirectory, attributes, symlinkTarget, true, children);
     RefreshQueue.getInstance().processSingleEvent(event);
-    refreshCaseSensitivity(realName);
+    updateCaseSensitivityIfUnknown(realName);
     return findChild(realName);
   }
 
-  private void refreshCaseSensitivity(@NotNull String childName) {
+  private void updateCaseSensitivityIfUnknown(@NotNull String childName) {
     VFileEvent caseSensitivityEvent = VfsImplUtil.generateCaseSensitivityChangedEventForUnknownCase(this, childName);
     if (caseSensitivityEvent != null) {
       RefreshQueue.getInstance().processSingleEvent(caseSensitivityEvent);