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


Java RangeHighlighter类代码示例

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


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

示例1: generateGherkinRunIcons

import com.intellij.openapi.editor.markup.RangeHighlighter; //导入依赖的package包/类
public void generateGherkinRunIcons(Document rootDocument, Editor rootEditor) {
    for (int i = 0; i < rootDocument.getLineCount(); i++) {
        int startOffset = rootDocument.getLineStartOffset(i);
        int endOffset = rootDocument.getLineEndOffset(i);

        String lineText = rootDocument.getText(new TextRange(startOffset, endOffset)).trim();

        Icon icon;
        if (lineText.matches(SCENARIO_REGEX)) {
            icon = GherkinIconRenderer.SCENARIO_ICON;
        } else if (lineText.matches(FEATURE_REGEX)) {
            icon = GherkinIconRenderer.FEATURE_ICON;
        } else {
            // System.out.println();
             continue;
        }
        GherkinIconRenderer gherkinIconRenderer = new GherkinIconRenderer(rootEditor.getProject(), fileName);
        gherkinIconRenderer.setLine(i);
        gherkinIconRenderer.setIcon(icon);

        RangeHighlighter rangeHighlighter = createRangeHighlighter(rootDocument, rootEditor, i, i, new TextAttributes());
        rangeHighlighter.setGutterIconRenderer(gherkinIconRenderer);
    }
}
 
开发者ID:KariiO,项目名称:Gherkin-TS-Runner,代码行数:25,代码来源:GherkinIconUtils.java

示例2: highlightLine

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

示例3: isClearHighlights

import com.intellij.openapi.editor.markup.RangeHighlighter; //导入依赖的package包/类
private static boolean isClearHighlights(@NotNull Editor editor) {
    if (editor instanceof EditorWindow) {
        editor = ((EditorWindow) editor).getDelegate();
    }
    
    final Project project = editor.getProject();
    if (project == null) {
        Log.error("isClearHighlights: editor.getProject() == null");
        return false;
    }
    
    int caretOffset = editor.getCaretModel().getOffset();
    final RangeHighlighter[] highlighters =
            ((HighlightManagerImpl) HighlightManager.getInstance(project)).getHighlighters(
                    editor);
    for (RangeHighlighter highlighter : highlighters) {
        if (TextRange.create(highlighter).grown(1).contains(caretOffset)) {
            return true;
        }
    }
    
    return false;
}
 
开发者ID:huoguangjin,项目名称:MultiHighlight,代码行数:24,代码来源:MultiHighlightHandler.java

示例4: actionPerformed

import com.intellij.openapi.editor.markup.RangeHighlighter; //导入依赖的package包/类
@Override
public void actionPerformed(AnActionEvent e) {
    final Project project = e.getRequiredData(CommonDataKeys.PROJECT);
    final Editor editor = e.getRequiredData(CommonDataKeys.EDITOR);
    
    final HighlightManager highlightManager = HighlightManager.getInstance(project);
    final RangeHighlighter[] highlighters =
            ((HighlightManagerImpl) highlightManager).getHighlighters(editor);
    for (RangeHighlighter highlighter : highlighters) {
        final TextAttributes ta = highlighter.getTextAttributes();
        if (ta != null && ta instanceof NamedTextAttr
                && highlighter.getLayer() == HighlighterLayer.SELECTION - 1) {
            highlightManager.removeSegmentHighlighter(editor, highlighter);
        }
    }
}
 
开发者ID:huoguangjin,项目名称:MultiHighlight,代码行数:17,代码来源:MultiHighlightClearAction.java

示例5: addHighlights

import com.intellij.openapi.editor.markup.RangeHighlighter; //导入依赖的package包/类
private static void addHighlights(List<TextRange> ranges, Editor editor, ArrayList<RangeHighlighter> highlighters) {
    EditorColorsManager colorsManager = EditorColorsManager.getInstance();
    TextAttributes attributes = colorsManager.getGlobalScheme().getAttributes(EditorColors.WRITE_SEARCH_RESULT_ATTRIBUTES);
    HighlightManager highlightManager = HighlightManager.getInstance(editor.getProject());
    Iterator iterator = ranges.iterator();

    while (iterator.hasNext()) {
        TextRange range = (TextRange) iterator.next();
        //highlightManager.addOccurrenceHighlight(editor, range.getStartOffset() + 1, range.getEndOffset() - 1, attributes, 0, highlighters, (Color) null);
        highlightManager.addRangeHighlight(editor, range.getStartOffset() + 1, range.getEndOffset() - 1, attributes, false, highlighters);
    }

    iterator = highlighters.iterator();

    while (iterator.hasNext()) {
        RangeHighlighter highlighter = (RangeHighlighter) iterator.next();
        highlighter.setGreedyToLeft(true);
        highlighter.setGreedyToRight(true);
    }

}
 
