com.intellij.openapi.editor.Editor.getMarkupModel()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(8.8k)|赞(0)|评价(0)|浏览(194)

本文整理了Java中com.intellij.openapi.editor.Editor.getMarkupModel()方法的一些代码示例,展示了Editor.getMarkupModel()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Editor.getMarkupModel()方法的具体详情如下:
包路径:com.intellij.openapi.editor.Editor
类名称:Editor
方法名:getMarkupModel

Editor.getMarkupModel介绍

暂无

代码示例

代码示例来源:origin: JetBrains/ideavim

@NotNull
public static RangeHighlighter highlightMatch(@NotNull Editor editor, int start, int end) {
 TextAttributes color = editor.getColorsScheme().getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES);
 return editor.getMarkupModel().addRangeHighlighter(start, end, HighlighterLayer.ADDITIONAL_SYNTAX + 1,
                           color, HighlighterTargetArea.EXACT_RANGE);
}

代码示例来源:origin: JetBrains/ideavim

private static void removeSearchHighlight(@NotNull Editor editor) {
 Collection<RangeHighlighter> ehl = EditorData.getLastHighlights(editor);
 if (ehl == null) {
  return;
 }
 for (RangeHighlighter rh : ehl) {
  editor.getMarkupModel().removeHighlighter(rh);
 }
 ehl.clear();
 EditorData.setLastHighlights(editor, null);
 EditorData.setLastSearch(editor, null);
}

代码示例来源:origin: JetBrains/ideavim

@NotNull
private RangeHighlighter highlightConfirm(@NotNull Editor editor, int start, int end) {
 TextAttributes color = new TextAttributes(
  editor.getColorsScheme().getColor(EditorColors.SELECTION_FOREGROUND_COLOR),
  editor.getColorsScheme().getColor(EditorColors.SELECTION_BACKGROUND_COLOR),
  null, null, 0
 );
 return editor.getMarkupModel().addRangeHighlighter(start, end, HighlighterLayer.ADDITIONAL_SYNTAX + 2,
                           color, HighlighterTargetArea.EXACT_RANGE);
}

代码示例来源:origin: hsz/idea-gitignore

/**
 * Highlights given text ranges in {@link #preview} content.
 *
 * @param pairs text ranges
 */
private void highlightWords(@NotNull List<Pair<Integer, Integer>> pairs) {
  final TextAttributes attr = new TextAttributes();
  attr.setBackgroundColor(UIUtil.getTreeSelectionBackground());
  attr.setForegroundColor(UIUtil.getTreeSelectionForeground());
  for (Pair<Integer, Integer> pair : pairs) {
    preview.getMarkupModel().addRangeHighlighter(pair.first, pair.second, 0, attr,
        HighlighterTargetArea.EXACT_RANGE);
  }
}

代码示例来源:origin: JetBrains/ideavim

@Override
 protected void textChanged(DocumentEvent e) {
  final Editor editor = entry.getEditor();
  final boolean forwards = !label.getText().equals("?");
  if (incHighlighter != null) {
   editor.getMarkupModel().removeHighlighter(incHighlighter);
  }
  final String pattern = entry.getText();
  final TextRange range = SearchGroup.findNext(editor, pattern, editor.getCaretModel().getOffset(), true, forwards);
  if (range != null) {
   final TextAttributes color = editor.getColorsScheme().getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES);
   incHighlighter = SearchGroup.highlightMatch(editor, range.getStartOffset(), range.getEndOffset());
   incHighlighter.setErrorStripeMarkColor(color.getBackgroundColor());
   incHighlighter.setErrorStripeTooltip(pattern);
   MotionGroup.scrollPositionIntoView(editor, editor.offsetToVisualPosition(range.getStartOffset()), true);
  }
 }
};

代码示例来源:origin: JetBrains/ideavim

