gnu.trove.TIntHashSet Java Examples

The following examples show how to use gnu.trove.TIntHashSet. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PersistentFSImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
private void applyCreateEventsInDirectory(@Nonnull VirtualDirectoryImpl parent, @Nonnull Collection<? extends VFileCreateEvent> createEvents) {
  int parentId = getFileId(parent);
  NewVirtualFile vf = findFileById(parentId);
  if (!(vf instanceof VirtualDirectoryImpl)) return;
  parent = (VirtualDirectoryImpl)vf;  // retain in myIdToDirCache at least for the duration of this block in order to subsequent findFileById() won't crash
  final NewVirtualFileSystem delegate = replaceWithNativeFS(getDelegate(parent));
  TIntHashSet parentChildrenIds = new TIntHashSet(createEvents.size());

  List<ChildInfo> childrenAdded = getOrCreateChildInfos(parent, createEvents, VFileCreateEvent::getChildName, parentChildrenIds, delegate, (createEvent, childId) -> {
    createEvent.resetCache();
    String name = createEvent.getChildName();
    Pair<FileAttributes, String> childData = getChildData(delegate, createEvent.getParent(), name, createEvent.getAttributes(), createEvent.getSymlinkTarget());
    if (childData == null) return null;
    childId = makeChildRecord(parentId, name, childData, delegate);
    return new ChildInfoImpl(childId, name, childData.first, createEvent.getChildren(), createEvent.getSymlinkTarget());
  });
  FSRecords.updateList(parentId, parentChildrenIds.toArray());
  parent.createAndAddChildren(childrenAdded, false, (__, ___) -> {
  });

  saveScannedChildrenRecursively(createEvents, delegate);
}
 
Example #2
Source File: ContributorsBasedGotoByModel.java    From consulo with Apache License 2.0 6 votes vote down vote up
public void processContributorNames(@Nonnull ChooseByNameContributor contributor, @Nonnull FindSymbolParameters parameters, @Nonnull Processor<? super String> nameProcessor) {
  TIntHashSet filter = new TIntHashSet(1000);
  if (contributor instanceof ChooseByNameContributorEx) {
    ((ChooseByNameContributorEx)contributor).processNames(s -> {
      if (nameProcessor.process(s)) {
        filter.add(s.hashCode());
      }
      return true;
    }, parameters.getSearchScope(), parameters.getIdFilter());
  }
  else {
    String[] names = contributor.getNames(myProject, parameters.isSearchInLibraries());
    for (String element : names) {
      if (nameProcessor.process(element)) {
        filter.add(element.hashCode());
      }
    }
  }
  myContributorToItsSymbolsMap.put(contributor, filter);
}
 
Example #3
Source File: VcsLogPersistentIndex.java    From consulo with Apache License 2.0 6 votes vote down vote up
private boolean indexOneByOne(@Nonnull VirtualFile root, @Nonnull TIntHashSet commits) {
  VcsLogProvider provider = myProviders.get(root);
  try {
    List<String> hashes = TroveUtil.map(commits, value -> myHashMap.getCommitId(value).getHash().asString());
    provider.readFullDetails(root, hashes, VcsLogPersistentIndex.this::storeDetail);
  }
  catch (VcsException e) {
    LOG.error(e);
    commits.forEach(value -> {
      markForIndexing(value, root);
      return true;
    });
    return false;
  }
  return true;
}
 
Example #4
Source File: TreeNode.java    From semafor-semantic-parser with GNU General Public License v3.0 6 votes vote down vote up
/**
 * 
 * @param alevel Level (depth) of the desired ancestor
 * @param ancPath A list to be populated with indices of nodes searched (starting with the current node), provided that an ancestor node at the specified level exists; or null.
 * @param alreadySearched Indices of nodes which have already been searched. If non-null, 'this' will be returned if (and only if) a member of this set is encountered in the ancestor path. 
 * @return Ancestor node of the current node whose level is 'alevel', or null if no such ancestor exists. A node is not considered to be its own ancestor.
 * @author Nathan Schneider (nschneid)
 */
