mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-14 18:05:27 +07:00
refactor FileCollectionFactory
GitOrigin-RevId: d05fb6b21b5d584e652da474aaf13cc9978689e9
This commit is contained in:
committed by
intellij-monorepo-bot
parent
d7767f4877
commit
7173841d21
@@ -1,7 +1,7 @@
|
|||||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||||
package org.jetbrains.jps.incremental;
|
package org.jetbrains.jps.incremental;
|
||||||
|
|
||||||
import com.intellij.util.containers.FastUtilHashingStrategies;
|
import com.intellij.util.containers.FileHashStrategy;
|
||||||
import it.unimi.dsi.fastutil.objects.Object2ObjectMap;
|
import it.unimi.dsi.fastutil.objects.Object2ObjectMap;
|
||||||
import it.unimi.dsi.fastutil.objects.Object2ObjectMaps;
|
import it.unimi.dsi.fastutil.objects.Object2ObjectMaps;
|
||||||
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenCustomHashMap;
|
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenCustomHashMap;
|
||||||
@@ -22,7 +22,8 @@ final class ChunkBuildOutputConsumerImpl implements ModuleLevelBuilder.OutputCon
|
|||||||
private final Map<BuildTarget<?>, BuildOutputConsumerImpl> myTarget2Consumer = new HashMap<>();
|
private final Map<BuildTarget<?>, BuildOutputConsumerImpl> myTarget2Consumer = new HashMap<>();
|
||||||
private final Map<String, CompiledClass> myClasses = new HashMap<>();
|
private final Map<String, CompiledClass> myClasses = new HashMap<>();
|
||||||
private final Map<BuildTarget<?>, Collection<CompiledClass>> myTargetToClassesMap = new HashMap<>();
|
private final Map<BuildTarget<?>, Collection<CompiledClass>> myTargetToClassesMap = new HashMap<>();
|
||||||
private final Object2ObjectMap<File, String> myOutputToBuilderNameMap = Object2ObjectMaps.synchronize(new Object2ObjectOpenCustomHashMap<>(FastUtilHashingStrategies.FILE_HASH_STRATEGY));
|
private final Object2ObjectMap<File, String> myOutputToBuilderNameMap =
|
||||||
|
Object2ObjectMaps.synchronize(new Object2ObjectOpenCustomHashMap<>(FileHashStrategy.INSTANCE));
|
||||||
private volatile String myCurrentBuilderName;
|
private volatile String myCurrentBuilderName;
|
||||||
|
|
||||||
ChunkBuildOutputConsumerImpl(CompileContext context) {
|
ChunkBuildOutputConsumerImpl(CompileContext context) {
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ package org.jetbrains.jps.incremental.fs;
|
|||||||
import com.intellij.openapi.diagnostic.Logger;
|
import com.intellij.openapi.diagnostic.Logger;
|
||||||
import com.intellij.openapi.util.Key;
|
import com.intellij.openapi.util.Key;
|
||||||
import com.intellij.util.SmartList;
|
import com.intellij.util.SmartList;
|
||||||
import com.intellij.util.containers.FastUtilHashingStrategies;
|
import com.intellij.util.containers.FileHashStrategy;
|
||||||
import com.intellij.util.containers.MultiMap;
|
import com.intellij.util.containers.MultiMap;
|
||||||
import com.intellij.util.io.IOUtil;
|
import com.intellij.util.io.IOUtil;
|
||||||
import it.unimi.dsi.fastutil.objects.Object2LongOpenCustomHashMap;
|
import it.unimi.dsi.fastutil.objects.Object2LongOpenCustomHashMap;
|
||||||
@@ -40,7 +40,7 @@ public final class BuildFSState {
|
|||||||
private final boolean myAlwaysScanFS;
|
private final boolean myAlwaysScanFS;
|
||||||
private final Set<BuildTarget<?>> myInitialScanPerformed = Collections.synchronizedSet(new HashSet<>());
|
private final Set<BuildTarget<?>> myInitialScanPerformed = Collections.synchronizedSet(new HashSet<>());
|
||||||
@SuppressWarnings("SSBasedInspection")
|
@SuppressWarnings("SSBasedInspection")
|
||||||
private final Object2LongOpenCustomHashMap<File> myRegistrationStamps = new Object2LongOpenCustomHashMap<>(FastUtilHashingStrategies.FILE_HASH_STRATEGY);
|
private final Object2LongOpenCustomHashMap<File> myRegistrationStamps = new Object2LongOpenCustomHashMap<>(FileHashStrategy.INSTANCE);
|
||||||
private final Map<BuildTarget<?>, FilesDelta> myDeltas = Collections.synchronizedMap(new HashMap<>());
|
private final Map<BuildTarget<?>, FilesDelta> myDeltas = Collections.synchronizedMap(new HashMap<>());
|
||||||
|
|
||||||
public BuildFSState(boolean alwaysScanFS) {
|
public BuildFSState(boolean alwaysScanFS) {
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import java.util.concurrent.ConcurrentMap;
|
|||||||
import java.util.function.BiConsumer;
|
import java.util.function.BiConsumer;
|
||||||
|
|
||||||
// ContainerUtil requires trove in classpath
|
// ContainerUtil requires trove in classpath
|
||||||
|
@SuppressWarnings("UnnecessaryFullyQualifiedName")
|
||||||
public final class CollectionFactory {
|
public final class CollectionFactory {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -278,16 +279,17 @@ public final class CollectionFactory {
|
|||||||
|
|
||||||
public static @NotNull Set<String> createFilePathLinkedSet() {
|
public static @NotNull Set<String> createFilePathLinkedSet() {
|
||||||
return SystemInfoRt.isFileSystemCaseSensitive
|
return SystemInfoRt.isFileSystemCaseSensitive
|
||||||
? createSmallMemoryFootprintLinkedSet()
|
? new ObjectLinkedOpenHashSet<>()
|
||||||
: new ObjectLinkedOpenCustomHashSet<>(FastUtilHashingStrategies.getCaseInsensitiveStringStrategy());
|
: new ObjectLinkedOpenCustomHashSet<>(FastUtilHashingStrategies.getCaseInsensitiveStringStrategy());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create linked map with key hash strategy according to file system path case sensitivity.
|
* Create a linked map with key hash strategy according to file system path case sensitivity.
|
||||||
*/
|
*/
|
||||||
public static @NotNull <V> Map<String, V> createFilePathLinkedMap() {
|
public static @NotNull <V> Map<String, V> createFilePathLinkedMap() {
|
||||||
|
//noinspection SSBasedInspection
|
||||||
return SystemInfoRt.isFileSystemCaseSensitive
|
return SystemInfoRt.isFileSystemCaseSensitive
|
||||||
? createSmallMemoryFootprintLinkedMap()
|
? new Object2ObjectLinkedOpenHashMap<>()
|
||||||
: new Object2ObjectLinkedOpenCustomHashMap<>(FastUtilHashingStrategies.getCaseInsensitiveStringStrategy());
|
: new Object2ObjectLinkedOpenCustomHashMap<>(FastUtilHashingStrategies.getCaseInsensitiveStringStrategy());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -336,8 +338,8 @@ public final class CollectionFactory {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a linked-keys (i.e. iteration order is the same as the insertion order) {@link Set} implementation with slightly faster access for very big collection (>100K keys) and a bit smaller memory footprint
|
* Returns a linked-keys (i.e. iteration order is the same as the insertion order) {@link Set} implementation with slightly faster access for very big collection (>100K keys) and a bit smaller memory footprint
|
||||||
* than {@link HashSet}. Null keys are permitted. Use sparingly only when performance considerations are utterly important;
|
* than {@link java.util.HashSet}. Null keys are permitted. Use sparingly only when performance considerations are utterly important;
|
||||||
* in all other cases please prefer {@link HashSet}.
|
* in all other cases please prefer {@link java.util.HashSet}.
|
||||||
*/
|
*/
|
||||||
@Contract(value = "-> new", pure = true)
|
@Contract(value = "-> new", pure = true)
|
||||||
public static <K> @NotNull Set<K> createSmallMemoryFootprintLinkedSet() {
|
public static <K> @NotNull Set<K> createSmallMemoryFootprintLinkedSet() {
|
||||||
@@ -346,8 +348,8 @@ public final class CollectionFactory {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a {@link Set} implementation with slightly faster access for very big collections (>100K keys) and a bit smaller memory footprint
|
* Returns a {@link Set} implementation with slightly faster access for very big collections (>100K keys) and a bit smaller memory footprint
|
||||||
* than {@link HashSet}. Null keys are permitted. Use sparingly only when performance considerations are utterly important;
|
* than {@link java.util.HashSet}. Null keys are permitted. Use sparingly only when performance considerations are utterly important;
|
||||||
* in all other cases please prefer {@link HashSet}.
|
* in all other cases please prefer {@link java.util.HashSet}.
|
||||||
*/
|
*/
|
||||||
@Contract(value = "-> new", pure = true)
|
@Contract(value = "-> new", pure = true)
|
||||||
public static <K> @NotNull Set<K> createSmallMemoryFootprintSet() {
|
public static <K> @NotNull Set<K> createSmallMemoryFootprintSet() {
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import org.jetbrains.annotations.ApiStatus;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
@@ -36,18 +35,6 @@ public final class FastUtilHashingStrategies {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public static final Hash.Strategy<File> FILE_HASH_STRATEGY = new SerializableHashStrategy<File>() {
|
|
||||||
@Override
|
|
||||||
public int hashCode(@Nullable File o) {
|
|
||||||
return FileUtilRt.pathHashCode(o == null ? null : o.getPath());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(@Nullable File a, @Nullable File b) {
|
|
||||||
return FileUtilRt.pathsEqual(a == null ? null : a.getPath(), b == null ? null : b.getPath());
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
public static @NotNull Hash.Strategy<CharSequence> getCharSequenceStrategy(boolean isCaseSensitive) {
|
public static @NotNull Hash.Strategy<CharSequence> getCharSequenceStrategy(boolean isCaseSensitive) {
|
||||||
return isCaseSensitive ? CASE_SENSITIVE : CASE_INSENSITIVE;
|
return isCaseSensitive ? CASE_SENSITIVE : CASE_INSENSITIVE;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,123 +1,81 @@
|
|||||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||||
package com.intellij.util.containers;
|
package com.intellij.util.containers
|
||||||
|
|
||||||
import com.intellij.openapi.util.io.FileUtilRt;
|
import com.intellij.openapi.util.io.FileUtilRt
|
||||||
import it.unimi.dsi.fastutil.Hash;
|
import it.unimi.dsi.fastutil.Hash
|
||||||
import it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenCustomHashMap;
|
import it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenCustomHashMap
|
||||||
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenCustomHashMap;
|
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenCustomHashMap
|
||||||
import it.unimi.dsi.fastutil.objects.ObjectLinkedOpenCustomHashSet;
|
import it.unimi.dsi.fastutil.objects.ObjectLinkedOpenCustomHashSet
|
||||||
import it.unimi.dsi.fastutil.objects.ObjectOpenCustomHashSet;
|
import it.unimi.dsi.fastutil.objects.ObjectOpenCustomHashSet
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.ApiStatus.Internal
|
||||||
import org.jetbrains.annotations.Nullable;
|
import java.io.File
|
||||||
|
import java.io.Serializable
|
||||||
import java.io.File;
|
import java.nio.file.Path
|
||||||
import java.io.Serializable;
|
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates map or set with canonicalized path hash strategy.
|
* Creates map or set with canonicalized path hash strategy.
|
||||||
*/
|
*/
|
||||||
public final class FileCollectionFactory {
|
object FileCollectionFactory {
|
||||||
private interface SerializableHashingStrategy<T> extends Hash.Strategy<T>, Serializable {}
|
/**
|
||||||
|
* Create a linked map with canonicalized key hash strategy.
|
||||||
private static final SerializableHashingStrategy<File> FILE_HASH_STRATEGY = new SerializableHashingStrategy<File>() {
|
*/
|
||||||
@Override
|
@JvmStatic
|
||||||
public int hashCode(@Nullable File o) {
|
fun <V> createCanonicalPathLinkedMap(): MutableMap<Path, V> = Object2ObjectLinkedOpenCustomHashMap(PathHashStrategy)
|
||||||
return FileUtilRt.pathHashCode(o == null ? null : o.getPath());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(@Nullable File a, @Nullable File b) {
|
|
||||||
return FileUtilRt.pathsEqual(a == null ? null : a.getPath(), b == null ? null : b.getPath());
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create linked map with canonicalized key hash strategy.
|
* Create a linked map with canonicalized key hash strategy.
|
||||||
*/
|
*/
|
||||||
public static @NotNull <V> Map<Path, V> createCanonicalPathLinkedMap() {
|
@JvmStatic
|
||||||
return new Object2ObjectLinkedOpenCustomHashMap<>(new PathSerializableHashStrategy());
|
fun <V> createCanonicalFilePathLinkedMap(): MutableMap<String, V> {
|
||||||
|
return Object2ObjectLinkedOpenCustomHashMap(object : Hash.Strategy<String?> {
|
||||||
|
override fun hashCode(value: String?): Int = FileUtilRt.pathHashCode(value)
|
||||||
|
|
||||||
|
override fun equals(val1: String?, val2: String?): Boolean = FileUtilRt.pathsEqual(val1, val2)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@JvmStatic
|
||||||
* Create linked map with canonicalized key hash strategy.
|
fun <V> createCanonicalFileMap(): MutableMap<File, V> = Object2ObjectOpenCustomHashMap(FileHashStrategy)
|
||||||
*/
|
|
||||||
public static @NotNull <V> Map<String, V> createCanonicalFilePathLinkedMap() {
|
|
||||||
return new Object2ObjectLinkedOpenCustomHashMap<>(new Hash.Strategy<String>() {
|
|
||||||
@Override
|
|
||||||
public int hashCode(@Nullable String value) {
|
|
||||||
return FileUtilRt.pathHashCode(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@JvmStatic
|
||||||
public boolean equals(@Nullable String val1, @Nullable String val2) {
|
fun <V> createCanonicalPathMap(): MutableMap<Path, V> = Object2ObjectOpenCustomHashMap(PathHashStrategy)
|
||||||
return FileUtilRt.pathsEqual(val1, val2);
|
|
||||||
}
|
@JvmStatic
|
||||||
});
|
fun <V> createCanonicalFileMap(expected: Int): MutableMap<File, V> {
|
||||||
|
return Object2ObjectOpenCustomHashMap(expected, FileHashStrategy)
|
||||||
}
|
}
|
||||||
|
|
||||||
public static @NotNull <V> Map<File, V> createCanonicalFileMap() {
|
@JvmStatic
|
||||||
return new Object2ObjectOpenCustomHashMap<>(FILE_HASH_STRATEGY);
|
fun <V> createCanonicalFileMap(map: Map<out File, V>): MutableMap<File, V> = Object2ObjectOpenCustomHashMap(map, FileHashStrategy)
|
||||||
}
|
|
||||||
|
|
||||||
public static @NotNull <V> Map<File, V> createCanonicalFileMap(int expected) {
|
@JvmStatic
|
||||||
return new Object2ObjectOpenCustomHashMap<>(expected, FILE_HASH_STRATEGY);
|
fun createCanonicalFileSet(): MutableSet<File> = ObjectOpenCustomHashSet(FileHashStrategy)
|
||||||
}
|
|
||||||
|
|
||||||
public static @NotNull <V> Map<File, V> createCanonicalFileMap(@NotNull Map<? extends File, ? extends V> map) {
|
@JvmStatic
|
||||||
Map<File, V> result = createCanonicalFileMap(map.size());
|
fun createCanonicalFileSet(files: Collection<File>): MutableSet<File> = ObjectOpenCustomHashSet(files, FileHashStrategy)
|
||||||
result.putAll(map);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static @NotNull Set<File> createCanonicalFileSet() {
|
@JvmStatic
|
||||||
return new ObjectOpenCustomHashSet<>(FILE_HASH_STRATEGY);
|
fun createCanonicalPathSet(): MutableSet<Path> = ObjectOpenCustomHashSet(PathHashStrategy)
|
||||||
}
|
|
||||||
|
|
||||||
public static @NotNull Set<File> createCanonicalFileSet(@NotNull Collection<? extends File> files) {
|
@JvmStatic
|
||||||
Set<File> set = createCanonicalFileSet();
|
fun createCanonicalPathSet(files: Collection<Path>): MutableSet<Path> = ObjectOpenCustomHashSet(files, PathHashStrategy)
|
||||||
set.addAll(files);
|
|
||||||
return set;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static @NotNull Set<Path> createCanonicalPathSet() {
|
@JvmStatic
|
||||||
return new ObjectOpenCustomHashSet<>(new PathSerializableHashStrategy());
|
fun createCanonicalFilePathSet(): MutableSet<String> = ObjectOpenCustomHashSet(FastUtilHashingStrategies.FILE_PATH_HASH_STRATEGY)
|
||||||
}
|
|
||||||
|
|
||||||
public static @NotNull Set<Path> createCanonicalPathSet(@NotNull Collection<? extends Path> files) {
|
@JvmStatic
|
||||||
return new ObjectOpenCustomHashSet<>(files, new PathSerializableHashStrategy());
|
fun createCanonicalFileLinkedSet(): MutableSet<File> = ObjectLinkedOpenCustomHashSet(FileHashStrategy)
|
||||||
}
|
}
|
||||||
|
|
||||||
public static @NotNull Set<String> createCanonicalFilePathSet() {
|
@Internal
|
||||||
return new ObjectOpenCustomHashSet<>(FastUtilHashingStrategies.FILE_PATH_HASH_STRATEGY);
|
object FileHashStrategy : Hash.Strategy<File>, Serializable {
|
||||||
}
|
override fun hashCode(o: File?): Int = FileUtilRt.pathHashCode(o?.path)
|
||||||
|
|
||||||
public static @NotNull Set<File> createCanonicalFileLinkedSet() {
|
override fun equals(a: File?, b: File?): Boolean = FileUtilRt.pathsEqual(a?.path, b?.path)
|
||||||
return new ObjectLinkedOpenCustomHashSet<>(new Hash.Strategy<File>() {
|
}
|
||||||
@Override
|
|
||||||
public int hashCode(@Nullable File o) {
|
private object PathHashStrategy : Hash.Strategy<Path>, Serializable {
|
||||||
return FileUtilRt.pathHashCode(o == null ? null : o.getPath());
|
override fun hashCode(o: Path?): Int = FileUtilRt.pathHashCode(o?.toString())
|
||||||
}
|
|
||||||
|
override fun equals(a: Path?, b: Path?): Boolean = FileUtilRt.pathsEqual(a?.toString(), b?.toString())
|
||||||
@Override
|
|
||||||
public boolean equals(@Nullable File a, @Nullable File b) {
|
|
||||||
return FileUtilRt.pathsEqual(a == null ? null : a.getPath(), b == null ? null : b.getPath());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final class PathSerializableHashStrategy implements FastUtilHashingStrategies.SerializableHashStrategy<Path> {
|
|
||||||
@Override
|
|
||||||
public int hashCode(@Nullable Path o) {
|
|
||||||
return FileUtilRt.pathHashCode(o == null ? null : o.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(@Nullable Path a, @Nullable Path b) {
|
|
||||||
return FileUtilRt.pathsEqual(a == null ? null : a.toString(), b == null ? null : b.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||||
package com.intellij.openapi.vcs.changes.ui
|
package com.intellij.openapi.vcs.changes.ui
|
||||||
|
|
||||||
import com.intellij.openapi.Disposable
|
import com.intellij.openapi.Disposable
|
||||||
@@ -30,12 +30,12 @@ abstract class PartiallyExcludedFilesStateHolder<T>(
|
|||||||
return getChangeListId(element)?.let { getExcludedFromCommitState(it) } ?: ExclusionState.NO_CHANGES
|
return getChangeListId(element)?.let { getExcludedFromCommitState(it) } ?: ExclusionState.NO_CHANGES
|
||||||
}
|
}
|
||||||
|
|
||||||
protected val myUpdateQueue =
|
protected val updateQueue =
|
||||||
MergingUpdateQueue(PartiallyExcludedFilesStateHolder::class.java.name, 300, true, MergingUpdateQueue.ANY_COMPONENT, this)
|
MergingUpdateQueue(PartiallyExcludedFilesStateHolder::class.java.name, 300, true, MergingUpdateQueue.ANY_COMPONENT, this)
|
||||||
|
|
||||||
private val lock = ReentrantReadWriteLock()
|
private val lock = ReentrantReadWriteLock()
|
||||||
private val myIncludedElements: MutableSet<T> = createElementsSet()
|
private val includedElements = createElementsSet()
|
||||||
private val myTrackerExclusionStates: MutableMap<T, ExclusionState> = CollectionFactory.createCustomHashingStrategyMap(hashingStrategy)
|
private val trackerExclusionStates = CollectionFactory.createCustomHashingStrategyMap<T, ExclusionState>(hashingStrategy)
|
||||||
|
|
||||||
init {
|
init {
|
||||||
MyTrackerManagerListener().install(project)
|
MyTrackerManagerListener().install(project)
|
||||||
@@ -45,7 +45,8 @@ abstract class PartiallyExcludedFilesStateHolder<T>(
|
|||||||
return CollectionFactory.createCustomHashingStrategySet(hashingStrategy).also { it.addAll(elements) }
|
return CollectionFactory.createCustomHashingStrategySet(hashingStrategy).also { it.addAll(elements) }
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun dispose() = Unit
|
override fun dispose() {
|
||||||
|
}
|
||||||
|
|
||||||
protected abstract val trackableElements: Sequence<T>
|
protected abstract val trackableElements: Sequence<T>
|
||||||
protected abstract fun getChangeListId(element: T): String?
|
protected abstract fun getChangeListId(element: T): String?
|
||||||
@@ -57,7 +58,7 @@ abstract class PartiallyExcludedFilesStateHolder<T>(
|
|||||||
get() = trackableElements.mapNotNull { element -> findTrackerFor(element)?.let { tracker -> element to tracker } }
|
get() = trackableElements.mapNotNull { element -> findTrackerFor(element)?.let { tracker -> element to tracker } }
|
||||||
|
|
||||||
private fun scheduleExclusionStatesUpdate() {
|
private fun scheduleExclusionStatesUpdate() {
|
||||||
myUpdateQueue.queue(DisposableUpdate.createDisposable(myUpdateQueue, "updateExcludedFromCommit") { updateExclusionStates() })
|
updateQueue.queue(DisposableUpdate.createDisposable(updateQueue, "updateExcludedFromCommit") { updateExclusionStates() })
|
||||||
}
|
}
|
||||||
|
|
||||||
private inner class MyTrackerListener : PartialLocalLineStatusTracker.ListenerAdapter() {
|
private inner class MyTrackerListener : PartialLocalLineStatusTracker.ListenerAdapter() {
|
||||||
@@ -82,7 +83,7 @@ abstract class PartiallyExcludedFilesStateHolder<T>(
|
|||||||
if (tracker !is PartialLocalLineStatusTracker) return
|
if (tracker !is PartialLocalLineStatusTracker) return
|
||||||
|
|
||||||
tracker.getAffectedChangeListsIds().forEach { changeListId ->
|
tracker.getAffectedChangeListsIds().forEach { changeListId ->
|
||||||
findElementFor(tracker, changeListId)?.let { element -> tracker.setExcludedFromCommit(element, element !in myIncludedElements) }
|
findElementFor(tracker, changeListId)?.let { element -> tracker.setExcludedFromCommit(element, element !in includedElements) }
|
||||||
}
|
}
|
||||||
tracker.addListener(trackerListener, disposable)
|
tracker.addListener(trackerListener, disposable)
|
||||||
}
|
}
|
||||||
@@ -97,13 +98,13 @@ abstract class PartiallyExcludedFilesStateHolder<T>(
|
|||||||
val exclusionState = tracker.getExcludedFromCommitState(element)
|
val exclusionState = tracker.getExcludedFromCommitState(element)
|
||||||
|
|
||||||
lock.write {
|
lock.write {
|
||||||
myTrackerExclusionStates -= element
|
trackerExclusionStates -= element
|
||||||
if (exclusionState != ExclusionState.NO_CHANGES) {
|
if (exclusionState != ExclusionState.NO_CHANGES) {
|
||||||
if (exclusionState != ExclusionState.ALL_EXCLUDED) {
|
if (exclusionState != ExclusionState.ALL_EXCLUDED) {
|
||||||
myIncludedElements += element
|
includedElements += element
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
myIncludedElements -= element
|
includedElements -= element
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -115,8 +116,8 @@ abstract class PartiallyExcludedFilesStateHolder<T>(
|
|||||||
|
|
||||||
fun getIncludedSet(): Set<T> {
|
fun getIncludedSet(): Set<T> {
|
||||||
lock.read {
|
lock.read {
|
||||||
val set: MutableSet<T> = createElementsSet(myIncludedElements)
|
val set: MutableSet<T> = createElementsSet(includedElements)
|
||||||
myTrackerExclusionStates.forEach { (element, state) ->
|
trackerExclusionStates.forEach { (element, state) ->
|
||||||
if (state == ExclusionState.ALL_EXCLUDED) set -= element else set += element
|
if (state == ExclusionState.ALL_EXCLUDED) set -= element else set += element
|
||||||
}
|
}
|
||||||
return set
|
return set
|
||||||
@@ -125,9 +126,9 @@ abstract class PartiallyExcludedFilesStateHolder<T>(
|
|||||||
|
|
||||||
fun getExclusionState(element: T): ExclusionState {
|
fun getExclusionState(element: T): ExclusionState {
|
||||||
lock.read {
|
lock.read {
|
||||||
val trackerState = myTrackerExclusionStates[element]
|
val trackerState = trackerExclusionStates[element]
|
||||||
if (trackerState != null) return trackerState
|
if (trackerState != null) return trackerState
|
||||||
val isIncluded = element in myIncludedElements
|
val isIncluded = element in includedElements
|
||||||
return if (isIncluded) ExclusionState.ALL_INCLUDED else ExclusionState.ALL_EXCLUDED
|
return if (isIncluded) ExclusionState.ALL_INCLUDED else ExclusionState.ALL_EXCLUDED
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -144,11 +145,11 @@ abstract class PartiallyExcludedFilesStateHolder<T>(
|
|||||||
@RequiresEdt
|
@RequiresEdt
|
||||||
private fun rebuildTrackerExclusionStates() {
|
private fun rebuildTrackerExclusionStates() {
|
||||||
assert(lock.isWriteLocked)
|
assert(lock.isWriteLocked)
|
||||||
myTrackerExclusionStates.clear()
|
trackerExclusionStates.clear()
|
||||||
|
|
||||||
trackers.forEach { (element, tracker) ->
|
trackers.forEach { (element, tracker) ->
|
||||||
val state = tracker.getExcludedFromCommitState(element)
|
val state = tracker.getExcludedFromCommitState(element)
|
||||||
if (state != ExclusionState.NO_CHANGES) myTrackerExclusionStates[element] = state
|
if (state != ExclusionState.NO_CHANGES) trackerExclusionStates[element] = state
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -160,8 +161,8 @@ abstract class PartiallyExcludedFilesStateHolder<T>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
lock.write {
|
lock.write {
|
||||||
myIncludedElements.clear()
|
includedElements.clear()
|
||||||
myIncludedElements += elements
|
includedElements += elements
|
||||||
rebuildTrackerExclusionStates()
|
rebuildTrackerExclusionStates()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -173,7 +174,7 @@ abstract class PartiallyExcludedFilesStateHolder<T>(
|
|||||||
elements.forEach { findTrackerFor(it)?.setExcludedFromCommit(it, false) }
|
elements.forEach { findTrackerFor(it)?.setExcludedFromCommit(it, false) }
|
||||||
|
|
||||||
lock.write {
|
lock.write {
|
||||||
myIncludedElements += elements
|
includedElements += elements
|
||||||
rebuildTrackerExclusionStates()
|
rebuildTrackerExclusionStates()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -188,7 +189,7 @@ abstract class PartiallyExcludedFilesStateHolder<T>(
|
|||||||
|
|
||||||
lock.write {
|
lock.write {
|
||||||
for (element in elements) {
|
for (element in elements) {
|
||||||
myIncludedElements.remove(element)
|
includedElements.remove(element)
|
||||||
}
|
}
|
||||||
rebuildTrackerExclusionStates()
|
rebuildTrackerExclusionStates()
|
||||||
}
|
}
|
||||||
@@ -207,7 +208,7 @@ abstract class PartiallyExcludedFilesStateHolder<T>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
lock.write {
|
lock.write {
|
||||||
myIncludedElements.retainAll(toRetain)
|
includedElements.retainAll(toRetain)
|
||||||
rebuildTrackerExclusionStates()
|
rebuildTrackerExclusionStates()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||||
package com.intellij.openapi.vcs
|
package com.intellij.openapi.vcs
|
||||||
|
|
||||||
import com.intellij.openapi.util.Disposer
|
import com.intellij.openapi.util.Disposer
|
||||||
@@ -46,7 +46,7 @@ abstract class BasePartiallyExcludedChangesTest : BaseLineStatusTrackerManagerTe
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun waitExclusionStateUpdate() {
|
fun waitExclusionStateUpdate() {
|
||||||
myUpdateQueue.flush()
|
updateQueue.flush()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user