Search in sources :

Example 6 with TIntHashSet

use of gnu.trove.TIntHashSet in project intellij-community by JetBrains.

the class DataPack method getHeads.

@NotNull
private static Set<Integer> getHeads(@NotNull List<? extends GraphCommit<Integer>> commits) {
    TIntHashSet parents = new TIntHashSet();
    for (GraphCommit<Integer> commit : commits) {
        for (int parent : commit.getParents()) {
            parents.add(parent);
        }
    }
    Set<Integer> heads = ContainerUtil.newHashSet();
    for (GraphCommit<Integer> commit : commits) {
        if (!parents.contains(commit.getId())) {
            heads.add(commit.getId());
        }
    }
    return heads;
}
Also used : TIntHashSet(gnu.trove.TIntHashSet) NotNull(org.jetbrains.annotations.NotNull)

Example 7 with TIntHashSet

use of gnu.trove.TIntHashSet in project intellij-community by JetBrains.

the class VcsLogFullDetailsIndex method getCommitsWithAnyKey.

@NotNull
public TIntHashSet getCommitsWithAnyKey(@NotNull Set<Integer> keys) throws StorageException {
    checkDisposed();
    TIntHashSet result = new TIntHashSet();
    for (Integer key : keys) {
        iterateCommitIds(key, result::add);
    }
    return result;
}
Also used : TIntHashSet(gnu.trove.TIntHashSet) NotNull(org.jetbrains.annotations.NotNull)

Example 8 with TIntHashSet

use of gnu.trove.TIntHashSet in project intellij-community by JetBrains.

the class VcsLogPersistentIndex method scheduleIndex.

@Override
public synchronized void scheduleIndex(boolean full) {
    if (myCommitsToIndex.isEmpty())
        return;
    Map<VirtualFile, TIntHashSet> commitsToIndex = myCommitsToIndex;
    for (VirtualFile root : commitsToIndex.keySet()) {
        myNumberOfTasks.get(root).incrementAndGet();
    }
    myCommitsToIndex = ContainerUtil.newHashMap();
    mySingleTaskController.request(new IndexingRequest(commitsToIndex, full));
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) TIntHashSet(gnu.trove.TIntHashSet)

Example 9 with TIntHashSet

use of gnu.trove.TIntHashSet in project intellij-community by JetBrains.

the class Util method findParametersToRemove.

// returns parameters that are used solely in specified expression
@NotNull
public static TIntArrayList findParametersToRemove(@NotNull PsiMethod method, @NotNull final PsiExpression expr, @Nullable final PsiExpression[] occurences) {
    final PsiParameter[] parameters = method.getParameterList().getParameters();
    if (parameters.length == 0)
        return new TIntArrayList();
    PsiMethod[] overridingMethods = OverridingMethodsSearch.search(method).toArray(PsiMethod.EMPTY_ARRAY);
    final PsiMethod[] allMethods = ArrayUtil.append(overridingMethods, method);
    final TIntHashSet suspects = new TIntHashSet();
    expr.accept(new JavaRecursiveElementWalkingVisitor() {

        @Override
        public void visitReferenceExpression(final PsiReferenceExpression expression) {
            super.visitReferenceExpression(expression);
            PsiElement resolved = expression.resolve();
            if (resolved instanceof PsiParameter) {
                int i = ArrayUtil.find(parameters, resolved);
                if (i != -1) {
                    suspects.add(i);
                }
            }
        }
    });
    final TIntIterator iterator = suspects.iterator();
    while (iterator.hasNext()) {
        final int paramNum = iterator.next();
        for (PsiMethod psiMethod : allMethods) {
            PsiParameter[] psiParameters = psiMethod.getParameterList().getParameters();
            if (paramNum >= psiParameters.length)
                continue;
            PsiParameter parameter = psiParameters[paramNum];
            if (!ReferencesSearch.search(parameter, parameter.getResolveScope(), false).forEach(reference -> {
                PsiElement element = reference.getElement();
                boolean stillCanBeRemoved = false;
                if (element != null) {
                    stillCanBeRemoved = isAncestor(expr, element, false) || PsiUtil.isInsideJavadocComment(getPhysical(element));
                    if (!stillCanBeRemoved && occurences != null) {
                        for (PsiExpression occurence : occurences) {
                            if (isAncestor(occurence, element, false)) {
                                stillCanBeRemoved = true;
                                break;
                            }
                        }
                    }
                }
                if (!stillCanBeRemoved) {
                    iterator.remove();
                    return false;
                }
                return true;
            }))
                break;
        }
    }
    return new TIntArrayList(suspects.toArray());
}
Also used : ReferencesSearch(com.intellij.psi.search.searches.ReferencesSearch) TIntHashSet(gnu.trove.TIntHashSet) ArrayUtil(com.intellij.util.ArrayUtil) TIntIterator(gnu.trove.TIntIterator) OverridingMethodsSearch(com.intellij.psi.search.searches.OverridingMethodsSearch) ElementToWorkOn(com.intellij.refactoring.introduceField.ElementToWorkOn) UsageInfo(com.intellij.usageView.UsageInfo) GenerateMembersUtil(com.intellij.codeInsight.generation.GenerateMembersUtil) TextRange(com.intellij.openapi.util.TextRange) Nullable(org.jetbrains.annotations.Nullable) PsiTreeUtil(com.intellij.psi.util.PsiTreeUtil) List(java.util.List) Processor(com.intellij.util.Processor) PsiUtil(com.intellij.psi.util.PsiUtil) com.intellij.psi(com.intellij.psi) NotNull(org.jetbrains.annotations.NotNull) TIntArrayList(gnu.trove.TIntArrayList) TIntIterator(gnu.trove.TIntIterator) TIntArrayList(gnu.trove.TIntArrayList) TIntHashSet(gnu.trove.TIntHashSet) NotNull(org.jetbrains.annotations.NotNull)