@SuppressWarnings("unchecked")
public T getAncestorAtLevel(int alevel, TIntArrayList ancPath, TIntHashSet alreadySearched) {
	if (alevel < 0 || alevel >= this.depth)	// A node at this level is not strictly an ancestor
		return null;
	
	TreeNode<T> node = this;
	for (int d=this.depth; d>alevel; d--) {
		if (ancPath!=null)
			ancPath.add(node.index);
		if (alreadySearched!=null && alreadySearched.contains(node.index))
			return (T)this;
		node = node.getParent();
	}
	return (T)node;
}
 
Example #5
Source File: SoftWrapApplianceOnDocumentModificationTest.java    From consulo with Apache License 2.0 6 votes vote down vote up
public void testTrailingSoftWrapOffsetShiftOnTyping() throws IOException {
  // The main idea is to type on a logical line before soft wrap in order to ensure that its offset is correctly shifted back.
  String text =
          "line1<caret>\n" +
          "second line that is long enough to be soft wrapped";
  init(15, text);

  TIntHashSet offsetsBefore = collectSoftWrapStartOffsets(1);
  assertTrue(!offsetsBefore.isEmpty());

  type('2');
  final TIntHashSet offsetsAfter = collectSoftWrapStartOffsets(1);
  assertSame(offsetsBefore.size(), offsetsAfter.size());
  offsetsBefore.forEach(value -> {
    assertTrue(offsetsAfter.contains(value + 1));
    return true;
  });
}
 
Example #6
Source File: VfsAwareMapIndexStorage.java    From consulo with Apache License 2.0 6 votes vote down vote up
private void saveHashedIds(@Nonnull TIntHashSet hashMaskSet, int largestId, @Nonnull GlobalSearchScope scope) {
  File newFileWithCaches = getSavedProjectFileValueIds(largestId, scope);
  assert newFileWithCaches != null;

  boolean savedSuccessfully;
  try (DataOutputStream stream = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(newFileWithCaches)))) {
    DataInputOutputUtil.writeINT(stream, hashMaskSet.size());
    savedSuccessfully = hashMaskSet.forEach(value -> {
      try {
        DataInputOutputUtil.writeINT(stream, value);
        return true;
      }
      catch (IOException ex) {
        return false;
      }
    });
  }
  catch (IOException ignored) {
    savedSuccessfully = false;
  }
  if (savedSuccessfully) {
    myLastScannedId = largestId;
  }
}
 
Example #7
Source File: VcsLogPathsIndex.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nonnull
public Set<Integer> addCommitsAndGetRenames(@Nonnull Set<Integer> newPathIds,
                                            @Nonnull Set<Integer> allPathIds,
                                            @Nonnull TIntHashSet commits)
        throws StorageException {
  Set<Integer> renames = ContainerUtil.newHashSet();
  for (Integer key : newPathIds) {
    iterateCommitIdsAndValues(key, (value, commit) -> {
      commits.add(commit);
      if (value != null && !allPathIds.contains(value)) {
        renames.add(value);
      }
    });
  }
  return renames;
}
 
Example #8
Source File: VcsLogGraphTable.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nonnull
private Pair<TIntHashSet, Integer> findRowsToSelectAndScroll(@Nonnull GraphTableModel model,
                                                             @Nonnull VisibleGraph<Integer> visibleGraph) {
  TIntHashSet rowsToSelect = new TIntHashSet();

  if (model.getRowCount() == 0) {
    // this should have been covered by facade.getVisibleCommitCount,
    // but if the table is empty (no commits match the filter), the GraphFacade is not updated, because it can't handle it
    // => it has previous values set.
    return Pair.create(rowsToSelect, null);
  }

  Integer rowToScroll = null;
  for (int row = 0;
       row < visibleGraph.getVisibleCommitCount() && (rowsToSelect.size() < mySelectedCommits.size() || rowToScroll == null);
       row++) { //stop iterating if found all hashes
    int commit = visibleGraph.getRowInfo(row).getCommit();
    if (mySelectedCommits.contains(commit)) {
      rowsToSelect.add(row);
    }
    if (myVisibleSelectedCommit != null && myVisibleSelectedCommit == commit) {
      rowToScroll = row;
    }
  }
  return Pair.create(rowsToSelect, rowToScroll);
}
 
