Search in sources :

Example 61 with TIntArrayList

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;
}
Also used : VcsRef(com.intellij.vcs.log.VcsRef) SmartList(com.intellij.util.SmartList) TIntArrayList(gnu.trove.TIntArrayList) NotNull(org.jetbrains.annotations.NotNull)

Example 62 with TIntArrayList

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));
}
Also used : Ref(com.intellij.openapi.util.Ref) TIntArrayList(gnu.trove.TIntArrayList)

Example 63 with TIntArrayList

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);
    }
}
Also used : TwosideContentPanel(com.intellij.diff.tools.util.side.TwosideContentPanel) com.intellij.diff.tools.util(com.intellij.diff.tools.util) AllIcons(com.intellij.icons.AllIcons) DiffContentFactory(com.intellij.diff.DiffContentFactory) FocusOppositePaneAction(com.intellij.diff.actions.impl.FocusOppositePaneAction) ActionUtil(com.intellij.openapi.actionSystem.ex.ActionUtil) DiffBundle(com.intellij.openapi.diff.DiffBundle) com.intellij.openapi.editor(com.intellij.openapi.editor) org.jetbrains.annotations(org.jetbrains.annotations) DiffManager(com.intellij.diff.DiffManager) ContainerUtil(com.intellij.util.containers.ContainerUtil) SetEditorSettingsAction(com.intellij.diff.actions.impl.SetEditorSettingsAction) ArrayList(java.util.ArrayList) Disposer(com.intellij.openapi.util.Disposer) MergeModelBase(com.intellij.diff.merge.MergeModelBase) Project(com.intellij.openapi.project.Project) EditorEx(com.intellij.openapi.editor.ex.EditorEx) UndoConfirmationPolicy(com.intellij.openapi.command.UndoConfirmationPolicy) Logger(com.intellij.openapi.diagnostic.Logger) TIntArrayList(gnu.trove.TIntArrayList) DocumentImpl(com.intellij.openapi.editor.impl.DocumentImpl) SimpleDiffRequest(com.intellij.diff.requests.SimpleDiffRequest) BooleanGetter(com.intellij.openapi.util.BooleanGetter) DiffContext(com.intellij.diff.DiffContext) TextDiffViewerUtil(com.intellij.diff.tools.util.base.TextDiffViewerUtil) Iterator(java.util.Iterator) com.intellij.diff.util(com.intellij.diff.util) StringUtil(com.intellij.openapi.util.text.StringUtil) TextDiffSettings(com.intellij.diff.tools.util.base.TextDiffSettingsHolder.TextDiffSettings) DocumentContent(com.intellij.diff.contents.DocumentContent) ProxyUndoRedoAction(com.intellij.diff.actions.ProxyUndoRedoAction) EditorMarkupModel(com.intellij.openapi.editor.ex.EditorMarkupModel) DiffDialogHints(com.intellij.diff.DiffDialogHints) LineNumberConvertor(com.intellij.diff.tools.fragmented.LineNumberConvertor) Disposable(com.intellij.openapi.Disposable) AppliedTextPatch(com.intellij.openapi.vcs.changes.patch.AppliedTextPatch) java.awt(java.awt) com.intellij.openapi.actionSystem(com.intellij.openapi.actionSystem) DumbAwareAction(com.intellij.openapi.project.DumbAwareAction) List(java.util.List) Pair(com.intellij.openapi.util.Pair) VisibleAreaListener(com.intellij.openapi.editor.event.VisibleAreaListener) TextEditorHolder(com.intellij.diff.tools.holders.TextEditorHolder) BitSet(java.util.BitSet) javax.swing(javax.swing) LineNumberConvertor(com.intellij.diff.tools.fragmented.LineNumberConvertor) ArrayList(java.util.ArrayList) TIntArrayList(gnu.trove.TIntArrayList) TIntArrayList(gnu.trove.TIntArrayList) VisibleAreaListener(com.intellij.openapi.editor.event.VisibleAreaListener)

Example 64 with TIntArrayList

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

Example 65 with TIntArrayList

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

Aggregations

TIntArrayList (gnu.trove.TIntArrayList)104 NotNull (org.jetbrains.annotations.NotNull)34 ArrayList (java.util.ArrayList)9 List (java.util.List)7 Nullable (org.jetbrains.annotations.Nullable)7 VirtualFile (com.intellij.openapi.vfs.VirtualFile)4 ArrangementMatchingRulesControl (com.intellij.application.options.codeStyle.arrangement.match.ArrangementMatchingRulesControl)3 StringSearcher (com.intellij.util.text.StringSearcher)3 TIntHashSet (gnu.trove.TIntHashSet)3 TIntProcedure (gnu.trove.TIntProcedure)3 IOException (java.io.IOException)3 IDevice (com.android.ddmlib.IDevice)2 ArrangementMatchingRulesModel (com.intellij.application.options.codeStyle.arrangement.match.ArrangementMatchingRulesModel)2 FileChooserDescriptor (com.intellij.openapi.fileChooser.FileChooserDescriptor)2 Project (com.intellij.openapi.project.Project)2 TextRange (com.intellij.openapi.util.TextRange)2 ElementToWorkOn (com.intellij.refactoring.introduceField.ElementToWorkOn)2 IntroduceParameterProcessor (com.intellij.refactoring.introduceParameter.IntroduceParameterProcessor)2 RelativePoint (com.intellij.ui.awt.RelativePoint)2 RadComponent (com.intellij.uiDesigner.radComponents.RadComponent)2