use of gnu.trove.TIntArrayList in project intellij-community by JetBrains.
the class CompressedRefs method refsToCommit.
@NotNull
SmartList<VcsRef> refsToCommit(int index) {
SmartList<VcsRef> result = new SmartList<>();
if (myBranches.containsKey(index))
result.addAll(myBranches.get(index));
TIntArrayList tags = myTags.get(index);
if (tags != null) {
tags.forEach(value -> {
result.add(myStorage.getVcsRef(value));
return true;
});
}
return result;
}
use of gnu.trove.TIntArrayList in project intellij-community by JetBrains.
the class TrigramBuilderTest method testBuilder.
public void testBuilder() {
final Ref<Integer> trigramCountRef = new Ref<>();
final TIntArrayList list = new TIntArrayList();
TrigramBuilder.processTrigrams("String$CharData", new TrigramBuilder.TrigramProcessor() {
@Override
public boolean execute(int value) {
list.add(value);
return true;
}
@Override
public boolean consumeTrigramsCount(int count) {
trigramCountRef.set(count);
return true;
}
});
list.sort();
Integer trigramCount = trigramCountRef.get();
assertNotNull(trigramCount);
int expectedTrigramCount = 13;
assertEquals(expectedTrigramCount, (int) trigramCount);
assertEquals(expectedTrigramCount, list.size());
int[] expected = { buildTrigram("$Ch"), buildTrigram("arD"), buildTrigram("ata"), 6514785, 6578548, 6759523, 6840690, 6909543, 7235364, 7496801, 7498094, 7566450, 7631465 };
for (int i = 0; i < expectedTrigramCount; ++i) assertEquals(expected[i], list.getQuick(i));
}
use of gnu.trove.TIntArrayList in project intellij-community by JetBrains.
the class ApplyPatchViewer method initPatchViewer.
//
// Impl
//
protected void initPatchViewer() {
final Document outputDocument = myResultEditor.getDocument();
boolean success = DiffUtil.executeWriteCommand(outputDocument, myProject, "Init merge content", () -> {
outputDocument.setText(myPatchRequest.getLocalContent());
if (!isReadOnly())
DiffUtil.putNonundoableOperation(myProject, outputDocument);
});
if (!success && !StringUtil.equals(outputDocument.getText(), myPatchRequest.getLocalContent())) {
myPanel.setErrorContent("Failed to display patch applier - local content was modified");
return;
}
PatchChangeBuilder builder = new PatchChangeBuilder();
builder.exec(myPatchRequest.getPatch().getHunks());
Document patchDocument = myPatchEditor.getDocument();
patchDocument.setText(builder.getPatchContent());
LineNumberConvertor convertor1 = builder.getLineConvertor1();
LineNumberConvertor convertor2 = builder.getLineConvertor2();
myPatchEditor.getGutterComponentEx().setLineNumberConvertor(convertor1.createConvertor(), convertor2.createConvertor());
TIntArrayList lines = builder.getSeparatorLines();
for (int i = 0; i < lines.size(); i++) {
int offset = patchDocument.getLineStartOffset(lines.get(i));
DiffDrawUtil.createLineSeparatorHighlighter(myPatchEditor, offset, offset, BooleanGetter.TRUE);
}
List<PatchChangeBuilder.Hunk> hunks = builder.getHunks();
int[] modelToPatchIndexes = DiffUtil.getSortedIndexes(hunks, (h1, h2) -> {
LineRange lines1 = h1.getAppliedToLines();
LineRange lines2 = h2.getAppliedToLines();
if (lines1 == null && lines2 == null)
return 0;
if (lines1 == null)
return -1;
if (lines2 == null)
return 1;
return lines1.start - lines2.start;
});
int[] patchToModelIndexes = DiffUtil.invertIndexes(modelToPatchIndexes);
List<LineRange> modelRanges = new ArrayList<>();
for (int modelIndex = 0; modelIndex < hunks.size(); modelIndex++) {
int patchIndex = modelToPatchIndexes[modelIndex];
PatchChangeBuilder.Hunk hunk = hunks.get(patchIndex);
LineRange resultRange = hunk.getAppliedToLines();
ApplyPatchChange change = new ApplyPatchChange(hunk, modelIndex, this);
myModelChanges.add(change);
if (resultRange != null)
myResultChanges.add(change);
modelRanges.add(resultRange != null ? resultRange : new LineRange(-1, -1));
}
myModel.setChanges(modelRanges);
for (int index : patchToModelIndexes) {
myPatchChanges.add(myModelChanges.get(index));
}
myFoldingModel.install(myResultChanges, getFoldingModelSettings());
for (ApplyPatchChange change : myModelChanges) {
change.reinstallHighlighters();
}
myStatusPanel.update();
myContentPanel.setPainter(new MyDividerPainter());
VisibleAreaListener areaListener = (e) -> myContentPanel.repaint();
myResultEditor.getScrollingModel().addVisibleAreaListener(areaListener);
myPatchEditor.getScrollingModel().addVisibleAreaListener(areaListener);
myPatchEditor.getGutterComponentEx().revalidateMarkup();
if (myResultChanges.size() > 0) {
scrollToChange(myResultChanges.get(0), Side.LEFT, true);
}
}
use of gnu.trove.TIntArrayList in project intellij-community by JetBrains.
the class GithubTagInfo method createVersionComponents.
@NotNull
private Version createVersionComponents() {
String tagName = myName;
if (tagName.startsWith("v.")) {
tagName = tagName.substring(2);
} else if (StringUtil.startsWithChar(tagName, 'v')) {
tagName = tagName.substring(1);
}
TIntArrayList intComponents = new TIntArrayList();
int startInd = 0;
while (true) {
int ind = tagName.indexOf('.', startInd);
if (ind == -1) {
break;
}
String s = tagName.substring(startInd, ind);
try {
int x = Integer.parseInt(s);
intComponents.add(x);
startInd = ind + 1;
} catch (NumberFormatException e) {
break;
}
}
int nonDigitInd = startInd;
while (nonDigitInd < tagName.length()) {
if (!Character.isDigit(tagName.charAt(nonDigitInd))) {
break;
}
nonDigitInd++;
}
String digitStr = tagName.substring(startInd, nonDigitInd);
if (!digitStr.isEmpty()) {
intComponents.add(Integer.parseInt(digitStr));
}
String labelWithVersion = tagName.substring(nonDigitInd);
int lastNonDigitInd = labelWithVersion.length() - 1;
while (lastNonDigitInd >= 0) {
if (!Character.isDigit(labelWithVersion.charAt(lastNonDigitInd))) {
break;
}
lastNonDigitInd--;
}
String labelVersionStr = labelWithVersion.substring(lastNonDigitInd + 1);
String label = labelWithVersion.substring(0, lastNonDigitInd + 1);
int labelVersion = Integer.MAX_VALUE;
if (!labelVersionStr.isEmpty()) {
labelVersion = Integer.parseInt(labelVersionStr);
}
return new Version(intComponents, label, labelVersion);
}
use of gnu.trove.TIntArrayList in project intellij-community by JetBrains.
the class FSRecords method getParents.
// returns id, parent(id), parent(parent(id)), ... (already cached id or rootId)
@NotNull
public static TIntArrayList getParents(int id, @NotNull ConcurrentIntObjectMap<?> idCache) {
TIntArrayList result = new TIntArrayList(10);
r.lock();
try {
int parentId;
do {
result.add(id);
if (idCache.containsKey(id)) {
break;
}
parentId = getRecordInt(id, PARENT_OFFSET);
if (parentId == id || result.size() % 128 == 0 && result.contains(parentId)) {
LOG.error("Cyclic parent child relations in the database. id = " + parentId);
return result;
}
id = parentId;
} while (parentId != 0);
} catch (Throwable e) {
DbConnection.handleError(e);
} finally {
r.unlock();
}
return result;
}
Aggregations