Example #9
Source File: VirtualDirectoryImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
public void removeChildren(@Nonnull TIntHashSet idsToRemove, @Nonnull List<? extends CharSequence> namesToRemove) {
  boolean caseSensitive = getFileSystem().isCaseSensitive();
  synchronized (myData) {
    // remove from array by merging two sorted lists
    int[] newIds = new int[myData.myChildrenIds.length];
    int[] oldIds = myData.myChildrenIds;
    int o = 0;
    for (int oldId : oldIds) {
      if (!idsToRemove.contains(oldId)) {
        newIds[o++] = oldId;
      }
    }
    if (o != newIds.length) {
      newIds = o == 0 ? ArrayUtilRt.EMPTY_INT_ARRAY : Arrays.copyOf(newIds, o);
    }
    myData.myChildrenIds = newIds;

    if (!allChildrenLoaded()) {
      myData.addAdoptedNames(namesToRemove, caseSensitive);
    }

    assertConsistency(caseSensitive, namesToRemove);
  }
}
 
Example #10
Source File: Incremental.java    From jatecs with GNU General Public License v3.0 6 votes vote down vote up
public Incremental(int trainSize, ClassificationScoreDB classification, TIntHashSet categoriesFilter,
                   EstimationType estimation, ContingencyTableSet evaluation, IGain gain, IGain firstRankGain, double[] probabilitySlope, double[] prevalencies) {
    super(trainSize, classification, categoriesFilter, estimation, evaluation, firstRankGain, probabilitySlope, prevalencies);
    macroRankTable = new TIntDoubleHashMap((int) (testSize + testSize * 0.25), (float) 0.75);
    microRankTable = new TIntDoubleHashMap((int) (testSize + testSize * 0.25), (float) 0.75);
    macroAlreadySeen = new TIntHashSet((int) (testSize + testSize * 0.25), (float) 0.75);
    microAlreadySeen = new TIntHashSet((int) (testSize + testSize * 0.25), (float) 0.75);
    probabilities = new double[testSize][numOfCategories];
    for (int docId = 0; docId < testSize; docId++) {
        Set<Entry<Short, ClassifierRangeWithScore>> entries = classification.getDocumentScoresAsSet(docId);
        Iterator<Entry<Short, ClassifierRangeWithScore>> iterator = entries.iterator();
        while (iterator.hasNext()) {
            Entry<Short, ClassifierRangeWithScore> next = iterator.next();
            ClassifierRangeWithScore value = next.getValue();
            if (categoriesFilter.contains(next.getKey())) {
                probabilities[docId][catMap.get(next.getKey())] = probability(Math.abs(value.score - value.border), next.getKey());
            }
        }
    }
}
 
Example #11
Source File: ChangeListStorageImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
public synchronized void purge(long period, int intervalBetweenActivities, Consumer<ChangeSet> processor) {
  if (isCompletelyBroken) return;

  TIntHashSet recursionGuard = new TIntHashSet(1000);

  try {
    int firstObsoleteId = findFirstObsoleteBlock(period, intervalBetweenActivities, recursionGuard);
    if (firstObsoleteId == 0) return;

    int eachBlockId = firstObsoleteId;

    while (eachBlockId != 0) {
      processor.consume(doReadBlock(eachBlockId).changeSet);
      eachBlockId = doReadPrevSafely(eachBlockId, recursionGuard);
    }
    myStorage.deleteRecordsUpTo(firstObsoleteId);
    myStorage.force();
  }
  catch (IOException e) {
    handleError(e, null);
  }
}
 
