use of gnu.trove.TIntHashSet in project intellij-community by JetBrains.
the class AbstractDataGetter method runLoadCommitsData.
private void runLoadCommitsData(@NotNull Iterable<Integer> hashes) {
long taskNumber = myCurrentTaskIndex++;
TIntIntHashMap commits = getCommitsMap(hashes);
TIntHashSet toLoad = new TIntHashSet();
for (int id : commits.keys()) {
cacheCommit(id, taskNumber);
toLoad.add(id);
}
myLoader.queue(new TaskDescriptor(toLoad));
}
use of gnu.trove.TIntHashSet in project intellij-community by JetBrains.
the class XLineBreakpointManager method updateBreakpoints.
private void updateBreakpoints(@NotNull Document document) {
Collection<XLineBreakpointImpl> breakpoints = myBreakpoints.getKeysByValue(document);
if (breakpoints == null) {
return;
}
TIntHashSet lines = new TIntHashSet();
List<XBreakpoint<?>> toRemove = new SmartList<>();
for (XLineBreakpointImpl breakpoint : breakpoints) {
breakpoint.updatePosition();
if (!breakpoint.isValid() || !lines.add(breakpoint.getLine())) {
toRemove.add(breakpoint);
}
}
removeBreakpoints(toRemove);
}
use of gnu.trove.TIntHashSet in project intellij-community by JetBrains.
the class PersistentFSImpl method validateEvents.
@NotNull
private static List<VFileEvent> validateEvents(@NotNull List<VFileEvent> events) {
final List<EventWrapper> deletionEvents = ContainerUtil.newArrayList();
for (int i = 0, size = events.size(); i < size; i++) {
final VFileEvent event = events.get(i);
if (event instanceof VFileDeleteEvent && event.isValid()) {
deletionEvents.add(new EventWrapper((VFileDeleteEvent) event, i));
}
}
final TIntHashSet invalidIDs;
if (deletionEvents.isEmpty()) {
invalidIDs = EmptyIntHashSet.INSTANCE;
} else {
ContainerUtil.quickSort(deletionEvents, DEPTH_COMPARATOR);
invalidIDs = new TIntHashSet(deletionEvents.size());
final Set<VirtualFile> dirsToBeDeleted = new THashSet<>(deletionEvents.size());
nextEvent: for (EventWrapper wrapper : deletionEvents) {
final VirtualFile candidate = wrapper.event.getFile();
VirtualFile parent = candidate;
while (parent != null) {
if (dirsToBeDeleted.contains(parent)) {
invalidIDs.add(wrapper.id);
continue nextEvent;
}
parent = parent.getParent();
}
if (candidate.isDirectory()) {
dirsToBeDeleted.add(candidate);
}
}
}
final List<VFileEvent> filtered = new ArrayList<>(events.size() - invalidIDs.size());
for (int i = 0, size = events.size(); i < size; i++) {
final VFileEvent event = events.get(i);
if (event.isValid() && !(event instanceof VFileDeleteEvent && invalidIDs.contains(i))) {
filtered.add(event);
}
}
return filtered;
}
use of gnu.trove.TIntHashSet in project intellij-community by JetBrains.
the class PersistentFSImpl method applyChildrenChangeEvents.
private void applyChildrenChangeEvents(@NotNull VirtualFile parent, @NotNull List<VFileEvent> events) {
final NewVirtualFileSystem delegate = getDelegate(parent);
TIntArrayList childrenIdsUpdated = new TIntArrayList();
final int parentId = getFileId(parent);
assert parentId != 0;
TIntHashSet parentChildrenIds = new TIntHashSet(FSRecords.list(parentId));
boolean hasRemovedChildren = false;
List<VirtualFile> childrenToBeUpdated = new SmartList<>();
for (VFileEvent event : events) {
if (event instanceof VFileCreateEvent) {
String name = ((VFileCreateEvent) event).getChildName();
final VirtualFile fake = new FakeVirtualFile(parent, name);
final FileAttributes attributes = delegate.getAttributes(fake);
if (attributes != null) {
final int childId = createAndFillRecord(delegate, fake, parentId, attributes);
assert parent instanceof VirtualDirectoryImpl : parent;
final VirtualDirectoryImpl dir = (VirtualDirectoryImpl) parent;
VirtualFileSystemEntry child = dir.createChild(name, childId, dir.getFileSystem());
childrenToBeUpdated.add(child);
childrenIdsUpdated.add(childId);
parentChildrenIds.add(childId);
}
} else if (event instanceof VFileDeleteEvent) {
VirtualFile file = ((VFileDeleteEvent) event).getFile();
if (!file.exists()) {
LOG.error("Deleting a file, which does not exist: " + file.getPath());
continue;
}
hasRemovedChildren = true;
int id = getFileId(file);
childrenToBeUpdated.add(file);
childrenIdsUpdated.add(-id);
parentChildrenIds.remove(id);
}
}
FSRecords.updateList(parentId, parentChildrenIds.toArray());
if (hasRemovedChildren)
clearIdCache();
VirtualDirectoryImpl parentImpl = (VirtualDirectoryImpl) parent;
for (int i = 0, len = childrenIdsUpdated.size(); i < len; ++i) {
final int childId = childrenIdsUpdated.get(i);
final VirtualFile childFile = childrenToBeUpdated.get(i);
if (childId > 0) {
parentImpl.addChild((VirtualFileSystemEntry) childFile);
} else {
FSRecords.deleteRecordRecursively(-childId);
parentImpl.removeChild(childFile);
invalidateSubtree(childFile);
}
}
}
use of gnu.trove.TIntHashSet in project intellij-community by JetBrains.
the class VirtualDirectoryImpl method getChildren.
@Override
@NotNull
public VirtualFile[] getChildren() {
if (!isValid()) {
throw new InvalidVirtualFileAccessException(this);
}
NewVirtualFileSystem delegate = getFileSystem();
final boolean ignoreCase = !delegate.isCaseSensitive();
synchronized (myData) {
if (allChildrenLoaded()) {
assertConsistency(ignoreCase, "");
return getArraySafely();
}
final boolean wasChildrenLoaded = ourPersistence.areChildrenLoaded(this);
final FSRecords.NameId[] childrenIds = ourPersistence.listAll(this);
int[] result;
if (childrenIds.length == 0) {
result = ArrayUtil.EMPTY_INT_ARRAY;
} else {
Arrays.sort(childrenIds, (o1, o2) -> {
CharSequence name1 = o1.name;
CharSequence name2 = o2.name;
int cmp = compareNames(name1, name2, ignoreCase);
if (cmp == 0 && name1 != name2) {
LOG.error(ourPersistence + " returned duplicate file names(" + name1 + "," + name2 + ")" + " ignoreCase: " + ignoreCase + " SystemInfo.isFileSystemCaseSensitive: " + SystemInfo.isFileSystemCaseSensitive + " SystemInfo.OS: " + SystemInfo.OS_NAME + " " + SystemInfo.OS_VERSION + " wasChildrenLoaded: " + wasChildrenLoaded + " in the dir: " + this + ";" + " children: " + Arrays.toString(childrenIds));
}
return cmp;
});
TIntHashSet prevChildren = new TIntHashSet(myData.myChildrenIds);
result = new int[childrenIds.length];
for (int i = 0; i < childrenIds.length; i++) {
FSRecords.NameId child = childrenIds[i];
result[i] = child.id;
assert child.id > 0 : child;
prevChildren.remove(child.id);
if (VfsData.getFileById(child.id, this) == null) {
createChild(child.nameId, child.id, delegate);
}
}
if (!prevChildren.isEmpty()) {
LOG.error("Loaded child disappeared: " + "parent=" + verboseToString.fun(this) + "; child=" + verboseToString.fun(VfsData.getFileById(prevChildren.toArray()[0], this)));
}
}
if (getId() > 0) {
myData.myChildrenIds = result;
if (CHECK) {
assertConsistency(ignoreCase, Arrays.asList(childrenIds));
}
setChildrenLoaded();
}
return getArraySafely();
}
}
Aggregations