mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
speed up gutter painting
This commit is contained in:
@@ -83,6 +83,7 @@ public final class IterationState {
|
||||
|
||||
private final TextAttributes myMergedAttributes = new TextAttributes();
|
||||
|
||||
@Nullable
|
||||
private final HighlighterIterator myHighlighterIterator;
|
||||
private final HighlighterSweep myView;
|
||||
private final HighlighterSweep myDoc;
|
||||
@@ -118,6 +119,7 @@ public final class IterationState {
|
||||
private final DocumentEx myDocument;
|
||||
private final EditorEx myEditor;
|
||||
private final Color myReadOnlyColor;
|
||||
private final boolean myUseOnlyFullLineHighlighters;
|
||||
|
||||
public IterationState(@NotNull EditorEx editor, int start, int end, boolean useCaretAndSelection) {
|
||||
this(editor, start, end, useCaretAndSelection, false);
|
||||
@@ -130,9 +132,10 @@ public final class IterationState {
|
||||
|
||||
myEnd = end;
|
||||
myEditor = editor;
|
||||
myUseOnlyFullLineHighlighters = useOnlyFullLineHighlighters;
|
||||
|
||||
LOG.assertTrue(myStartOffset <= myEnd);
|
||||
myHighlighterIterator = editor.getHighlighter().createIterator(start);
|
||||
myHighlighterIterator = useOnlyFullLineHighlighters ? null : editor.getHighlighter().createIterator(start);
|
||||
|
||||
boolean hasSelection = useCaretAndSelection && (editor.getCaretModel().supportsMultipleCarets() || editor.getSelectionModel().hasSelection() || editor.getSelectionModel().hasBlockSelection());
|
||||
if (!hasSelection) {
|
||||
@@ -265,7 +268,9 @@ public final class IterationState {
|
||||
advanceCurrentSelectionIndex();
|
||||
advanceCurrentVirtualSelectionIndex();
|
||||
|
||||
myCurrentFold = myFoldingModel.fetchOutermost(myStartOffset);
|
||||
if (!myUseOnlyFullLineHighlighters) {
|
||||
myCurrentFold = myFoldingModel.fetchOutermost(myStartOffset);
|
||||
}
|
||||
if (myCurrentFold != null) {
|
||||
myEndOffset = myCurrentFold.getEndOffset();
|
||||
}
|
||||
@@ -281,6 +286,9 @@ public final class IterationState {
|
||||
}
|
||||
|
||||
private int getHighlighterEnd(int start) {
|
||||
if (myHighlighterIterator == null) {
|
||||
return myEnd;
|
||||
}
|
||||
while (!myHighlighterIterator.atEnd()) {
|
||||
int end = myHighlighterIterator.getEnd();
|
||||
if (end > start) {
|
||||
@@ -304,6 +312,9 @@ public final class IterationState {
|
||||
}
|
||||
|
||||
private int getGuardedBlockEnd(int start) {
|
||||
if (myUseOnlyFullLineHighlighters) {
|
||||
return myEnd;
|
||||
}
|
||||
List<RangeMarker> blocks = myDocument.getGuardedBlocks();
|
||||
int min = myEnd;
|
||||
//noinspection ForLoopReplaceableByForEach
|
||||
@@ -359,6 +370,9 @@ public final class IterationState {
|
||||
}
|
||||
|
||||
private int getFoldRangesEnd(int startOffset) {
|
||||
if (myUseOnlyFullLineHighlighters) {
|
||||
return myEnd;
|
||||
}
|
||||
int end = myEnd;
|
||||
FoldRegion[] topLevelCollapsed = myFoldingModel.fetchTopLevel();
|
||||
if (topLevelCollapsed != null) {
|
||||
@@ -401,15 +415,15 @@ public final class IterationState {
|
||||
}
|
||||
|
||||
private void reinit() {
|
||||
if (myHighlighterIterator.atEnd()) {
|
||||
if (myHighlighterIterator != null && myHighlighterIterator.atEnd()) {
|
||||
return;
|
||||
}
|
||||
|
||||
boolean isInSelection = isInSelection();
|
||||
boolean isInCaretRow = myStartOffset >= myCaretRowStart && myStartOffset < myCaretRowEnd;
|
||||
boolean isInGuardedBlock = myDocument.getOffsetGuard(myStartOffset) != null;
|
||||
boolean isInGuardedBlock = !myUseOnlyFullLineHighlighters && myDocument.getOffsetGuard(myStartOffset) != null;
|
||||
|
||||
TextAttributes syntax = myHighlighterIterator.getTextAttributes();
|
||||
TextAttributes syntax = myHighlighterIterator == null ? null : myHighlighterIterator.getTextAttributes();
|
||||
|
||||
TextAttributes selection = isInSelection ? mySelectionAttributes : null;
|
||||
TextAttributes caret = isInCaretRow ? myCaretRowAttributes : null;
|
||||
|
||||
Reference in New Issue
Block a user