Example #12
Source File: ChangeListStorageImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
private int findFirstObsoleteBlock(long period, int intervalBetweenActivities, TIntHashSet recursionGuard) throws IOException {
  long prevTimestamp = 0;
  long length = 0;

  int last = myStorage.getLastRecord();
  while (last != 0) {
    long t = myStorage.getTimestamp(last);
    if (prevTimestamp == 0) prevTimestamp = t;

    long delta = prevTimestamp - t;
    prevTimestamp = t;

    // we sum only intervals between changes during one 'day' (intervalBetweenActivities) and add '1' between two 'days'
    length += delta < intervalBetweenActivities ? delta : 1;

    if (length >= period) return last;

    last = doReadPrevSafely(last, recursionGuard);
  }

  return 0;
}
 
Example #13
Source File: ChangeTrackingValueContainer.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void saveTo(DataOutput out, DataExternalizer<? super Value> externalizer) throws IOException {
  if (needsCompacting()) {
    getMergedData().saveTo(out, externalizer);
  }
  else {
    final TIntHashSet set = myInvalidated;
    if (set != null && set.size() > 0) {
      for (int inputId : set.toArray()) {
        DataInputOutputUtil.writeINT(out, -inputId); // mark inputId as invalid, to be processed on load in ValueContainerImpl.readFrom
      }
    }

    final UpdatableValueContainer<Value> toAppend = myAdded;
    if (toAppend != null && toAppend.size() > 0) {
      toAppend.saveTo(out, externalizer);
    }
  }
}
 
Example #14
Source File: SATCsimulation.java    From jatecs with GNU General Public License v3.0 6 votes vote down vote up
@SuppressWarnings("unused")
private static IClassificationDB mixClassifications(
        IClassificationDB trueClassification,
        IClassificationDB predictedClassification,
        TIntHashSet fromTrueClassification) {
    TroveClassificationDBBuilder builder = new TroveClassificationDBBuilder(
            trueClassification.getDocumentDB(),
            trueClassification.getCategoryDB());

    IIntIterator documents = trueClassification.getDocumentDB()
            .getDocuments();
    while (documents.hasNext()) {
        int document = documents.next();
        if (fromTrueClassification.contains(document))
            copyClassification(document, trueClassification, builder);
        else
            copyClassification(document, predictedClassification, builder);
    }
    return builder.getClassificationDB();
}
 
Example #15
Source File: XLineBreakpointManager.java    From consulo with Apache License 2.0 6 votes vote down vote up
private void updateBreakpoints(@Nonnull 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);
}
 
Example #16
Source File: CompactVirtualFileSet.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
public Iterator<VirtualFile> iterator() {
  BitSet ids = fileIds;
  TIntHashSet idSet = this.idSet;
  VirtualFileManager virtualFileManager = VirtualFileManager.getInstance();
  Iterator<VirtualFile> idsIterator = ids == null ? Collections.emptyIterator() : ContainerUtil.mapIterator(ids.stream().iterator(), id -> virtualFileManager.findFileById(id));
  Iterator<VirtualFile> idSetIterator = idSet == null ? Collections.emptyIterator() : ContainerUtil.mapIterator(idSet.iterator(), id -> virtualFileManager.findFileById(id));
  Iterator<VirtualFile> weirdFileIterator = weirdFiles.iterator();
  return ContainerUtil.filterIterator(ContainerUtil.concatIterators(idsIterator, idSetIterator, weirdFileIterator), Objects::nonNull);
}
 