if (!rh.isValid() || (eoff >= rh.getStartOffset() && soff <= rh.getEndOffset())) {
 iter.remove();
 editor.getMarkupModel().removeHighlighter(rh);

代码示例来源:origin: JetBrains/ideavim

/**
 * Turns off the ex entry field and optionally puts the focus back to the original component
 */
public void deactivate(boolean refocusOwningEditor) {
 logger.info("deactivate");
 if (!active) return;
 active = false;
 if (!ApplicationManager.getApplication().isUnitTestMode()) {
  if (refocusOwningEditor && parent != null) {
   UiHelper.requestFocus(parent);
  }
  oldGlass.removeComponentListener(adapter);
  oldGlass.setVisible(false);
  oldGlass.remove(this);
  oldGlass.setOpaque(wasOpaque);
  oldGlass.setLayout(oldLayout);
  if (isIncSearchEnabled(label.getText())) {
   entry.getDocument().removeDocumentListener(documentListener);
   final Editor editor = entry.getEditor();
   editor.getScrollingModel().scrollVertically(verticalOffset);
   editor.getScrollingModel().scrollHorizontally(horizontalOffset);
   if (incHighlighter != null) {
    editor.getMarkupModel().removeHighlighter(incHighlighter);
   }
  }
 }
 parent = null;
}

代码示例来源:origin: JetBrains/ideavim

MotionGroup.moveCaret(editor, caret, start);
final ReplaceConfirmationChoice choice = confirmChoice(editor, match);
editor.getMarkupModel().removeHighlighter(hl);
switch (choice) {
 case SUBSTITUTE_THIS:

代码示例来源:origin: SonarSource/sonarlint-intellij

private void removeHighlights() {
 MarkupModel markupModel = myEditor.getMarkupModel();
 RangeHighlighter[] allHighlighters = markupModel.getAllHighlighters();
 myAddedHighlighters.stream()
  .filter(h -> !ArrayUtil.contains(allHighlighters, h))
  .forEach(RangeHighlighter::dispose);
 myAddedHighlighters.clear();
}

代码示例来源:origin: antlr/intellij-plugin-v4

/**
 * Clear all input highlighters
 */
public void clearInputEditorHighlighters() {
  Editor editor = getInputEditor();
  if ( editor==null ) return;
  MarkupModel markupModel = editor.getMarkupModel();
  markupModel.removeAllHighlighters();
}

代码示例来源:origin: infinitest/infinitest

@Override
public TextEditorHighlightingPass createHighlightingPass(@NotNull PsiFile psiFile, @NotNull Editor editor) {
  Module module = ModuleUtil.findModuleForPsiElement(psiFile);
  if (module == null) {
    return null;
  }
  return new InfinitestLineMarkersPass(module.getProject(), editor.getDocument(), editor.getMarkupModel());
}

代码示例来源:origin: sonar-intellij-plugin/sonar-intellij-plugin

private static void addHighlightersFromEditor(final Set<RangeHighlighter> highlighters, final Editor editor) {
 ApplicationManager.getApplication().invokeAndWait(() -> {
  final RangeHighlighter[] highlightersFromCurrentEditor = editor.getMarkupModel().getAllHighlighters();
  highlighters.addAll(Sets.newHashSet(highlightersFromCurrentEditor));
 }, ModalityState.any());
}

代码示例来源:origin: antlr/intellij-plugin-v4

public static void removeHighlighters(Editor editor, Key<?> key) {
  // Remove anything with user data accessible via key
  MarkupModel markupModel = editor.getMarkupModel();
  for (RangeHighlighter r : markupModel.getAllHighlighters()) {
    if ( r.getUserData(key)!=null ) {
      markupModel.removeHighlighter(r);
    }
  }
}

代码示例来源:origin: uwolfer/gerrit-intellij-plugin

public void removeComment(Project project, Editor editor, RangeHighlighter lineHighlighter, RangeHighlighter rangeHighlighter) {
  editor.getMarkupModel().removeHighlighter(lineHighlighter);
  lineHighlighter.dispose();
  if (rangeHighlighter != null) {
    HighlightManager highlightManager = HighlightManager.getInstance(project);
    highlightManager.removeSegmentHighlighter(editor, rangeHighlighter);
  }
}

代码示例来源:origin: uwolfer/gerrit-intellij-plugin

private static RangeHighlighter highlightRangeComment(Comment.Range range, Editor editor, Project project) {
    CharSequence charsSequence = editor.getMarkupModel().getDocument().getCharsSequence();

    RangeUtils.Offset offset = RangeUtils.rangeToTextOffset(charsSequence, range);

    TextAttributes attributes = new TextAttributes();
    attributes.setBackgroundColor(JBColor.YELLOW);
    ArrayList<RangeHighlighter> highlighters = Lists.newArrayList();
    HighlightManager highlightManager = HighlightManager.getInstance(project);
    highlightManager.addRangeHighlight(editor, offset.start, offset.end, attributes, false, highlighters);
    return highlighters.get(0);
  }
}

代码示例来源:origin: antlr/intellij-plugin-v4

/**
 * Remove any previous underlining or boxing, but not errors or decision event info
 */
public static void clearTokenInfoHighlighters(Editor editor) {
  MarkupModel markupModel = editor.getMarkupModel();
  for (RangeHighlighter r : markupModel.getAllHighlighters()) {
    if ( r.getUserData(ProfilerPanel.DECISION_EVENT_INFO_KEY)==null &&
      r.getUserData(SYNTAX_ERROR)==null ) {
      markupModel.removeHighlighter(r);
    }
  }
}

代码示例来源:origin: sonar-intellij-plugin/sonar-intellij-plugin

private static void removeAllHighlighters() {
 ApplicationManager.getApplication().invokeLater(
   () -> {
    Editor[] allEditors = EditorFactory.getInstance().getAllEditors();
    for (Editor editor : allEditors) {
     editor.getMarkupModel().removeAllHighlighters();
    }
   }
 );
}

代码示例来源:origin: uwolfer/gerrit-intellij-plugin

private Comment.Range handleRangeComment(SelectionModel selectionModel) {
    int startSelection = selectionModel.getBlockSelectionStarts()[0];
    int endSelection = selectionModel.getBlockSelectionEnds()[0];
    CharSequence charsSequence = editor.getMarkupModel().getDocument().getCharsSequence();
    return RangeUtils.textOffsetToRange(charsSequence, startSelection, endSelection);
  }
}

代码示例来源:origin: qeesung/HighlightBracketPair

public BraceHighlighter(Editor editor) {
  this.editor = editor;
  this.project = this.editor.getProject();
  this.document = this.editor.getDocument();
  this.psiFile = PsiDocumentManager.getInstance(project).getPsiFile(document);
  this.fileType = psiFile.getFileType();
  this.fileText = this.editor.getDocument().getImmutableCharSequence();
  this.markupModelEx = (MarkupModelEx) this.editor.getMarkupModel();
}

代码示例来源:origin: SeeSharpSoft/intellij-csv-validator

private RangeHighlighter[] testHighlightUsages(String... fileNames) {
  myFixture.configureByFiles(fileNames);
  HighlightUsagesHandlerBase handler = HighlightUsagesHandler.createCustomHandler(myFixture.getEditor(), myFixture.getFile());
  String featureId = handler.getFeatureId();
  if (featureId != null) {
    FeatureUsageTracker.getInstance().triggerFeatureUsed(featureId);
  }
  handler.highlightUsages();
  Editor editor = this.getEditor();
  return editor.getMarkupModel().getAllHighlighters();
}

相关文章