From 1b83cd8259d8319bd4ed9f2b7370d7bcb2d8ea22 Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Fri, 5 Jun 2020 14:57:41 +0300 Subject: [PATCH] cleanup GitOrigin-RevId: fa17a899591828d067d1b2ce3038c26ee8af5516 --- .../vfs/newvfs/persistent/FSRecords.java | 2 +- .../vfs/newvfs/persistent/ListResult.java | 2 +- .../newvfs/persistent/PersistentFSImpl.java | 47 ++++++++++--------- .../util/containers/ObjectIntHashMap.java | 8 ++-- 4 files changed, 31 insertions(+), 28 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/persistent/FSRecords.java b/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/persistent/FSRecords.java index 56191867cd22..62aedb6f8a2b 100644 --- a/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/persistent/FSRecords.java +++ b/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/persistent/FSRecords.java @@ -1059,7 +1059,7 @@ public final class FSRecords { @NotNull static ListResult mergeByName(@NotNull ListResult existingList, @NotNull ListResult newList, - @NotNull TObjectHashingStrategy hashingStrategy) { + @NotNull TObjectHashingStrategy hashingStrategy) { List newChildren = newList.children; List oldChildren = existingList.children; if (oldChildren.isEmpty()) return newList; diff --git a/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/persistent/ListResult.java b/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/persistent/ListResult.java index e34d140b2f8c..83532a482618 100644 --- a/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/persistent/ListResult.java +++ b/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/persistent/ListResult.java @@ -75,7 +75,7 @@ class ListResult { @Contract(pure=true) @NotNull - ListResult merge(@NotNull List newList, @NotNull TObjectHashingStrategy hashingStrategy) { + ListResult merge(@NotNull List newList, @NotNull TObjectHashingStrategy hashingStrategy) { // assume list is sorted ListResult newChildren = FSRecords.mergeByName(this, new ListResult(newList), hashingStrategy); return new ListResult(modStamp, newChildren.children); diff --git a/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/persistent/PersistentFSImpl.java b/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/persistent/PersistentFSImpl.java index d6cffd979f5d..f3aefcd48420 100644 --- a/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/persistent/PersistentFSImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/persistent/PersistentFSImpl.java @@ -35,6 +35,7 @@ import gnu.trove.TObjectHashingStrategy; import it.unimi.dsi.fastutil.ints.IntOpenHashSet; import it.unimi.dsi.fastutil.ints.IntSet; import it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.TestOnly; @@ -190,6 +191,7 @@ public final class PersistentFSImpl extends PersistentFS implements Disposable { } @Override + @ApiStatus.Internal public @NotNull List listAll(@NotNull VirtualFile file) { int id = getFileId(file); @@ -364,6 +366,7 @@ public final class PersistentFSImpl extends PersistentFS implements Disposable { } @Override + @ApiStatus.Internal public ChildInfo findChildInfo(@NotNull VirtualFile parent, @NotNull String childName, @NotNull NewVirtualFileSystem fs) { int parentId = getFileId(parent); Ref result = new Ref<>(); @@ -738,7 +741,7 @@ public final class PersistentFSImpl extends PersistentFS implements Disposable { private static int groupByPath(@NotNull List events, int startIndex, @NotNull MostlySingularMultiMap filesInvolved, - @NotNull Set middleDirsInvolved, + @NotNull Set middleDirsInvolved, @NotNull Set deletedPaths, @NotNull Set createdPaths, @NotNull Set eventsToRemove) { @@ -813,7 +816,7 @@ public final class PersistentFSImpl extends PersistentFS implements Disposable { private static boolean checkIfConflictingPaths(@NotNull VFileEvent event, @NotNull String path, @NotNull MostlySingularMultiMap files, - @NotNull Set middleDirs) { + @NotNull Set middleDirs) { boolean canReconcileEvents = true; for (VFileEvent t : files.get(path)) { if (!(isContentChangeLikeHarmlessEvent(event) && isContentChangeLikeHarmlessEvent(t))) { @@ -853,23 +856,23 @@ public final class PersistentFSImpl extends PersistentFS implements Disposable { } // finds a group of non-conflicting events, validate them. - // "outApplyEvents" will contain handlers for applying the grouped events + // "outApplyActions" will contain handlers for applying the grouped events // "outValidatedEvents" will contain events for which VFileEvent.isValid() is true // return index after the last processed event private int groupAndValidate(@NotNull List events, int startIndex, - @NotNull List outApplyEvents, + @NotNull List outApplyActions, @NotNull List outValidatedEvents, @NotNull MostlySingularMultiMap filesInvolved, - @NotNull Set middleDirsInvolved) { + @NotNull Set middleDirsInvolved) { Set toIgnore = new ReferenceOpenHashSet<>(); // VFileEvents override equals() int endIndex = groupByPath(events, startIndex, filesInvolved, middleDirsInvolved, CollectionFactory.createFilePathSet(), CollectionFactory.createFilePathSet(), toIgnore); assert endIndex > startIndex : events.get(startIndex) +"; files: "+filesInvolved+"; middleDirs: "+middleDirsInvolved; // since all events in the group events[startIndex..endIndex) are mutually non-conflicting, we can re-arrange creations/deletions together - groupCreations(events, startIndex, endIndex, outValidatedEvents, outApplyEvents, toIgnore); - groupDeletions(events, startIndex, endIndex, outValidatedEvents, outApplyEvents, toIgnore); - groupOthers(events, startIndex, endIndex, outValidatedEvents, outApplyEvents); + groupCreations(events, startIndex, endIndex, outValidatedEvents, outApplyActions, toIgnore); + groupDeletions(events, startIndex, endIndex, outValidatedEvents, outApplyActions, toIgnore); + groupOthers(events, startIndex, endIndex, outValidatedEvents, outApplyActions); return endIndex; } @@ -880,7 +883,7 @@ public final class PersistentFSImpl extends PersistentFS implements Disposable { int start, int end, @NotNull List outValidated, - @NotNull List outApplyEvents, + @NotNull List outApplyActions, @NotNull Set toIgnore) { MultiMap grouped = null; @@ -908,7 +911,7 @@ public final class PersistentFSImpl extends PersistentFS implements Disposable { if (hasValidEvents) { MultiMap finalGrouped = grouped; - outApplyEvents.add((Runnable)() -> { + outApplyActions.add((Runnable)() -> { applyCreations(finalGrouped); incStructuralModificationCount(); }); @@ -922,7 +925,7 @@ public final class PersistentFSImpl extends PersistentFS implements Disposable { int start, int end, @NotNull List outValidated, - @NotNull List outApplyEvents, + @NotNull List outApplyActions, @NotNull Set toIgnore) { MultiMap grouped = null; boolean hasValidEvents = false; @@ -941,7 +944,7 @@ public final class PersistentFSImpl extends PersistentFS implements Disposable { if (hasValidEvents) { MultiMap finalGrouped = grouped; - outApplyEvents.add((Runnable)() -> { + outApplyActions.add((Runnable)() -> { clearIdCache(); applyDeletions(finalGrouped); incStructuralModificationCount(); @@ -955,12 +958,12 @@ public final class PersistentFSImpl extends PersistentFS implements Disposable { int start, int end, @NotNull List outValidated, - @NotNull List outApplyEvents) { + @NotNull List outApplyActions) { for (int i = start; i < end; i++) { VFileEvent event = events.get(i); if (event instanceof VFileCreateEvent || event instanceof VFileDeleteEvent || !event.isValid()) continue; outValidated.add(event); - outApplyEvents.add((Runnable)() -> applyEvent(event)); + outApplyActions.add((Runnable)() -> applyEvent(event)); } } @@ -971,7 +974,7 @@ public final class PersistentFSImpl extends PersistentFS implements Disposable { int startIndex = 0; int cappedInitialSize = Math.min(events.size(), INNER_ARRAYS_THRESHOLD); - List applyEvents = new ArrayList<>(cappedInitialSize); + List applyActions = new ArrayList<>(cappedInitialSize); MostlySingularMultiMap files = new MostlySingularMultiMap<>(CollectionFactory.createFilePathMap(cappedInitialSize)); Set middleDirs = CollectionFactory.createFilePathSet(cappedInitialSize); List validated = new ArrayList<>(cappedInitialSize); @@ -979,11 +982,11 @@ public final class PersistentFSImpl extends PersistentFS implements Disposable { while (startIndex != events.size()) { PingProgress.interactWithEdtProgress(); - applyEvents.clear(); + applyActions.clear(); files.clear(); middleDirs.clear(); validated.clear(); - startIndex = groupAndValidate(events, startIndex, applyEvents, validated, files, middleDirs); + startIndex = groupAndValidate(events, startIndex, applyActions, validated, files, middleDirs); if (!validated.isEmpty()) { PingProgress.interactWithEdtProgress(); @@ -992,7 +995,7 @@ public final class PersistentFSImpl extends PersistentFS implements Disposable { publisher.before(toSend); PingProgress.interactWithEdtProgress(); - applyEvents.forEach(Runnable::run); + applyActions.forEach(Runnable::run); PingProgress.interactWithEdtProgress(); publisher.after(toSend); @@ -1040,7 +1043,7 @@ public final class PersistentFSImpl extends PersistentFS implements Disposable { } private void applyCreateEventsInDirectory(@NotNull VirtualDirectoryImpl parent, - @NotNull Collection createEvents) { + @NotNull Collection createEvents) { int parentId = getFileId(parent); NewVirtualFile vf = findFileById(parentId); if (!(vf instanceof VirtualDirectoryImpl)) return; @@ -1065,9 +1068,9 @@ public final class PersistentFSImpl extends PersistentFS implements Disposable { saveScannedChildrenRecursively(createEvents, delegate, hashingStrategy); } - private static void saveScannedChildrenRecursively(@NotNull Collection createEvents, + private static void saveScannedChildrenRecursively(@NotNull Collection createEvents, @NotNull NewVirtualFileSystem delegate, - @NotNull TObjectHashingStrategy hashingStrategy) { + @NotNull TObjectHashingStrategy hashingStrategy) { for (VFileCreateEvent createEvent : createEvents) { ChildInfo[] children = createEvent.getChildren(); if (children == null || !createEvent.isDirectory()) continue; @@ -1149,7 +1152,7 @@ public final class PersistentFSImpl extends PersistentFS implements Disposable { @Nullable @Override public VirtualFile getParent() { return null; } }); if (parentAttributes != null) { - throw new IllegalArgumentException("Must pass FS root path, but got: '" + path + "', which has a parent '" + parentPath + "')." + + throw new IllegalArgumentException("Must pass FS root path, but got: '" + path + "', which has a parent '" + parentPath + "'." + " Use NewVirtualFileSystem.extractRootPath() for obtaining root path"); } } diff --git a/platform/util/src/com/intellij/util/containers/ObjectIntHashMap.java b/platform/util/src/com/intellij/util/containers/ObjectIntHashMap.java index 0d32d185573f..db0f645c5130 100644 --- a/platform/util/src/com/intellij/util/containers/ObjectIntHashMap.java +++ b/platform/util/src/com/intellij/util/containers/ObjectIntHashMap.java @@ -13,12 +13,12 @@ public class ObjectIntHashMap extends TObjectIntHashMap { super(initialCapacity); } - public ObjectIntHashMap(@NotNull TObjectHashingStrategy strategy) { - super(strategy); + public ObjectIntHashMap(@NotNull TObjectHashingStrategy strategy) { + super((TObjectHashingStrategy)strategy); } - public ObjectIntHashMap(int initialCapacity, @NotNull TObjectHashingStrategy strategy) { - super(initialCapacity, strategy); + public ObjectIntHashMap(int initialCapacity, @NotNull TObjectHashingStrategy strategy) { + super(initialCapacity, (TObjectHashingStrategy)strategy); } public ObjectIntHashMap() {