当前位置: 首页>>代码示例>>Java>>正文


Java HighlighterTargetArea类代码示例

本文整理汇总了Java中com.intellij.openapi.editor.markup.HighlighterTargetArea的典型用法代码示例。如果您正苦于以下问题:Java HighlighterTargetArea类的具体用法?Java HighlighterTargetArea怎么用?Java HighlighterTargetArea使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


HighlighterTargetArea类属于com.intellij.openapi.editor.markup包,在下文中一共展示了HighlighterTargetArea类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: highlightLine

import com.intellij.openapi.editor.markup.HighlighterTargetArea; //导入依赖的package包/类
private void highlightLine(int index, NamedTextAttr namedTextAttr) {
    UIUtil.invokeAndWaitIfNeeded((Runnable) () -> {
        try {
            MarkupModelEx markupModel = myEditor.getMarkupModel();
            final Document doc = markupModel.getDocument();
            final int lineStartOffset = doc.getLineStartOffset(index);
            final int lineEndOffset = doc.getLineEndOffset(index);
            // IDEA-53203: add ERASE_MARKER for manually defined attributes
            markupModel.addRangeHighlighter(lineStartOffset, lineEndOffset,
                    HighlighterLayer.SELECTION - 1, TextAttributes.ERASE_MARKER,
                    HighlighterTargetArea.EXACT_RANGE);
            RangeHighlighter rangeHighlight =
                    markupModel.addRangeHighlighter(lineStartOffset, lineEndOffset,
                            HighlighterLayer.SELECTION - 1, namedTextAttr,
                            HighlighterTargetArea.EXACT_RANGE);
            rangeHighlight.setErrorStripeMarkColor(namedTextAttr.getErrorStripeColor());
            rangeHighlight.setErrorStripeTooltip(namedTextAttr.getName());
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    });
}
 
开发者ID:huoguangjin,项目名称:MultiHighlight,代码行数:23,代码来源:ColorPreviewPanel.java

示例2: changedUpdateImpl

import com.intellij.openapi.editor.markup.HighlighterTargetArea; //导入依赖的package包/类
@Override
protected void changedUpdateImpl(@NotNull DocumentEvent e) {
  // todo Denis Zhdanov
  DocumentEventImpl event = (DocumentEventImpl)e;
  final boolean shouldTranslateViaDiff = isValid() && PersistentRangeMarkerUtil.shouldTranslateViaDiff(event, this);
  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));
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:PersistentRangeHighlighterImpl.java

示例3: HighlighterSweep

