Java Code Examples for com.intellij.openapi.editor.markup.HighlighterTargetArea#LINES_IN_RANGE

The following examples show how to use com.intellij.openapi.editor.markup.HighlighterTargetArea#LINES_IN_RANGE . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PersistentRangeHighlighterImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
protected void changedUpdateImpl(@Nonnull DocumentEvent e) {
  // todo Denis Zhdanov
  DocumentEventImpl event = (DocumentEventImpl)e;
  final boolean shouldTranslateViaDiff = isValid() && PersistentRangeMarkerUtil.shouldTranslateViaDiff(event, getStartOffset(), getEndOffset());
  boolean wasTranslatedViaDiff = shouldTranslateViaDiff;
  if (shouldTranslateViaDiff) {
    wasTranslatedViaDiff = translatedViaDiff(e, event);
  }
  if (!wasTranslatedViaDiff) {
    super.changedUpdateImpl(e);
    if (isValid()) {
      myLine = getDocument().getLineNumber(getStartOffset());
      int endLine = getDocument().getLineNumber(getEndOffset());
      if (endLine != myLine) {
        setIntervalEnd(getDocument().getLineEndOffset(myLine));
      }
    }
  }
  if (isValid() && getTargetArea() == HighlighterTargetArea.LINES_IN_RANGE) {
    setIntervalStart(DocumentUtil.getFirstNonSpaceCharOffset(getDocument(), myLine));
    setIntervalEnd(getDocument().getLineEndOffset(myLine));
  }
}
 
Example 2
Source File: ImmediatePainter.java    From consulo with Apache License 2.0 6 votes vote down vote up
private static void updateAttributes(final DesktopEditorImpl editor, final int offset, final List<? extends TextAttributes> attributes) {
  final List<RangeHighlighterEx> list1 = new ArrayList<>();
  final List<RangeHighlighterEx> list2 = new ArrayList<>();

  final Processor<RangeHighlighterEx> processor = highlighter -> {
    if (!highlighter.isValid()) return true;

    final boolean isLineHighlighter = highlighter.getTargetArea() == HighlighterTargetArea.LINES_IN_RANGE;

    if (isLineHighlighter || highlighter.getStartOffset() < offset) {
      list1.add(highlighter);
    }

    if (isLineHighlighter || highlighter.getEndOffset() > offset || (highlighter.getEndOffset() == offset && (highlighter.isGreedyToRight()))) {
      list2.add(highlighter);
    }

    return true;
  };

  editor.getFilteredDocumentMarkupModel().processRangeHighlightersOverlappingWith(Math.max(0, offset - 1), offset, processor);
  editor.getMarkupModel().processRangeHighlightersOverlappingWith(Math.max(0, offset - 1), offset, processor);

  updateAttributes(editor, attributes.get(0), list1);
  updateAttributes(editor, attributes.get(1), list2);
}