Search in sources :

Example 36 with TIntHashSet

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));
}
Also used : TIntIntHashMap(gnu.trove.TIntIntHashMap) TIntHashSet(gnu.trove.TIntHashSet)

Example 37 with TIntHashSet

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);
}
Also used : XBreakpoint(com.intellij.xdebugger.breakpoints.XBreakpoint) SmartList(com.intellij.util.SmartList) TIntHashSet(gnu.trove.TIntHashSet)

Example 38 with TIntHashSet

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;
}
Also used : TIntArrayList(gnu.trove.TIntArrayList) TIntHashSet(gnu.trove.TIntHashSet) THashSet(gnu.trove.THashSet) NotNull(org.jetbrains.annotations.NotNull)

Example 39 with TIntHashSet

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);
        }
    }
}
Also used : TIntArrayList(gnu.trove.TIntArrayList) TIntHashSet(gnu.trove.TIntHashSet)

Example 40 with TIntHashSet

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();
    }
}
Also used : FSRecords(com.intellij.openapi.vfs.newvfs.persistent.FSRecords) NewVirtualFileSystem(com.intellij.openapi.vfs.newvfs.NewVirtualFileSystem) InvalidVirtualFileAccessException(com.intellij.openapi.vfs.InvalidVirtualFileAccessException) TIntHashSet(gnu.trove.TIntHashSet) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

TIntHashSet (gnu.trove.TIntHashSet)50 NotNull (org.jetbrains.annotations.NotNull)16 TIntArrayList (gnu.trove.TIntArrayList)5 VirtualFile (com.intellij.openapi.vfs.VirtualFile)4 IOException (java.io.IOException)4 Nullable (org.jetbrains.annotations.Nullable)4 TIntProcedure (gnu.trove.TIntProcedure)3 ArrayList (java.util.ArrayList)3 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)2 Processor (com.intellij.util.Processor)2 StorageException (com.intellij.util.indexing.StorageException)2 CharArrayCharSequence (com.intellij.util.text.CharArrayCharSequence)2 THashSet (gnu.trove.THashSet)2 TIntIterator (gnu.trove.TIntIterator)2 LightRef (org.jetbrains.jps.backwardRefs.LightRef)2 GenerateMembersUtil (com.intellij.codeInsight.generation.GenerateMembersUtil)1 Edge (com.intellij.codeInspection.bytecodeAnalysis.asm.ControlFlowGraph.Edge)1 CompilerReferenceFindUsagesTestInfo (com.intellij.compiler.backwardRefs.view.CompilerReferenceFindUsagesTestInfo)1 DirtyScopeTestInfo (com.intellij.compiler.backwardRefs.view.DirtyScopeTestInfo)1 PluginException (com.intellij.diagnostic.PluginException)1