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);
}
Aggregations