import com.intellij.openapi.editor.markup.HighlighterTargetArea; //导入依赖的package包/类
private HighlighterSweep(@NotNull MarkupModelEx markupModel, int start, int end, final boolean onlyFullLine) {
  // we have to get all highlighters in advance and sort them by affected offsets
  // since these can be different from the real offsets the highlighters are sorted by in the tree.  (See LINES_IN_RANGE perverts)
  final List<RangeHighlighterEx> list = new ArrayList<RangeHighlighterEx>();
  markupModel.processRangeHighlightersOverlappingWith(myReverseIteration ? end : start, 
                                                      myReverseIteration ? start : end,
                                                      new CommonProcessors.CollectProcessor<RangeHighlighterEx>(list) {
                                                        @Override
                                                        protected boolean accept(RangeHighlighterEx ex) {
                                                          return !onlyFullLine || ex.getTargetArea() == HighlighterTargetArea.LINES_IN_RANGE;
                                                        }
                                                      });
  highlighters = list.isEmpty() ? RangeHighlighterEx.EMPTY_ARRAY : list.toArray(new RangeHighlighterEx[list.size()]);
  Arrays.sort(highlighters, myReverseIteration ? BY_AFFECTED_END_OFFSET_REVERSED : RangeHighlighterEx.BY_AFFECTED_START_OFFSET);

  while (i < highlighters.length) {
    RangeHighlighterEx highlighter = highlighters[i++];
    if (!skipHighlighter(highlighter)) {
      myNextHighlighter = highlighter;
      break;
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:IterationState.java

示例4: advanceSegmentHighlighters

import com.intellij.openapi.editor.markup.HighlighterTargetArea; //导入依赖的package包/类
private void advanceSegmentHighlighters() {
  myDoc.advance();
  myView.advance();

  boolean fileEnd = myStartOffset == myDocument.getTextLength();
  for (int i = myCurrentHighlighters.size() - 1; i >= 0; i--) {
    RangeHighlighterEx highlighter = myCurrentHighlighters.get(i);
    if (myReverseIteration ?
        highlighter.getAffectedAreaStartOffset() >= myStartOffset :
        fileEnd && highlighter.getTargetArea() == HighlighterTargetArea.LINES_IN_RANGE ? 
        highlighter.getAffectedAreaEndOffset() < myStartOffset : 
        highlighter.getAffectedAreaEndOffset() <= myStartOffset) {
      myCurrentHighlighters.remove(i);
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:IterationState.java

示例5: HighlighterSweep

import com.intellij.openapi.editor.markup.HighlighterTargetArea; //导入依赖的package包/类
private HighlighterSweep(@NotNull MarkupModelEx markupModel, int start, int end, final boolean onlyFullLine) {
  // we have to get all highlighters in advance and sort them by affected offsets
  // since these can be different from the real offsets the highlighters are sorted by in the tree.  (See LINES_IN_RANGE perverts)
  final List<RangeHighlighterEx> list = new ArrayList<RangeHighlighterEx>();
  markupModel.processRangeHighlightersOverlappingWith(start, end, new CommonProcessors.CollectProcessor<RangeHighlighterEx>(list) {
    @Override
    protected boolean accept(RangeHighlighterEx ex) {
      return !onlyFullLine || ex.getTargetArea() == HighlighterTargetArea.LINES_IN_RANGE;
    }
  });
  highlighters = list.isEmpty() ? RangeHighlighterEx.EMPTY_ARRAY : list.toArray(new RangeHighlighterEx[list.size()]);
  Arrays.sort(highlighters, RangeHighlighterEx.BY_AFFECTED_START_OFFSET);

  while (i < highlighters.length) {
    RangeHighlighterEx highlighter = highlighters[i++];
    if (!skipHighlighter(highlighter)) {
      myNextHighlighter = highlighter;
      break;
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:IterationState.java

示例6: linkFollowed

import com.intellij.openapi.editor.markup.HighlighterTargetArea; //导入依赖的package包/类
private static void linkFollowed(Editor editor, Collection<RangeHighlighter> ranges, final RangeHighlighter link) {
  MarkupModelEx markupModel = (MarkupModelEx)editor.getMarkupModel();
  for (RangeHighlighter range : ranges) {
    TextAttributes oldAttr = range.getUserData(OLD_HYPERLINK_TEXT_ATTRIBUTES);
    if (oldAttr != null) {
      markupModel.setRangeHighlighterAttributes(range, oldAttr);
      range.putUserData(OLD_HYPERLINK_TEXT_ATTRIBUTES, null);
    }
    if (range == link) {
      range.putUserData(OLD_HYPERLINK_TEXT_ATTRIBUTES, range.getTextAttributes());
      markupModel.setRangeHighlighterAttributes(range, getFollowedHyperlinkAttributes(range));
    }
  }
  //refresh highlighter text attributes
  markupModel.addRangeHighlighter(0, 0, HYPERLINK_LAYER, getHyperlinkAttributes(), HighlighterTargetArea.EXACT_RANGE).dispose();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:EditorHyperlinkSupport.java

示例7: testRangeHighlighterLinesInRangeForLongLinePerformance

import com.intellij.openapi.editor.markup.HighlighterTargetArea; //导入依赖的package包/类
public void testRangeHighlighterLinesInRangeForLongLinePerformance() throws Exception {
  final int N = 50000;
  Document document = EditorFactory.getInstance().createDocument(StringUtil.repeatSymbol('x', 2 * N));

  final MarkupModelEx markupModel = (MarkupModelEx)DocumentMarkupModel.forDocument(document, ourProject, true);
  for (int i=0; i<N-1;i++) {
    markupModel.addRangeHighlighter(2*i, 2*i+1, 0, null, HighlighterTargetArea.EXACT_RANGE);
  }
  markupModel.addRangeHighlighter(N / 2, N / 2 + 1, 0, null, HighlighterTargetArea.LINES_IN_RANGE);

  PlatformTestUtil.startPerformanceTest("slow highlighters lookup", (int)(N*Math.log(N)/1000), new ThrowableRunnable() {
    @Override
    public void run() {
      List<RangeHighlighterEx> list = new ArrayList<RangeHighlighterEx>();
      CommonProcessors.CollectProcessor<RangeHighlighterEx> coll = new CommonProcessors.CollectProcessor<RangeHighlighterEx>(list);
      for (int i=0; i<N-1;i++) {
        list.clear();
        markupModel.processRangeHighlightersOverlappingWith(2*i, 2*i+1, coll);
        assertEquals(2, list.size());  // 1 line plus one exact range marker
      }
    }
  }).assertTiming();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:RangeMarkerTest.java

示例8: installHighlighterSet

import com.intellij.openapi.editor.markup.HighlighterTargetArea; //导入依赖的package包/类
@NotNull
private HighlightersSet installHighlighterSet(@NotNull Info info, @NotNull Editor editor) {
  final JComponent internalComponent = editor.getContentComponent();
  internalComponent.addKeyListener(myEditorKeyListener);
  editor.getScrollingModel().addVisibleAreaListener(myVisibleAreaListener);
  final Cursor cursor = internalComponent.getCursor();
  internalComponent.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
  myFileEditorManager.addFileEditorManagerListener(myFileEditorManagerListener);

  List<RangeHighlighter> highlighters = new ArrayList<RangeHighlighter>();
  TextAttributes attributes = myEditorColorsManager.getGlobalScheme().getAttributes(EditorColors.REFERENCE_HYPERLINK_COLOR);
  for (TextRange range : info.getRanges()) {
    TextAttributes attr = NavigationUtil.patchAttributesColor(attributes, range, editor);
    final RangeHighlighter highlighter = editor.getMarkupModel().addRangeHighlighter(range.getStartOffset(), range.getEndOffset(),
                                                                                     HighlighterLayer.SELECTION + 1,
                                                                                     attr,
                                                                                     HighlighterTargetArea.EXACT_RANGE);
    highlighters.add(highlighter);
  }

  return new HighlightersSet(highlighters, editor, cursor, info);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:CtrlMouseHandler.java

示例9: syntaxError

import com.intellij.openapi.editor.markup.HighlighterTargetArea; //导入依赖的package包/类
protected void syntaxError(String annotation, Token offendingToken) {
//		Annotation annot = new Annotation(20, 30, HighlightSeverity.ERROR, "Test!", "Test Message!");
//		HighlightInfo info = HighlightInfo.fromAnnotation(annot);
//		List<HighlightInfo> al = new ArrayList<HighlightInfo>();
//		al.add(info);
//		UpdateHighlightersUtil.setHighlightersToEditor(project, doc, 20, 30, al, null, 0)

		final TextAttributes attr = new TextAttributes();
		attr.setForegroundColor(JBColor.RED);
		attr.setEffectColor(JBColor.RED);
		attr.setEffectType(EffectType.WAVE_UNDERSCORE);
		MarkupModel markupModel = editor.getMarkupModel();
		RangeHighlighter h =
			markupModel.addRangeHighlighter(startIndex+offendingToken.getStartIndex(),
			                                startIndex+offendingToken.getStopIndex()+1,
			                                HighlighterLayer.ERROR, // layer
			                                attr,
			                                HighlighterTargetArea.EXACT_RANGE);
		h.putUserData(SYNTAX_HIGHLIGHTING_TAG, offendingToken); // store any non-null value to tag it
	}
 
开发者ID:antlr,项目名称:jetbrains-plugin-st4,代码行数:21,代码来源:SyntaxHighlighter.java

示例10: changedUpdateImpl

import com.intellij.openapi.editor.markup.HighlighterTargetArea; //导入依赖的package包/类
@Override
protected void changedUpdateImpl(DocumentEvent e) {
  // todo Denis Zhdanov
  DocumentEventImpl event = (DocumentEventImpl)e;
  final boolean shouldTranslateViaDiff = PersistentRangeMarkerUtil.shouldTranslateViaDiff(event, this);
  boolean wasTranslatedViaDiff = shouldTranslateViaDiff;
  if (shouldTranslateViaDiff) {
    wasTranslatedViaDiff = translatedViaDiff(e, event);
  }
  if (!wasTranslatedViaDiff) {
    super.changedUpdateImpl(e);
    if (isValid()) {
      setLine(getDocument().getLineNumber(getStartOffset()));
      int endLine = getDocument().getLineNumber(getEndOffset());
      if (endLine != getLine()) {
        setIntervalEnd(getDocument().getLineEndOffset(getLine()));
      }
    }
  }
  if (isValid() && getTargetArea() == HighlighterTargetArea.LINES_IN_RANGE) {
    setIntervalStart(getDocument().getLineStartOffset(getLine()));
    setIntervalEnd(getDocument().getLineEndOffset(getLine()));
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:25,代码来源:PersistentRangeHighlighterImpl.java

示例11: addRangeHighlighterAndChangeAttributes

import com.intellij.openapi.editor.markup.HighlighterTargetArea; //导入依赖的package包/类
@Override
public RangeHighlighterEx addRangeHighlighterAndChangeAttributes(int startOffset,
                                                                 int endOffset,
                                                                 int layer,
                                                                 TextAttributes textAttributes,
                                                                 @NotNull HighlighterTargetArea targetArea,
                                                                 boolean isPersistent,
                                                                 @Nullable Consumer<RangeHighlighterEx> changeAttributesAction) {
  ApplicationManager.getApplication().assertIsDispatchThread();
  RangeHighlighterEx highlighter = isPersistent
                                   ? new PersistentRangeHighlighterImpl(this, startOffset, layer, targetArea, textAttributes)
                                   : new RangeHighlighterImpl(this, startOffset, endOffset, layer, targetArea, textAttributes, false,
                                                              false);

  myCachedHighlighters = null;
  if (changeAttributesAction != null) {
    ((RangeHighlighterImpl)highlighter).changeAttributesNoEvents(changeAttributesAction);
  }
  fireAfterAdded(highlighter);
  return highlighter;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:22,代码来源:MarkupModelImpl.java

示例12: installHighlighterSet

import com.intellij.openapi.editor.markup.HighlighterTargetArea; //导入依赖的package包/类
private HighlightersSet installHighlighterSet(Info info, Editor editor) {
  final JComponent internalComponent = editor.getContentComponent();
  internalComponent.addKeyListener(myEditorKeyListener);
  editor.getScrollingModel().addVisibleAreaListener(myVisibleAreaListener);
  final Cursor cursor = internalComponent.getCursor();
  internalComponent.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
  myFileEditorManager.addFileEditorManagerListener(myFileEditorManagerListener);

  List<RangeHighlighter> highlighters = new ArrayList<RangeHighlighter>();
  TextAttributes attributes = myEditorColorsManager.getGlobalScheme().getAttributes(EditorColors.REFERENCE_HYPERLINK_COLOR);
  for (TextRange range : info.getRanges()) {
    final RangeHighlighter highlighter = editor.getMarkupModel().addRangeHighlighter(range.getStartOffset(), range.getEndOffset(),
                                                                                     HighlighterLayer.SELECTION + 1,
                                                                                     attributes,
                                                                                     HighlighterTargetArea.EXACT_RANGE);
    highlighters.add(highlighter);
  }

  return new HighlightersSet(highlighters, editor, cursor, info);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:21,代码来源:CtrlMouseHandler.java

示例13: addDecisionEventHighlighter

import com.intellij.openapi.editor.markup.HighlighterTargetArea; //导入依赖的package包/类
public Token addDecisionEventHighlighter(PreviewState previewState, MarkupModel markupModel,
                                         DecisionEventInfo info, Color errorStripeColor,
                                         EffectType effectType) {
	TokenStream tokens = previewState.parsingResult.parser.getInputStream();
	Token startToken = tokens.get(info.startIndex);
	Token stopToken = tokens.get(info.stopIndex);
	TextAttributes textAttributes =
		new TextAttributes(JBColor.BLACK, JBColor.WHITE, errorStripeColor,
		                   effectType, Font.PLAIN);
	textAttributes.setErrorStripeColor(errorStripeColor);
	final RangeHighlighter rangeHighlighter =
		markupModel.addRangeHighlighter(
			startToken.getStartIndex(), stopToken.getStopIndex()+1,
			HighlighterLayer.ADDITIONAL_SYNTAX, textAttributes,
			HighlighterTargetArea.EXACT_RANGE);
	rangeHighlighter.putUserData(DECISION_EVENT_INFO_KEY, info);
	rangeHighlighter.setErrorStripeMarkColor(errorStripeColor);
	return startToken;
}
 
开发者ID:antlr,项目名称:intellij-plugin-v4,代码行数:20,代码来源:ProfilerPanel.java

示例14: highlightAndOfferHint

import com.intellij.openapi.editor.markup.HighlighterTargetArea; //导入依赖的package包/类
public void highlightAndOfferHint(Editor editor, int offset,
                                  Interval sourceInterval,
                                  JBColor color,
                                  EffectType effectType, String hintText) {
	CaretModel caretModel = editor.getCaretModel();
	final TextAttributes attr = new TextAttributes();
	attr.setForegroundColor(color);
	attr.setEffectColor(color);
	attr.setEffectType(effectType);
	MarkupModel markupModel = editor.getMarkupModel();
	markupModel.addRangeHighlighter(
		sourceInterval.a,
		sourceInterval.b,
		InputPanel.TOKEN_INFO_LAYER, // layer
		attr,
		HighlighterTargetArea.EXACT_RANGE
	                               );

	if ( hintText.contains("<") ) {
		hintText = hintText.replaceAll("<", "&lt;");
	}

	// HINT
	caretModel.moveToOffset(offset); // info tooltip only shows at cursor :(
	HintManager.getInstance().showInformationHint(editor, hintText);
}
 
开发者ID:antlr,项目名称:intellij-plugin-v4,代码行数:27,代码来源:InputPanel.java

示例15: changedUpdateImpl

import com.intellij.openapi.editor.markup.HighlighterTargetArea; //导入依赖的package包/类
@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));
  }
}
 
开发者ID:consulo,项目名称:consulo,代码行数:25,代码来源:PersistentRangeHighlighterImpl.java


注:本文中的com.intellij.openapi.editor.markup.HighlighterTargetArea类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。