use of com.intellij.openapi.editor.markup.RangeHighlighter in project intellij-community by JetBrains.
the class CodeInsightTestFixtureImpl method findAllGutters.
@Override
@NotNull
public List<GutterMark> findAllGutters() {
final Project project = getProject();
final SortedMap<Integer, List<GutterMark>> result = new TreeMap<>();
List<HighlightInfo> infos = doHighlighting();
for (HighlightInfo info : infos) {
addGutterIconRenderer(info.getGutterIconRenderer(), info.startOffset, result);
}
RangeHighlighter[] highlighters = DocumentMarkupModel.forDocument(myEditor.getDocument(), project, true).getAllHighlighters();
for (final RangeHighlighter highlighter : highlighters) {
if (!highlighter.isValid())
continue;
addGutterIconRenderer(highlighter.getGutterIconRenderer(), highlighter.getStartOffset(), result);
}
return ContainerUtil.concat(result.values());
}
use of com.intellij.openapi.editor.markup.RangeHighlighter in project intellij-community by JetBrains.
the class CodeInsightTestFixtureImpl method findGutters.
private void findGutters(Processor<GutterMark> processor) {
int offset = myEditor.getCaretModel().getOffset();
final Collection<HighlightInfo> infos = doHighlighting();
for (HighlightInfo info : infos) {
if (info.endOffset >= offset && info.startOffset <= offset) {
final GutterMark renderer = info.getGutterIconRenderer();
if (renderer != null && !processor.process(renderer)) {
return;
}
}
}
RangeHighlighter[] highlighters = DocumentMarkupModel.forDocument(myEditor.getDocument(), getProject(), true).getAllHighlighters();
for (RangeHighlighter highlighter : highlighters) {
if (highlighter.getEndOffset() >= offset && highlighter.getStartOffset() <= offset) {
GutterMark renderer = highlighter.getGutterIconRenderer();
if (renderer != null && !processor.process(renderer)) {
return;
}
}
}
}
use of com.intellij.openapi.editor.markup.RangeHighlighter in project intellij-community by JetBrains.
the class ApplyPatchChange method createStatusHighlighter.
private void createStatusHighlighter() {
int line1 = myPatchDeletionRange.start;
int line2 = myPatchInsertionRange.end;
Color color = getStatusColor();
if (isResolved()) {
color = ColorUtil.mix(color, myViewer.getPatchEditor().getGutterComponentEx().getBackground(), 0.6f);
}
String tooltip = getStatusText();
EditorEx patchEditor = myViewer.getPatchEditor();
Document document = patchEditor.getDocument();
MarkupModelEx markupModel = patchEditor.getMarkupModel();
TextRange textRange = DiffUtil.getLinesRange(document, line1, line2);
RangeHighlighter highlighter = markupModel.addRangeHighlighter(textRange.getStartOffset(), textRange.getEndOffset(), HighlighterLayer.LAST, null, HighlighterTargetArea.LINES_IN_RANGE);
PairConsumer<Editor, MouseEvent> clickHandler = getResultRange() != null ? (e, event) -> myViewer.scrollToChange(this, Side.RIGHT, false) : null;
highlighter.setLineMarkerRenderer(LineStatusMarkerRenderer.createRenderer(line1, line2, color, tooltip, clickHandler));
myHighlighters.add(highlighter);
}
use of com.intellij.openapi.editor.markup.RangeHighlighter in project intellij-community by JetBrains.
the class EditorImplTest method testChangingHighlightersInBulkModeListener.
public void testChangingHighlightersInBulkModeListener() throws Exception {
DocumentBulkUpdateListener.Adapter listener = new DocumentBulkUpdateListener.Adapter() {
@Override
public void updateFinished(@NotNull Document doc) {
if (doc == myEditor.getDocument()) {
myEditor.getMarkupModel().addRangeHighlighter(7, 8, 0, null, HighlighterTargetArea.EXACT_RANGE);
}
}
};
getProject().getMessageBus().connect(getTestRootDisposable()).subscribe(DocumentBulkUpdateListener.TOPIC, listener);
initText("abcdef");
DocumentEx document = (DocumentEx) myEditor.getDocument();
runWriteCommand(() -> {
DocumentUtil.executeInBulk(document, true, () -> {
document.insertString(3, "\n\n");
});
});
RangeHighlighter[] highlighters = myEditor.getMarkupModel().getAllHighlighters();
assertEquals(1, highlighters.length);
assertEquals(7, highlighters[0].getStartOffset());
assertEquals(8, highlighters[0].getEndOffset());
}
use of com.intellij.openapi.editor.markup.RangeHighlighter in project intellij-community by JetBrains.
the class EditorImplTest method testChangingHighlightersAfterClearingFoldingsDuringFoldingBatchUpdate.
public void testChangingHighlightersAfterClearingFoldingsDuringFoldingBatchUpdate() throws Exception {
initText("abc\n\ndef");
addCollapsedFoldRegion(2, 6, "...");
runFoldingOperation(() -> {
((FoldingModelEx) myEditor.getFoldingModel()).clearFoldRegions();
myEditor.getMarkupModel().addRangeHighlighter(7, 8, 0, new TextAttributes(null, null, null, null, Font.BOLD), HighlighterTargetArea.EXACT_RANGE);
});
RangeHighlighter[] highlighters = myEditor.getMarkupModel().getAllHighlighters();
assertEquals(1, highlighters.length);
assertEquals(7, highlighters[0].getStartOffset());
assertEquals(8, highlighters[0].getEndOffset());
}
Aggregations