use of com.intellij.openapi.editor.markup.RangeHighlighter in project intellij-community by JetBrains.
the class EditorMarkupModelImpl method doClick.
private void doClick(@NotNull final MouseEvent e) {
RangeHighlighter marker = getNearestRangeHighlighter(e);
int offset;
LogicalPosition logicalPositionToScroll = null;
if (marker == null) {
if (myEditorPreviewHint != null) {
logicalPositionToScroll = myEditor.visualToLogicalPosition(new VisualPosition(myEditorFragmentRenderer.myStartVisualLine, 0));
offset = myEditor.getDocument().getLineStartOffset(logicalPositionToScroll.line);
} else {
return;
}
} else {
offset = marker.getStartOffset();
}
final Document doc = myEditor.getDocument();
if (doc.getLineCount() > 0 && myEditorPreviewHint == null) {
// Necessary to expand folded block even if navigating just before one
// Very useful when navigating to first unused import statement.
int lineEnd = doc.getLineEndOffset(doc.getLineNumber(offset));
myEditor.getCaretModel().moveToOffset(lineEnd);
}
myEditor.getCaretModel().removeSecondaryCarets();
myEditor.getCaretModel().moveToOffset(offset);
myEditor.getSelectionModel().removeSelection();
ScrollingModel scrollingModel = myEditor.getScrollingModel();
scrollingModel.disableAnimation();
if (logicalPositionToScroll != null) {
int lineY = myEditor.logicalPositionToXY(logicalPositionToScroll).y;
int relativePopupOffset = myEditorFragmentRenderer.myRelativeY;
scrollingModel.scrollVertically(lineY - relativePopupOffset);
} else {
scrollingModel.scrollToCaret(ScrollType.CENTER);
}
scrollingModel.enableAnimation();
if (marker != null) {
fireErrorMarkerClicked(marker, e);
}
}
use of com.intellij.openapi.editor.markup.RangeHighlighter in project intellij-community by JetBrains.
the class EditorImpl method setHighlightingFilter.
public void setHighlightingFilter(@Nullable Condition<RangeHighlighter> filter) {
if (myHighlightingFilter == filter)
return;
Condition<RangeHighlighter> oldFilter = myHighlightingFilter;
myHighlightingFilter = filter;
for (RangeHighlighter highlighter : myDocumentMarkupModel.getDelegate().getAllHighlighters()) {
boolean oldAvailable = oldFilter == null || oldFilter.value(highlighter);
boolean newAvailable = filter == null || filter.value(highlighter);
if (oldAvailable != newAvailable) {
myMarkupModelListener.attributesChanged((RangeHighlighterEx) highlighter, true, EditorUtil.attributesImpactFontStyleOrColor(highlighter.getTextAttributes()));
}
}
}
use of com.intellij.openapi.editor.markup.RangeHighlighter in project intellij-community by JetBrains.
the class ApplyPatchChange method createOperation.
@Nullable
private MyGutterOperation createOperation(@NotNull OperationType type) {
if (isResolved())
return null;
EditorEx editor = myViewer.getPatchEditor();
Document document = editor.getDocument();
int line = getPatchRange().start;
int offset = line == DiffUtil.getLineCount(document) ? document.getTextLength() : document.getLineStartOffset(line);
RangeHighlighter highlighter = editor.getMarkupModel().addRangeHighlighter(offset, offset, HighlighterLayer.ADDITIONAL_SYNTAX, null, HighlighterTargetArea.LINES_IN_RANGE);
return new MyGutterOperation(highlighter, type);
}
use of com.intellij.openapi.editor.markup.RangeHighlighter in project intellij-community by JetBrains.
the class ApplyPatchChange method destroyHighlighters.
private void destroyHighlighters() {
for (RangeHighlighter highlighter : myHighlighters) {
highlighter.dispose();
}
myHighlighters.clear();
for (MyGutterOperation operation : myOperations) {
operation.dispose();
}
myOperations.clear();
}
use of com.intellij.openapi.editor.markup.RangeHighlighter in project intellij-community by JetBrains.
the class LineStatusTracker method createHighlighter.
@Override
@CalledInAwt
protected void createHighlighter(@NotNull Range range) {
myApplication.assertIsDispatchThread();
if (range.getHighlighter() != null) {
LOG.error("Multiple highlighters registered for the same Range");
return;
}
if (myMode == Mode.SILENT)
return;
int first = range.getLine1() >= getLineCount(myDocument) ? myDocument.getTextLength() : myDocument.getLineStartOffset(range.getLine1());
int second = range.getLine2() >= getLineCount(myDocument) ? myDocument.getTextLength() : myDocument.getLineStartOffset(range.getLine2());
MarkupModel markupModel = DocumentMarkupModel.forDocument(myDocument, myProject, true);
RangeHighlighter highlighter = LineStatusMarkerRenderer.createRangeHighlighter(range, new TextRange(first, second), markupModel);
highlighter.setLineMarkerRenderer(LineStatusMarkerRenderer.createRenderer(range, (editor) -> {
return new LineStatusTrackerDrawing.MyLineStatusMarkerPopup(this, editor, range);
}));
highlighter.setEditorFilter(MarkupEditorFilterFactory.createIsNotDiffFilter());
range.setHighlighter(highlighter);
}
Aggregations