开发者ID:machaval,项目名称:mule-intellij-plugins,代码行数:22,代码来源:FlowInPlaceRenamer.java

示例6: addMarkerAtOffset

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

示例7: editBreakpoint

import com.intellij.openapi.editor.markup.RangeHighlighter; //导入依赖的package包/类
public void editBreakpoint(final Breakpoint breakpoint, final Editor editor) {
  DebuggerInvocationUtil.swingInvokeLater(myProject, new Runnable() {
    @Override
    public void run() {
      XBreakpoint xBreakpoint = breakpoint.myXBreakpoint;
      if (xBreakpoint instanceof XLineBreakpointImpl) {
        RangeHighlighter highlighter = ((XLineBreakpointImpl)xBreakpoint).getHighlighter();
        if (highlighter != null) {
          GutterIconRenderer renderer = highlighter.getGutterIconRenderer();
          if (renderer != null) {
            DebuggerSupport.getDebuggerSupport(JavaDebuggerSupport.class).getEditBreakpointAction().editBreakpoint(
              myProject, editor, breakpoint.myXBreakpoint, renderer
            );
          }
        }
      }
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:BreakpointManager.java

示例8: assertHighlighted

import com.intellij.openapi.editor.markup.RangeHighlighter; //导入依赖的package包/类
protected void assertHighlighted(VirtualFile file, HighlightInfo... expected) throws IOException {
  Editor editor = getEditor(file);
  HighlightUsagesHandler.invoke(myProject, editor, getTestPsiFile(file));

  RangeHighlighter[] highlighters = editor.getMarkupModel().getAllHighlighters();
  List<HighlightInfo> actual = new ArrayList<HighlightInfo>();
  for (RangeHighlighter each : highlighters) {
    if (!each.isValid()) continue;
    int offset = each.getStartOffset();
    PsiElement element = getTestPsiFile(file).findElementAt(offset);
    element = PsiTreeUtil.getParentOfType(element, XmlTag.class);
    String text = editor.getDocument().getText().substring(offset, each.getEndOffset());
    actual.add(new HighlightInfo(element, text));
  }

  assertUnorderedElementsAreEqual(actual, expected);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:MavenDomTestCase.java

示例9: highlightAllOccurrences

import com.intellij.openapi.editor.markup.RangeHighlighter; //导入依赖的package包/类
/**
 * @return List of highlighters
 */
public static List<RangeHighlighter> highlightAllOccurrences(Project project, PsiElement[] occurrences, Editor editor) {
  ArrayList<RangeHighlighter> highlighters = new ArrayList<RangeHighlighter>();
  HighlightManager highlightManager = HighlightManager.getInstance(project);
  EditorColorsManager colorsManager = EditorColorsManager.getInstance();
  TextAttributes attributes = colorsManager.getGlobalScheme().getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES);
  if (occurrences.length > 1) {
    for (PsiElement occurrence : occurrences) {
      final RangeMarker rangeMarker = occurrence.getUserData(ElementToWorkOn.TEXT_RANGE);
      if (rangeMarker != null && rangeMarker.isValid()) {
        highlightManager
          .addRangeHighlight(editor, rangeMarker.getStartOffset(), rangeMarker.getEndOffset(), attributes, true, highlighters);
      }
      else {
        final TextRange textRange = occurrence.getTextRange();
        highlightManager.addRangeHighlight(editor, textRange.getStartOffset(), textRange.getEndOffset(), attributes, true, highlighters);
      }
    }
  }
  return highlighters;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:RefactoringUtil.java

示例10: updateCursorHighlighting

import com.intellij.openapi.editor.markup.RangeHighlighter; //导入依赖的package包/类
private void updateCursorHighlighting() {
  hideBalloon();

  if (myCursorHighlighter != null) {
    HighlightManager.getInstance(mySearchResults.getProject()).removeSegmentHighlighter(mySearchResults.getEditor(), myCursorHighlighter);
    myCursorHighlighter = null;
  }

  final FindResult cursor = mySearchResults.getCursor();
  Editor editor = mySearchResults.getEditor();
  if (cursor != null && cursor.getEndOffset() <= editor.getDocument().getTextLength()) {
    Set<RangeHighlighter> dummy = new HashSet<RangeHighlighter>();
    Color color = editor.getColorsScheme().getColor(EditorColors.CARET_COLOR);
    highlightRange(cursor, new TextAttributes(null, null, color, EffectType.ROUNDED_BOX, 0), dummy);
    if (!dummy.isEmpty()) {
      myCursorHighlighter = dummy.iterator().next();
    }

    editor.getScrollingModel().runActionOnScrollingFinished(new Runnable() {
      @Override
      public void run() {
        showReplacementPreview();
      }
    });
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:LivePreview.java

示例11: apply

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

示例12: findAllGutters

import com.intellij.openapi.editor.markup.RangeHighlighter; //导入依赖的package包/类
@Override
@NotNull
public List<GutterMark> findAllGutters() {
  final Project project = getProject();
  final SortedMap<Integer, List<GutterMark>> result = new TreeMap<Integer, List<GutterMark>>();

  List<HighlightInfo> infos = doHighlighting();
  for (HighlightInfo info : infos) {
    addGutterIconRenderer(info.getGutterIconRenderer(), info.startOffset, result);
  }

  RangeHighlighter[] highlighters = DocumentMarkupModel.forDocument(myEditor.getDocument(), project, true).getAllHighlighters();
  for (final RangeHighlighter highlighter : highlighters) {
    if (!highlighter.isValid()) continue;
    addGutterIconRenderer(highlighter.getGutterIconRenderer(), highlighter.getStartOffset(), result);
  }
  return ContainerUtil.concat(result.values());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:CodeInsightTestFixtureImpl.java

示例13: finish

import com.intellij.openapi.editor.markup.RangeHighlighter; //导入依赖的package包/类
public void finish(boolean success) {
  if (!ourRenamersStack.isEmpty() && ourRenamersStack.peek() == this) {
    ourRenamersStack.pop();
  }
  if (myHighlighters != null) {
    if (!myProject.isDisposed()) {
      final HighlightManager highlightManager = HighlightManager.getInstance(myProject);
      for (RangeHighlighter highlighter : myHighlighters) {
        highlightManager.removeSegmentHighlighter(myEditor, highlighter);
      }
    }

    myHighlighters = null;
    myEditor.putUserData(INPLACE_RENAMER, null);
  }
  if (myBalloon != null) {
         if (!isRestart()) {
           myBalloon.hide();
         }
       }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:InplaceRefactoring.java

示例14: focusCurrentHighlighter

import com.intellij.openapi.editor.markup.RangeHighlighter; //导入依赖的package包/类
private void focusCurrentHighlighter(boolean toSelect) {
  if (isFinished()) {
    return;
  }
  if (myCurrentVariableNumber >= myTabStopHighlighters.size()) {
    return;
  }
  RangeHighlighter segmentHighlighter = myTabStopHighlighters.get(myCurrentVariableNumber);
  if (segmentHighlighter != null) {
    final int segmentNumber = getCurrentSegmentNumber();
    RangeHighlighter newSegmentHighlighter = getSegmentHighlighter(segmentNumber, toSelect, false);
    if (newSegmentHighlighter != null) {
      segmentHighlighter.dispose();
      myTabStopHighlighters.set(myCurrentVariableNumber, newSegmentHighlighter);
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:TemplateState.java

示例15: calcTooltipRenderer

import com.intellij.openapi.editor.markup.RangeHighlighter; //导入依赖的package包/类
@Override
public TooltipRenderer calcTooltipRenderer(@NotNull final Collection<RangeHighlighter> highlighters) {
  LineTooltipRenderer bigRenderer = null;
  //do not show same tooltip twice
  Set<String> tooltips = null;

  for (RangeHighlighter highlighter : highlighters) {
    final Object tooltipObject = highlighter.getErrorStripeTooltip();
    if (tooltipObject == null) continue;

    final String text = tooltipObject.toString();
    if (tooltips == null) {
      tooltips = new THashSet<String>();
    }
    if (tooltips.add(text)) {
      if (bigRenderer == null) {
        bigRenderer = new LineTooltipRenderer(text, new Object[]{highlighters});
      }
      else {
        bigRenderer.addBelow(text);
      }
    }
  }

  return bigRenderer;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:EditorMarkupModelImpl.java


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