Example 10 with TIntHashSet

use of gnu.trove.TIntHashSet in project intellij-community by JetBrains.

the class YYYYYYY method paintBackgrounds.

private void paintBackgrounds(@NotNull Graphics g, @NotNull Rectangle clip, @NotNull LogicalPosition clipStartPosition, @NotNull VisualPosition clipStartVisualPos, int clipStartOffset, int clipEndOffset) {
    Color defaultBackground = getBackgroundColor();
    if (myEditorComponent.isOpaque()) {
        g.setColor(defaultBackground);
        g.fillRect(clip.x, clip.y, clip.width, clip.height);
    }
    Color prevBackColor = null;
    int lineHeight = getLineHeight();
    int visibleLine = yPositionToVisibleLine(clip.y);
    Point position = new Point(0, visibleLine * lineHeight);
    CharSequence prefixText = myPrefixText == null ? null : new CharArrayCharSequence(myPrefixText);
    if (clipStartVisualPos.line == 0 && prefixText != null) {
        Color backColor = myPrefixAttributes.getBackgroundColor();
        position.x = drawBackground(g, backColor, prefixText, 0, prefixText.length(), position, myPrefixAttributes.getFontType(), defaultBackground, clip);
        prevBackColor = backColor;
    }
    if (clipStartPosition.line >= myDocument.getLineCount() || clipStartPosition.line < 0) {
        if (position.x > 0)
            flushBackground(g, clip);
        return;
    }
    myLastBackgroundPosition = null;
    myLastBackgroundColor = null;
    mySelectionStartPosition = null;
    mySelectionEndPosition = null;
    int start = clipStartOffset;
    if (!myPurePaintingMode) {
        getSoftWrapModel().registerSoftWrapsIfNecessary();
    }
    LineIterator lIterator = createLineIterator();
    lIterator.start(start);
    if (lIterator.atEnd()) {
        return;
    }
    IterationState iterationState = new IterationState(this, start, clipEndOffset, isPaintSelection());
    TextAttributes attributes = iterationState.getMergedAttributes();
    Color backColor = getBackgroundColor(attributes);
    int fontType = attributes.getFontType();
    int lastLineIndex = Math.max(0, myDocument.getLineCount() - 1);
    // There is a possible case that we need to draw background from the start of soft wrap-introduced visual line. Given position
    // has valid 'y' coordinate then at it shouldn't be affected by soft wrap that corresponds to the visual line start offset.
    // Hence, we store information about soft wrap to be skipped for further processing and adjust 'x' coordinate value if necessary.
    TIntHashSet softWrapsToSkip = new TIntHashSet();
    SoftWrap softWrap = getSoftWrapModel().getSoftWrap(start);
    if (softWrap != null) {
        softWrapsToSkip.add(softWrap.getStart());
        Color color = null;
        if (backColor != null && !backColor.equals(defaultBackground)) {
            color = backColor;
        }
        // virtual space then.
        if (color == null && position.y == getCaretModel().getVisualPosition().line * getLineHeight()) {
            color = mySettings.isCaretRowShown() ? getColorsScheme().getColor(EditorColors.CARET_ROW_COLOR) : null;
        }
        if (color != null) {
            drawBackground(g, color, softWrap.getIndentInPixels(), position, defaultBackground, clip);
            prevBackColor = color;
        }
        position.x = softWrap.getIndentInPixels();
    }
    // There is a possible case that caret is located at soft-wrapped line. We don't need to paint caret row background
    // on a last visual line of that soft-wrapped line then. Below is a holder for the flag that indicates if caret row
    // background is already drawn.
    boolean[] caretRowPainted = new boolean[1];
    CharSequence text = myDocument.getImmutableCharSequence();
    while (!iterationState.atEnd() && !lIterator.atEnd()) {
        int hEnd = iterationState.getEndOffset();
        int lEnd = lIterator.getEnd();
        if (hEnd >= lEnd) {
            FoldRegion collapsedFolderAt = myFoldingModel.getCollapsedRegionAtOffset(start);
            if (collapsedFolderAt == null) {
                position.x = drawSoftWrapAwareBackground(g, backColor, prevBackColor, text, start, lEnd - lIterator.getSeparatorLength(), position, fontType, defaultBackground, clip, softWrapsToSkip, caretRowPainted);
                prevBackColor = backColor;
                paintAfterLineEndBackgroundSegments(g, iterationState, position, defaultBackground, lineHeight);
                if (lIterator.getLineNumber() < lastLineIndex) {
                    if (backColor != null && !backColor.equals(defaultBackground)) {
                        g.setColor(backColor);
                        g.fillRect(position.x, position.y, clip.x + clip.width - position.x, lineHeight);
                    }
                } else {
                    if (iterationState.hasPastFileEndBackgroundSegments()) {
                        paintAfterLineEndBackgroundSegments(g, iterationState, position, defaultBackground, lineHeight);
                    }
                    paintAfterFileEndBackground(iterationState, g, position, clip, lineHeight, defaultBackground, caretRowPainted);
                    break;
                }
                position.x = 0;
                if (position.y > clip.y + clip.height)
                    break;
                position.y += lineHeight;
                start = lEnd;
            } else if (collapsedFolderAt.getEndOffset() == clipEndOffset) {
                drawCollapsedFolderBackground(g, clip, defaultBackground, prevBackColor, position, backColor, fontType, softWrapsToSkip, caretRowPainted, text, collapsedFolderAt);
                prevBackColor = backColor;
            }
            lIterator.advance();
        } else {
            FoldRegion collapsedFolderAt = iterationState.getCurrentFold();
            if (collapsedFolderAt != null) {
                drawCollapsedFolderBackground(g, clip, defaultBackground, prevBackColor, position, backColor, fontType, softWrapsToSkip, caretRowPainted, text, collapsedFolderAt);
                prevBackColor = backColor;
            } else if (hEnd > lEnd - lIterator.getSeparatorLength()) {
                position.x = drawSoftWrapAwareBackground(g, backColor, prevBackColor, text, start, lEnd - lIterator.getSeparatorLength(), position, fontType, defaultBackground, clip, softWrapsToSkip, caretRowPainted);
                prevBackColor = backColor;
            } else {
                position.x = drawSoftWrapAwareBackground(g, backColor, prevBackColor, text, start, hEnd, position, fontType, defaultBackground, clip, softWrapsToSkip, caretRowPainted);
                prevBackColor = backColor;
            }
            iterationState.advance();
            attributes = iterationState.getMergedAttributes();
            backColor = getBackgroundColor(attributes);
            fontType = attributes.getFontType();
            start = iterationState.getStartOffset();
        }
    }
    flushBackground(g, clip);
    if (lIterator.getLineNumber() >= lastLineIndex && position.y <= clip.y + clip.height) {
        paintAfterFileEndBackground(iterationState, g, position, clip, lineHeight, defaultBackground, caretRowPainted);
    }
    // Perform additional activity if soft wrap is added or removed during repainting.
    if (mySoftWrapsChanged) {
        mySoftWrapsChanged = false;
        clearTextWidthCache();
        validateSize();
        // Repaint editor to the bottom in order to ensure that its content is shown correctly after new soft wrap introduction.
        repaintToScreenBottom(EditorUtil.yPositionToLogicalLine(this, position));
        // Repaint gutter at all space that is located after active clip in order to ensure that line numbers are correctly redrawn
        // in accordance with the newly introduced soft wrap(s).
        myGutterComponent.repaint(0, clip.y, myGutterComponent.getWidth(), myGutterComponent.getHeight() - clip.y);
    }
}
Also used : CharArrayCharSequence(com.intellij.util.text.CharArrayCharSequence) CharArrayCharSequence(com.intellij.util.text.CharArrayCharSequence) TIntHashSet(gnu.trove.TIntHashSet)

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