Search in sources :

Example 1 with ResultItem

use of com.intellij.execution.filters.Filter.ResultItem in project intellij-community by JetBrains.

the class ConsoleViewImpl method runHeavyFilters.

private void runHeavyFilters(int line1, int endLine) {
    final int startLine = Math.max(0, line1);
    final Document document = myEditor.getDocument();
    final int startOffset = document.getLineStartOffset(startLine);
    String text = document.getText(new TextRange(startOffset, document.getLineEndOffset(endLine)));
    final Document documentCopy = new DocumentImpl(text, true);
    documentCopy.setReadOnly(true);
    myJLayeredPane.startUpdating();
    final int currentValue = myHeavyUpdateTicket;
    myHeavyAlarm.addRequest(() -> {
        if (!myFilters.shouldRunHeavy())
            return;
        try {
            myFilters.applyHeavyFilter(documentCopy, startOffset, startLine, additionalHighlight -> addFlushRequest(new FlushRunnable() {

                @Override
                public void doRun() {
                    if (myHeavyUpdateTicket != currentValue)
                        return;
                    TextAttributes additionalAttributes = additionalHighlight.getTextAttributes(null);
                    if (additionalAttributes != null) {
                        ResultItem item = additionalHighlight.getResultItems().get(0);
                        myHyperlinks.addHighlighter(item.getHighlightStartOffset(), item.getHighlightEndOffset(), additionalAttributes);
                    } else {
                        myHyperlinks.highlightHyperlinks(additionalHighlight, 0);
                    }
                }

                @Override
                public boolean equals(Object o) {
                    return this == o;
                }
            }, 0));
        } finally {
            if (myHeavyAlarm.getActiveRequestCount() <= 1) {
                // only the current request
                UIUtil.invokeLaterIfNeeded(() -> myJLayeredPane.finishUpdating());
            }
        }
    }, 0);
}
Also used : ResultItem(com.intellij.execution.filters.Filter.ResultItem) TextRange(com.intellij.openapi.util.TextRange) DocumentImpl(com.intellij.openapi.editor.impl.DocumentImpl) RelativePoint(com.intellij.ui.awt.RelativePoint)

Aggregations

ResultItem (com.intellij.execution.filters.Filter.ResultItem)1 DocumentImpl (com.intellij.openapi.editor.impl.DocumentImpl)1 TextRange (com.intellij.openapi.util.TextRange)1 RelativePoint (com.intellij.ui.awt.RelativePoint)1