Example #17
Source File: PersistentFSImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
private void applyDeletions(@Nonnull MultiMap<VirtualDirectoryImpl, VFileDeleteEvent> deletions) {
  for (Map.Entry<VirtualDirectoryImpl, Collection<VFileDeleteEvent>> entry : deletions.entrySet()) {
    VirtualDirectoryImpl parent = entry.getKey();
    Collection<VFileDeleteEvent> deleteEvents = entry.getValue();
    // no valid containing directory, apply events the old way - one by one
    if (parent == null || !parent.isValid()) {
      deleteEvents.forEach(this::applyEvent);
      return;
    }

    int parentId = getFileId(parent);
    int[] oldIds = FSRecords.list(parentId);
    TIntHashSet parentChildrenIds = new TIntHashSet(oldIds);

    List<CharSequence> childrenNamesDeleted = new ArrayList<>(deleteEvents.size());
    TIntHashSet childrenIdsDeleted = new TIntHashSet(deleteEvents.size());

    for (VFileDeleteEvent event : deleteEvents) {
      VirtualFile file = event.getFile();
      int id = getFileId(file);
      childrenNamesDeleted.add(file.getNameSequence());
      childrenIdsDeleted.add(id);
      FSRecords.deleteRecordRecursively(id);
      invalidateSubtree(file);
      parentChildrenIds.remove(id);
    }
    FSRecords.updateList(parentId, parentChildrenIds.toArray());
    parent.removeChildren(childrenIdsDeleted, childrenNamesDeleted);
  }
}
 
Example #18
Source File: IntToIntSetMap.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void removeOccurence(int key, int value) {
  if (mySingle.containsKey(key)) {
    mySingle.remove(key);
    return;
  }
  TIntHashSet items = myMulti.get(key);
  if (items != null) {
    items.remove(value);
    if (items.size() == 1) {
      mySingle.put(key, items.toArray()[0]);
      myMulti.remove(key);
    }
  }
}
 
Example #19
Source File: PersistentFSImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
private static void saveScannedChildrenRecursively(@Nonnull Collection<? extends VFileCreateEvent> createEvents, @Nonnull NewVirtualFileSystem delegate) {
  for (VFileCreateEvent createEvent : createEvents) {
    ChildInfo[] children = createEvent.getChildren();
    if (children == null || !createEvent.isDirectory()) continue;
    // todo avoid expensive findFile
    VirtualFile createdDir = createEvent.getFile();
    if (createdDir instanceof VirtualDirectoryImpl) {
      Queue<Pair<VirtualDirectoryImpl, ChildInfo[]>> queue = new ArrayDeque<>();
      queue.add(Pair.create((VirtualDirectoryImpl)createdDir, children));
      while (!queue.isEmpty()) {
        Pair<VirtualDirectoryImpl, ChildInfo[]> queued = queue.remove();
        VirtualDirectoryImpl directory = queued.first;
        TIntHashSet childIds = new TIntHashSet();
        List<ChildInfo> scannedChildren = Arrays.asList(queued.second);
        List<ChildInfo> added = getOrCreateChildInfos(directory, scannedChildren, childInfo -> childInfo.getName(), childIds, delegate, (childInfo, childId) -> {
          // passed children have no ChildInfo.id, have to create new ones
          if (childId < 0) {
            String childName = childInfo.getName().toString();
            Pair<FileAttributes, String> childData = getChildData(delegate, directory, childName, childInfo.getFileAttributes(), childInfo.getSymLinkTarget());
            if (childData == null) return null;
            childId = makeChildRecord(directory.getId(), childName, childData, delegate);
          }
          return new ChildInfoImpl(childId, childInfo.getNameId(), childInfo.getFileAttributes(), childInfo.getChildren(), childInfo.getSymLinkTarget());
        });

        FSRecords.updateList(directory.getId(), childIds.toArray());
        setChildrenCached(directory.getId());
        // set "all children loaded" because the first "fileCreated" listener (looking at you, local history)
        // will call getChildren() anyway, beyond a shadow of a doubt
        directory.createAndAddChildren(added, true, (childCreated, childInfo) -> {
          // enqueue recursive children
          if (childCreated instanceof VirtualDirectoryImpl && childInfo.getChildren() != null) {
            queue.add(Pair.create((VirtualDirectoryImpl)childCreated, childInfo.getChildren()));
          }
        });
      }
    }
  }
}
 
