Java Code Examples for gnu.trove.TIntHashSet#forEach()

The following examples show how to use gnu.trove.TIntHashSet#forEach() . 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: 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 2
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 3
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 4
Source File: FileBasedIndexImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
private static boolean processVirtualFiles(@Nonnull TIntHashSet ids, @Nonnull final GlobalSearchScope filter, @Nonnull final Processor<? super VirtualFile> processor) {
  final PersistentFS fs = (PersistentFS)ManagingFS.getInstance();
  return ids.forEach(id -> {
    ProgressManager.checkCanceled();
    VirtualFile file = IndexInfrastructure.findFileByIdIfCached(fs, id);
    if (file != null && filter.accept(file)) {
      return processor.process(file);
    }
    return true;
  });
}
 
Example 5
Source File: VcsLogPersistentIndex.java    From consulo with Apache License 2.0 4 votes vote down vote up
public void indexAll(@Nonnull VirtualFile root,
                     @Nonnull TIntHashSet commitsSet,
                     @Nonnull CommitsCounter counter) {
  TIntHashSet notIndexed = new TIntHashSet();
  TroveUtil.stream(commitsSet).forEach(c -> {
    if (isIndexed(c)) {
      counter.oldCommits++;
    }
    else {
      notIndexed.add(c);
    }
  });
  counter.displayProgress();

  if (notIndexed.size() <= MAGIC_NUMBER) {
    indexOneByOne(root, counter, TroveUtil.stream(notIndexed));
  }
  else {
    try {
      myProviders.get(root).readAllFullDetails(root, details -> {
        int index = myHashMap.getCommitIndex(details.getId(), details.getRoot());
        if (notIndexed.contains(index)) {
          storeDetail(details);
          counter.newIndexedCommits++;
        }

        counter.indicator.checkCanceled();
        counter.displayProgress();
      });
    }
    catch (VcsException e) {
      LOG.error(e);
      notIndexed.forEach(value -> {
        markForIndexing(value, root);
        return true;
      });
    }
  }

  flush();
}