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


Java MarkupModel类代码示例

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


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

示例1: addMarkerAtOffset

import com.intellij.openapi.editor.markup.MarkupModel; //导入依赖的package包/类
private RangeHighlighter addMarkerAtOffset(int offset, SearchMark mark) {
    ApplicationManager.getApplication().assertIsDispatchThread();
    final Document document = editor.getDocument();

    if (0 <= offset && offset < document.getTextLength()) {
        editor.getSettings().setLineMarkerAreaShown(true);
        final int line = document.getLineNumber(offset);
        final MarkupModel markupModel = editor.getMarkupModel();

        RangeHighlighter highlighter;
        highlighter = markupModel.addLineHighlighter(line, HighlighterLayer.ADDITIONAL_SYNTAX, null);
        highlighter.setGutterIconRenderer(mark);
        return highlighter;
    } else {
        return null;
    }
}
 
开发者ID:samebug,项目名称:samebug-idea-plugin,代码行数:18,代码来源:ConsoleWatcher.java

示例2: apply

import com.intellij.openapi.editor.markup.MarkupModel; //导入依赖的package包/类
public void apply(@Nullable Project project, @NotNull Document document) {
  MarkupModel model = DocumentMarkupModel.forDocument(document, project, true);

  for (Element piece : myPieces) {
    RangeHighlighterEx delegate = piece.getDelegate();
    if (!delegate.isValid()) continue;

    RangeHighlighter highlighter = model
      .addRangeHighlighter(piece.getStart(), piece.getEnd(), delegate.getLayer(), delegate.getTextAttributes(), delegate.getTargetArea());
    highlighter.setEditorFilter(delegate.getEditorFilter());
    highlighter.setCustomRenderer(delegate.getCustomRenderer());
    highlighter.setErrorStripeMarkColor(delegate.getErrorStripeMarkColor());
    highlighter.setErrorStripeTooltip(delegate.getErrorStripeTooltip());
    highlighter.setGutterIconRenderer(delegate.getGutterIconRenderer());
    highlighter.setLineMarkerRenderer(delegate.getLineMarkerRenderer());
    highlighter.setLineSeparatorColor(delegate.getLineSeparatorColor());
    highlighter.setThinErrorStripeMark(delegate.isThinErrorStripeMark());
    highlighter.setLineSeparatorPlacement(delegate.getLineSeparatorPlacement());
    highlighter.setLineSeparatorRenderer(delegate.getLineSeparatorRenderer());
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:UnifiedEditorRangeHighlighter.java

示例3: testInfoTestAttributes

import com.intellij.openapi.editor.markup.MarkupModel; //导入依赖的package包/类
public void testInfoTestAttributes() throws Exception {
  LanguageExtensionPoint<Annotator> extension = new LanguageExtensionPoint<Annotator>();
  extension.language="TEXT";
  extension.implementationClass = TestAnnotator.class.getName();
  PlatformTestUtil.registerExtension(ExtensionPointName.create(LanguageAnnotators.EP_NAME), extension, getTestRootDisposable());
  myFixture.configureByText(PlainTextFileType.INSTANCE, "foo");
  EditorColorsScheme scheme = new EditorColorsSchemeImpl(new DefaultColorsScheme()){{initFonts();}};
  scheme.setAttributes(HighlighterColors.TEXT, new TextAttributes(Color.black, Color.white, null, null, Font.PLAIN));
  ((EditorEx)myFixture.getEditor()).setColorsScheme(scheme);
  myFixture.doHighlighting();
  MarkupModel model = DocumentMarkupModel.forDocument(myFixture.getEditor().getDocument(), getProject(), false);
  RangeHighlighter[] highlighters = model.getAllHighlighters();
  assertEquals(1, highlighters.length);
  TextAttributes attributes = highlighters[0].getTextAttributes();
  assertNotNull(attributes);
  assertNull(attributes.getBackgroundColor());
  assertNull(attributes.getForegroundColor());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:DocumentMarkupModelTest.java

示例4: syntaxError

import com.intellij.openapi.editor.markup.MarkupModel; //导入依赖的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

示例5: addDecisionEventHighlighter

import com.intellij.openapi.editor.markup.MarkupModel; //导入依赖的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

示例6: highlightAndOfferHint

import com.intellij.openapi.editor.markup.MarkupModel; //导入依赖的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

示例7: apply

import com.intellij.openapi.editor.markup.MarkupModel; //导入依赖的package包/类
public void apply(@Nullable Project project, @Nonnull Document document) {
  MarkupModel model = DocumentMarkupModel.forDocument(document, project, true);

  for (Element piece : myPieces) {
    RangeHighlighterEx delegate = piece.getDelegate();
    if (!delegate.isValid()) continue;

    RangeHighlighter highlighter = model
            .addRangeHighlighter(piece.getStart(), piece.getEnd(), delegate.getLayer(), delegate.getTextAttributes(), delegate.getTargetArea());
    highlighter.setEditorFilter(delegate.getEditorFilter());
    highlighter.setCustomRenderer(delegate.getCustomRenderer());
    highlighter.setErrorStripeMarkColor(delegate.getErrorStripeMarkColor());
    highlighter.setErrorStripeTooltip(delegate.getErrorStripeTooltip());
    highlighter.setGutterIconRenderer(delegate.getGutterIconRenderer());
    highlighter.setLineMarkerRenderer(delegate.getLineMarkerRenderer());
    highlighter.setLineSeparatorColor(delegate.getLineSeparatorColor());
    highlighter.setThinErrorStripeMark(delegate.isThinErrorStripeMark());
    highlighter.setLineSeparatorPlacement(delegate.getLineSeparatorPlacement());
    highlighter.setLineSeparatorRenderer(delegate.getLineSeparatorRenderer());
  }
}
 
开发者ID:consulo,项目名称:consulo,代码行数:22,代码来源:UnifiedEditorRangeHighlighter.java

示例8: patchAttributesColor

import com.intellij.openapi.editor.markup.MarkupModel; //导入依赖的package包/类
/**
 * Patches attributes to be visible under debugger active line
 */
@SuppressWarnings("UseJBColor")
public static TextAttributes patchAttributesColor(TextAttributes attributes, @Nonnull TextRange range, @Nonnull Editor editor) {
  if (attributes.getForegroundColor() == null && attributes.getEffectColor() == null) return attributes;
  MarkupModel model = DocumentMarkupModel.forDocument(editor.getDocument(), editor.getProject(), false);
  if (model != null) {
    if (!((MarkupModelEx)model).processRangeHighlightersOverlappingWith(range.getStartOffset(), range.getEndOffset(), highlighter -> {
      if (highlighter.isValid() && highlighter.getTargetArea() == HighlighterTargetArea.LINES_IN_RANGE) {
        TextAttributes textAttributes = highlighter.getTextAttributes();
        if (textAttributes != null) {
          Color color = textAttributes.getBackgroundColor();
          return !(color != null && color.getBlue() > 128 && color.getRed() < 128 && color.getGreen() < 128);
        }
      }
      return true;
    })) {
      TextAttributes clone = attributes.clone();
      clone.setForegroundColor(Color.orange);
      clone.setEffectColor(Color.orange);
      return clone;
    }
  }
  return attributes;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:27,代码来源:NavigationUtil.java

示例9: clearHighlightingAndLineMarkers

import com.intellij.openapi.editor.markup.MarkupModel; //导入依赖的package包/类
public static void clearHighlightingAndLineMarkers(final Editor editor, @NotNull Project project)
{
	final MarkupModel markupModel = DocumentMarkupModel.forDocument(editor.getDocument(), project, true);

	for(RangeHighlighter highlighter : markupModel.getAllHighlighters())
	{
		Object tooltip = highlighter.getErrorStripeTooltip();

		if(!(tooltip instanceof HighlightInfo))
		{
			continue;
		}

		if(((HighlightInfo) tooltip).type == TYPE)
		{
			highlighter.dispose();
		}
	}

	clearLineMarkers(editor);
}
 
开发者ID:consulo,项目名称:consulo-xml,代码行数:22,代码来源:XmlTagTreeHighlightingPass.java

示例10: getHighlighter

import com.intellij.openapi.editor.markup.MarkupModel; //导入依赖的package包/类
@Nullable
public static RangeHighlighter getHighlighter(MarkupModel model, AnswerPlaceholder placeholder) {
  for (RangeHighlighter highlighter : model.getAllHighlighters()) {
    int endOffset = placeholder.getOffset() + placeholder.getRealLength();
    if (highlighter.getStartOffset() == placeholder.getOffset() && highlighter.getEndOffset() == endOffset) {
      return highlighter;
    }
  }
  return null;
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:11,代码来源:CCTestCase.java

示例11: checkHighlighters

import com.intellij.openapi.editor.markup.MarkupModel; //导入依赖的package包/类
protected static void checkHighlighters(TaskFile taskFile, MarkupModel markupModel) {
  for (AnswerPlaceholder answerPlaceholder : taskFile.getActivePlaceholders()) {
    if (getHighlighter(markupModel, answerPlaceholder) == null) {
      throw new AssertionError("No highlighter for placeholder: " + CCTestsUtil.getPlaceholderPresentation(answerPlaceholder));
    }
  }
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:8,代码来源:CCTestCase.java

示例12: create

import com.intellij.openapi.editor.markup.MarkupModel; //导入依赖的package包/类
static PersistentRangeHighlighterImpl create(@NotNull MarkupModel model,
                                             int offset,
                                             int layer,
                                             @NotNull HighlighterTargetArea target,
                                             @Nullable TextAttributes textAttributes,
                                             boolean normalizeStartOffset) {
  int line = model.getDocument().getLineNumber(offset);
  int startOffset = normalizeStartOffset ? model.getDocument().getLineStartOffset(line) : offset;
  return new PersistentRangeHighlighterImpl(model, startOffset, line, layer, target, textAttributes);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:PersistentRangeHighlighterImpl.java

示例13: PersistentRangeHighlighterImpl

import com.intellij.openapi.editor.markup.MarkupModel; //导入依赖的package包/类
private PersistentRangeHighlighterImpl(@NotNull MarkupModel model,
                                       int startOffset,
                                       int line,
                                       int layer,
                                       @NotNull HighlighterTargetArea target,
                                       @Nullable TextAttributes textAttributes) {
  super(model, startOffset, model.getDocument().getLineEndOffset(line), layer, target, textAttributes, false, false);

  myLine = line;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:PersistentRangeHighlighterImpl.java

示例14: testRangeHighlightersRecreateBug

import com.intellij.openapi.editor.markup.MarkupModel; //导入依赖的package包/类
public void testRangeHighlightersRecreateBug() throws Exception {
  Document document = EditorFactory.getInstance().createDocument("[xxxxxxxxxxxxxx]");

  MarkupModel markupModel = DocumentMarkupModel.forDocument(document, ourProject, true);
  for (int i=0; i<2; i++) {
    RangeMarker m = markupModel.addRangeHighlighter(1, 6, 0, null, HighlighterTargetArea.EXACT_RANGE);
    RangeMarker m2 = markupModel.addRangeHighlighter(2, 7, 0, null, HighlighterTargetArea.EXACT_RANGE);
    RangeMarker m3 = markupModel.addRangeHighlighter(1, 6, 0, null, HighlighterTargetArea.EXACT_RANGE);
    markupModel.removeAllHighlighters();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:RangeMarkerTest.java

示例15: testRangeHighlighterDisposeVsRemoveAllConflict

import com.intellij.openapi.editor.markup.MarkupModel; //导入依赖的package包/类
public void testRangeHighlighterDisposeVsRemoveAllConflict() throws Exception {
  Document document = EditorFactory.getInstance().createDocument("[xxxxxxxxxxxxxx]");

  MarkupModel markupModel = DocumentMarkupModel.forDocument(document, ourProject, true);
  RangeMarker m = markupModel.addRangeHighlighter(1, 6, 0, null, HighlighterTargetArea.EXACT_RANGE);
  assertTrue(m.isValid());
  markupModel.removeAllHighlighters();
  assertFalse(m.isValid());
  assertEmpty(markupModel.getAllHighlighters());
  m.dispose();
  assertFalse(m.isValid());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:RangeMarkerTest.java


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