Example #20
Source File: MergePanel2.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public int[] getFragmentStartingLines() {
  TIntHashSet beginnings = new TIntHashSet();
  if (myMergeList != null) {
    for (int i = 0; i < 2; i++) {
      FragmentSide branchSide = FragmentSide.fromIndex(i);
      beginnings.addAll(myMergeList.getChanges(branchSide).getLineBlocks().getBeginnings(MergeList.BASE_SIDE));
    }
  }
  int[] result = beginnings.toArray();
  Arrays.sort(result);
  return result;
}
 
Example #21
Source File: VcsLogGraphTable.java    From consulo with Apache License 2.0 5 votes vote down vote up
public Selection(@Nonnull VcsLogGraphTable table) {
  myTable = table;
  List<Integer> selectedRows = ContainerUtil.sorted(Ints.asList(myTable.getSelectedRows()));
  Couple<Integer> visibleRows = ScrollingUtil.getVisibleRows(myTable);
  myIsOnTop = visibleRows.first - 1 == 0;

  VisibleGraph<Integer> graph = myTable.getVisibleGraph();

  mySelectedCommits = new TIntHashSet();

  Integer visibleSelectedCommit = null;
  Integer delta = null;
  for (int row : selectedRows) {
    if (row < graph.getVisibleCommitCount()) {
      Integer commit = graph.getRowInfo(row).getCommit();
      mySelectedCommits.add(commit);
      if (visibleRows.first - 1 <= row && row <= visibleRows.second && visibleSelectedCommit == null) {
        visibleSelectedCommit = commit;
        delta = myTable.getCellRect(row, 0, false).y - myTable.getVisibleRect().y;
      }
    }
  }
  if (visibleSelectedCommit == null && visibleRows.first - 1 >= 0) {
    visibleSelectedCommit = graph.getRowInfo(visibleRows.first - 1).getCommit();
    delta = myTable.getCellRect(visibleRows.first - 1, 0, false).y - myTable.getVisibleRect().y;
  }

  myVisibleSelectedCommit = visibleSelectedCommit;
  myDelta = delta;
}
 
Example #22
Source File: VcsLogPathsIndex.java    From consulo with Apache License 2.0 5 votes vote down vote up
public TIntHashSet getCommitsForPaths(@Nonnull Collection<FilePath> paths) throws IOException, StorageException {
  Set<Integer> allPathIds = ContainerUtil.newHashSet();
  for (FilePath path : paths) {
    allPathIds.add(myPathsIndexer.myPathsEnumerator.enumerate(path.getPath()));
  }

  TIntHashSet result = new TIntHashSet();
  Set<Integer> renames = allPathIds;
  while (!renames.isEmpty()) {
    renames = addCommitsAndGetRenames(renames, allPathIds, result);
    allPathIds.addAll(renames);
  }

  return result;
}
 
Example #23
Source File: AbstractDataGetter.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
public TIntObjectHashMap<T> preLoadCommitData(@Nonnull TIntHashSet commits) throws VcsException {
  TIntObjectHashMap<T> result = new TIntObjectHashMap<>();
  final MultiMap<VirtualFile, String> rootsAndHashes = MultiMap.create();
  commits.forEach(commit -> {
    CommitId commitId = myHashMap.getCommitId(commit);
    if (commitId != null) {
      rootsAndHashes.putValue(commitId.getRoot(), commitId.getHash().asString());
    }
    return true;
  });

  for (Map.Entry<VirtualFile, Collection<String>> entry : rootsAndHashes.entrySet()) {
    VcsLogProvider logProvider = myLogProviders.get(entry.getKey());
    if (logProvider != null) {
      List<? extends T> details = readDetails(logProvider, entry.getKey(), ContainerUtil.newArrayList(entry.getValue()));
      for (T data : details) {
        int index = myHashMap.getCommitIndex(data.getId(), data.getRoot());
        result.put(index, data);
      }
      saveInCache(result);
    }
    else {
      LOG.error("No log provider for root " + entry.getKey().getPath() + ". All known log providers " + myLogProviders);
    }
  }

  return result;
}
 
