Java Code Examples for com.intellij.openapi.editor.markup.RangeHighlighter#setGreedyToLeft()

The following examples show how to use com.intellij.openapi.editor.markup.RangeHighlighter#setGreedyToLeft() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FlowInPlaceRenamer.java    From mule-intellij-plugins with Apache License 2.0 6 votes vote down vote up
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);
    }

}
 
Example 2
Source File: TemplateState.java    From consulo with Apache License 2.0 5 votes vote down vote up
private RangeHighlighter getSegmentHighlighter(int segmentNumber, boolean isSelected, boolean isEnd) {
  final TextAttributes lvAttr = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(EditorColors.LIVE_TEMPLATE_ATTRIBUTES);
  TextAttributes attributes = isSelected ? lvAttr : new TextAttributes();
  TextAttributes endAttributes = new TextAttributes();

  int start = mySegments.getSegmentStart(segmentNumber);
  int end = mySegments.getSegmentEnd(segmentNumber);
  RangeHighlighter segmentHighlighter = myEditor.getMarkupModel()
          .addRangeHighlighter(start, end, HighlighterLayer.LAST + 1, isEnd ? endAttributes : attributes, HighlighterTargetArea.EXACT_RANGE);
  segmentHighlighter.setGreedyToLeft(true);
  segmentHighlighter.setGreedyToRight(true);
  return segmentHighlighter;
}
 
Example 3
Source File: InplaceRefactoring.java    From consulo with Apache License 2.0 5 votes vote down vote up
protected void addHighlights(@Nonnull Map<TextRange, TextAttributes> ranges,
                             @Nonnull Editor editor,
                             @Nonnull Collection<RangeHighlighter> highlighters,
                             @Nonnull HighlightManager highlightManager) {
  for (Map.Entry<TextRange, TextAttributes> entry : ranges.entrySet()) {
    TextRange range = entry.getKey();
    TextAttributes attributes = entry.getValue();
    highlightManager.addOccurrenceHighlight(editor, range.getStartOffset(), range.getEndOffset(), attributes, 0, highlighters, null);
  }

  for (RangeHighlighter highlighter : highlighters) {
    highlighter.setGreedyToLeft(true);
    highlighter.setGreedyToRight(true);
  }
}
 
Example 4
Source File: InplaceChangeSignature.java    From consulo with Apache License 2.0 5 votes vote down vote up
public InplaceChangeSignature(Project project, Editor editor, @Nonnull PsiElement element) {
  myDocumentManager = PsiDocumentManager.getInstance(project);
  myProject = project;
  try {
    myMarkAction = StartMarkAction.start(editor, project, ChangeSignatureHandler.REFACTORING_NAME);
  }
  catch (StartMarkAction.AlreadyStartedException e) {
    final int exitCode = Messages.showYesNoDialog(myProject, e.getMessage(), ChangeSignatureHandler.REFACTORING_NAME, "Navigate to Started", "Cancel", Messages.getErrorIcon());
    if (exitCode == Messages.CANCEL) return;
    PsiElement method = myStableChange.getMethod();
    VirtualFile virtualFile = PsiUtilCore.getVirtualFile(method);
    new OpenFileDescriptor(project, virtualFile, method.getTextOffset()).navigate(true);
    return;
  }


  myEditor = editor;
  myDetector = LanguageChangeSignatureDetectors.INSTANCE.forLanguage(element.getLanguage());
  myStableChange = myDetector.createInitialChangeInfo(element);
  myInitialSignature = myDetector.extractSignature(myStableChange);
  myInitialName = DescriptiveNameUtil.getDescriptiveName(myStableChange.getMethod());
  TextRange highlightingRange = myDetector.getHighlightingRange(myStableChange);

  HighlightManager highlightManager = HighlightManager.getInstance(myProject);
  TextAttributes attributes = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(EditorColors.LIVE_TEMPLATE_ATTRIBUTES);
  highlightManager.addRangeHighlight(editor, highlightingRange.getStartOffset(), highlightingRange.getEndOffset(), attributes, false, myHighlighters);
  for (RangeHighlighter highlighter : myHighlighters) {
    highlighter.setGreedyToRight(true);
    highlighter.setGreedyToLeft(true);
  }
  myEditor.getDocument().addDocumentListener(this);
  myEditor.putUserData(INPLACE_CHANGE_SIGNATURE, this);
  myPreview = InplaceRefactoring.createPreviewComponent(project, myDetector.getFileType());
  showBalloon();
}
 
Example 5
Source File: TemplateState.java    From consulo with Apache License 2.0 4 votes vote down vote up
public void setTabStopHighlightersGreedy(boolean greedy) {
  for (RangeHighlighter highlighter : myTabStopHighlighters) {
    highlighter.setGreedyToLeft(greedy);
    highlighter.setGreedyToRight(greedy);
  }
}