Exemplo n.º 1
0
 private void paintBorder(RangeHighlighterEx rangeHighlighter, TextAttributes textAttributes) {
   paintBorder(
       textAttributes.getEffectColor(),
       rangeHighlighter.getAffectedAreaStartOffset(),
       rangeHighlighter.getAffectedAreaEndOffset(),
       textAttributes.getEffectType());
 }
Exemplo n.º 2
0
 @NotNull
 public String getText() {
   RangeHighlighterEx highlighter = this.highlighter;
   if (highlighter == null) throw new RuntimeException("info not applied yet");
   if (!highlighter.isValid()) return "";
   return highlighter.getDocument().getText(TextRange.create(highlighter));
 }
 private static void duplicateHighlighters(
     MarkupModel to, MarkupModel from, int offset, TextRange textRange) {
   for (RangeHighlighter rangeHighlighter : from.getAllHighlighters()) {
     if (!rangeHighlighter.isValid()) continue;
     Object tooltip = rangeHighlighter.getErrorStripeTooltip();
     HighlightInfo highlightInfo =
         tooltip instanceof HighlightInfo ? (HighlightInfo) tooltip : null;
     if (highlightInfo != null) {
       if (highlightInfo.getSeverity() != HighlightSeverity.INFORMATION) continue;
       if (highlightInfo.type.getAttributesKey() == EditorColors.IDENTIFIER_UNDER_CARET_ATTRIBUTES)
         continue;
     }
     final int localOffset = textRange.getStartOffset();
     final int start = Math.max(rangeHighlighter.getStartOffset(), localOffset) - localOffset;
     final int end =
         Math.min(rangeHighlighter.getEndOffset(), textRange.getEndOffset()) - localOffset;
     if (start > end) continue;
     final RangeHighlighter h =
         to.addRangeHighlighter(
             start + offset,
             end + offset,
             rangeHighlighter.getLayer(),
             rangeHighlighter.getTextAttributes(),
             rangeHighlighter.getTargetArea());
     ((RangeHighlighterEx) h)
         .setAfterEndOfLine(((RangeHighlighterEx) rangeHighlighter).isAfterEndOfLine());
   }
 }
 private static boolean isOffsetInsideHighlightInfo(
     int offset, HighlightInfo info, boolean includeFixRange) {
   RangeHighlighterEx highlighter = info.highlighter;
   if (highlighter == null || !highlighter.isValid()) return false;
   int startOffset = highlighter.getStartOffset();
   int endOffset = highlighter.getEndOffset();
   if (startOffset <= offset && offset <= endOffset) {
     return true;
   }
   if (!includeFixRange) return false;
   RangeMarker fixMarker = info.fixMarker;
   if (fixMarker != null) { // null means its range is the same as highlighter
     if (!fixMarker.isValid()) return false;
     startOffset = fixMarker.getStartOffset();
     endOffset = fixMarker.getEndOffset();
     return startOffset <= offset && offset <= endOffset;
   }
   return false;
 }
 private void paintHighlighterAfterEndOfLine(Graphics2D g, RangeHighlighterEx highlighter) {
   if (!highlighter.isAfterEndOfLine()) {
     return;
   }
   int startOffset = highlighter.getStartOffset();
   int lineEndOffset = myDocument.getLineEndOffset(myDocument.getLineNumber(startOffset));
   if (myEditor.getFoldingModel().isOffsetCollapsed(lineEndOffset)) return;
   Point lineEnd = myView.offsetToXY(lineEndOffset, true, false);
   int x = lineEnd.x;
   int y = lineEnd.y;
   TextAttributes attributes = highlighter.getTextAttributes();
   paintBackground(g, attributes, x, y, myView.getPlainSpaceWidth());
   if (attributes != null
       && hasTextEffect(attributes.getEffectColor(), attributes.getEffectType())) {
     paintTextEffect(
         g,
         x,
         x + myView.getPlainSpaceWidth() - 1,
         y + myView.getAscent(),
         attributes.getEffectColor(),
         attributes.getEffectType());
   }
 }
 private void findNextSuitableRange() {
   myNextAttributes = null;
   while (myIterator.hasNext()) {
     RangeHighlighterEx highlighter = myIterator.next();
     if (highlighter == null
         || !highlighter.isValid()
         || !isInterestedInLayer(highlighter.getLayer())) {
       continue;
     }
     // LINES_IN_RANGE highlighters are not supported currently
     myNextStart = Math.max(highlighter.getStartOffset(), myStartOffset);
     myNextEnd = Math.min(highlighter.getEndOffset(), myEndOffset);
     if (myNextStart >= myEndOffset) {
       break;
     }
     if (myNextStart < myCurrentEnd) {
       continue; // overlapping ranges withing document markup model are not supported currently
     }
     TextAttributes attributes = null;
     Object tooltip = highlighter.getErrorStripeTooltip();
     if (tooltip instanceof HighlightInfo) {
       HighlightInfo info = (HighlightInfo) tooltip;
       TextAttributesKey key = info.forcedTextAttributesKey;
       if (key == null) {
         HighlightInfoType type = info.type;
         key = type.getAttributesKey();
       }
       if (key != null) {
         attributes = myColorsScheme.getAttributes(key);
       }
     }
     if (attributes == null) {
       continue;
     }
     Color foreground = attributes.getForegroundColor();
     Color background = attributes.getBackgroundColor();
     if ((foreground == null || myDefaultForeground.equals(foreground))
         && (background == null || myDefaultBackground.equals(background))
         && attributes.getFontType() == Font.PLAIN) {
       continue;
     }
     myNextAttributes = attributes;
     break;
   }
 }
Exemplo n.º 7
0
 public int getActualEndOffset() {
   RangeHighlighterEx h = highlighter;
   return h == null || !h.isValid() ? endOffset : h.getEndOffset();
 }
Exemplo n.º 8
0
 public int getActualStartOffset() {
   RangeHighlighterEx h = highlighter;
   return h == null || !h.isValid() ? startOffset : h.getStartOffset();
 }