Example #24
Source File: AbstractDataGetter.java    From consulo with Apache License 2.0 5 votes vote down vote up
private void runLoadCommitsData(@Nonnull 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));
}
 
Example #25
Source File: Classfile.java    From whyline with MIT License 5 votes vote down vote up
/**
 * Creates a cached table of superclass name IDs.
 */
private void determineSuperclasses() {

	superclasses = new TIntHashSet(2);

	Classfile clazz = this;
	while(clazz != null) {
		ClassInfo superInfo = clazz.getSuperclassInfo(); 
		if(superInfo  != null) superclasses.add(superInfo.getName().getID());
		clazz = clazz.getSuperclass();
	}
	superclasses.trimToSize();
	
}
 
Example #26
Source File: CompactVirtualFileSet.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public boolean contains(Object file) {
  if (file instanceof VirtualFileWithId) {
    BitSet ids = fileIds;
    int id = ((VirtualFileWithId)file).getId();
    if (ids != null) {
      return ids.get(id);
    }
    TIntHashSet idSet = this.idSet;
    if (idSet != null) {
      return idSet.contains(id);
    }
  }
  return weirdFiles.contains(file);
}
 
Example #27
Source File: CompileDriver.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public Pair<int[], Set<VirtualFile>> fun(Pair<int[], Set<VirtualFile>> deps) {
  final TIntHashSet currentDeps = new TIntHashSet(deps.getFirst());
  currentDeps.removeAll(myProcessedNames.toArray());
  myProcessedNames.addAll(deps.getFirst());

  final Set<VirtualFile> depFiles = new HashSet<>(deps.getSecond());
  depFiles.removeAll(myProcessedFiles);
  myProcessedFiles.addAll(deps.getSecond());
  return new Pair<>(currentDeps.toArray(), depFiles);
}
 
Example #28
Source File: TranslationSourceFileInfo.java    From consulo with Apache License 2.0 5 votes vote down vote up
public boolean isAssociated(int projectId, String outputPath) {
  if (myProjectToOutputPathMap != null) {
    final Object val = myProjectToOutputPathMap.get(projectId);
    if (val instanceof Integer) {
      VirtualFile fileById = VirtualFileManager.getInstance().findFileById((Integer)val);
      return FileUtil.pathsEqual(outputPath, fileById != null ? fileById.getPath() : "");
    }
    if (val instanceof TIntHashSet) {
      VirtualFile vf = LocalFileSystem.getInstance().findFileByPath(outputPath);
      int _outputPath = vf == null ? -1 : FileBasedIndex.getFileId(vf);
      return ((TIntHashSet)val).contains(_outputPath);
    }
  }
  return false;
}
 
Example #29
Source File: TranslationSourceFileInfo.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void processOutputPaths(final int projectId, final TranslatingCompilerFilesMonitorImpl.Proc proc) {
  if (myProjectToOutputPathMap != null) {
    final Object val = myProjectToOutputPathMap.get(projectId);
    if (val instanceof Integer) {
      proc.execute(projectId, VirtualFileManager.getInstance().findFileById((Integer)val));
    }
    else if (val instanceof TIntHashSet) {
      ((TIntHashSet)val).forEach(value -> {
        proc.execute(projectId, VirtualFileManager.getInstance().findFileById(value));
        return true;
      });
    }
  }
}
 
Example #30
Source File: TranslationSourceFileInfo.java    From consulo with Apache License 2.0 5 votes vote down vote up
public TIntHashSet getProjectIds() {
  final TIntHashSet result = new TIntHashSet();
  if (myTimestamps != null) {
    result.addAll(myTimestamps.keys());
  }
  if (myProjectToOutputPathMap != null) {
    result.addAll(myProjectToOutputPathMap.keys());
  }
  return result;
}