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


Java RangeHighlighter.getUserData方法代码示例

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


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

示例1: linkFollowed

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

示例2: getNextOccurrence

import com.intellij.openapi.editor.markup.RangeHighlighter; //导入方法依赖的package包/类
@Nullable
public static OccurenceNavigator.OccurenceInfo getNextOccurrence(final Editor editor,
                                                                 final int delta,
                                                                 final Consumer<RangeHighlighter> action) {
  final List<RangeHighlighter> ranges = getHyperlinks(0, editor.getDocument().getTextLength(),editor);
  if (ranges.isEmpty()) {
    return null;
  }
  int i;
  for (i = 0; i < ranges.size(); i++) {
    RangeHighlighter range = ranges.get(i);
    if (range.getUserData(OLD_HYPERLINK_TEXT_ATTRIBUTES) != null) {
      break;
    }
  }
  i = i % ranges.size();
  int newIndex = i;
  while (newIndex < ranges.size() && newIndex >= 0) {
    newIndex = (newIndex + delta + ranges.size()) % ranges.size();
    final RangeHighlighter next = ranges.get(newIndex);
    if (editor.getFoldingModel().getCollapsedRegionAtOffset(next.getStartOffset()) == null) {
      return new OccurenceNavigator.OccurenceInfo(new NavigatableAdapter() {
        public void navigate(final boolean requestFocus) {
          action.consume(next);
          linkFollowed(editor, ranges, next);
        }
      }, newIndex == -1 ? -1 : newIndex + 1, ranges.size());
    }
    if (newIndex == i) {
      break; // cycled through everything, found no next/prev hyperlink
    }
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:35,代码来源:EditorHyperlinkSupport.java

示例3: showInEditor

import com.intellij.openapi.editor.markup.RangeHighlighter; //导入方法依赖的package包/类
protected static void showInEditor(DetailView panel, VirtualFile virtualFile, int line) {
  TextAttributes attributes =
    EditorColorsManager.getInstance().getGlobalScheme().getAttributes(DebuggerColors.BREAKPOINT_ATTRIBUTES);

  DetailView.PreviewEditorState state = DetailView.PreviewEditorState.create(virtualFile, line, attributes);

  if (state.equals(panel.getEditorState())) {
    return;
  }

  panel.navigateInPreviewEditor(state);

  TextAttributes softerAttributes = attributes.clone();
  Color backgroundColor = softerAttributes.getBackgroundColor();
  if (backgroundColor != null) {
    softerAttributes.setBackgroundColor(ColorUtil.softer(backgroundColor));
  }

  final Editor editor = panel.getEditor();
  if (editor != null) {
    final MarkupModel editorModel = editor.getMarkupModel();
    final MarkupModel documentModel =
      DocumentMarkupModel.forDocument(editor.getDocument(), editor.getProject(), false);

    for (RangeHighlighter highlighter : documentModel.getAllHighlighters()) {
      if (highlighter.getUserData(DebuggerColors.BREAKPOINT_HIGHLIGHTER_KEY) == Boolean.TRUE) {
        final int line1 = editor.offsetToLogicalPosition(highlighter.getStartOffset()).line;
        if (line1 != line) {
          editorModel.addLineHighlighter(line1,
                                         DebuggerColors.BREAKPOINT_HIGHLIGHTER_LAYER + 1, softerAttributes);
        }
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:36,代码来源:BreakpointItem.java

示例4: getHyperlinkInfo

import com.intellij.openapi.editor.markup.RangeHighlighter; //导入方法依赖的package包/类
@Nullable
public static HyperlinkInfo getHyperlinkInfo(@NotNull RangeHighlighter range) {
  final HyperlinkInfoTextAttributes attributes = range.getUserData(HYPERLINK);
  return attributes != null ? attributes.getHyperlinkInfo() : null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:6,代码来源:EditorHyperlinkSupport.java

示例5: updateInSelectionHighlighters

import com.intellij.openapi.editor.markup.RangeHighlighter; //导入方法依赖的package包/类
private void updateInSelectionHighlighters() {
  if (mySearchResults.getEditor() == null) return;
  final SelectionModel selectionModel = mySearchResults.getEditor().getSelectionModel();
  int[] starts = selectionModel.getBlockSelectionStarts();
  int[] ends = selectionModel.getBlockSelectionEnds();

  final HashSet<RangeHighlighter> toRemove = new HashSet<RangeHighlighter>();
  Set<RangeHighlighter> toAdd = new HashSet<RangeHighlighter>();
  for (RangeHighlighter highlighter : myHighlighters) {
    if (!highlighter.isValid()) continue;
    boolean intersectsWithSelection = false;
    for (int i = 0; i < starts.length; ++i) {
      TextRange selectionRange = new TextRange(starts[i], ends[i]);
      intersectsWithSelection = selectionRange.intersects(highlighter.getStartOffset(), highlighter.getEndOffset()) &&
                                selectionRange.getEndOffset() != highlighter.getStartOffset() &&
                                highlighter.getEndOffset() != selectionRange.getStartOffset();
      if (intersectsWithSelection) break;
    }

    final Object userData = highlighter.getUserData(IN_SELECTION_KEY);
    if (userData != null) {
      if (!intersectsWithSelection) {
        if (userData == IN_SELECTION2) {
          HighlightManager.getInstance(mySearchResults.getProject()).removeSegmentHighlighter(mySearchResults.getEditor(), highlighter);
          toRemove.add(highlighter);
        } else {
          highlighter.putUserData(IN_SELECTION_KEY, null);
        }
      }
    } else if (intersectsWithSelection) {
      TextRange cursor = mySearchResults.getCursor();
      if (cursor != null && highlighter.getStartOffset() == cursor.getStartOffset() &&
          highlighter.getEndOffset() == cursor.getEndOffset()) continue;
      final RangeHighlighter toAnnotate = highlightRange(new TextRange(highlighter.getStartOffset(), highlighter.getEndOffset()),
                                                               new TextAttributes(null, null, Color.WHITE, EffectType.ROUNDED_BOX, 0), toAdd);
      highlighter.putUserData(IN_SELECTION_KEY, IN_SELECTION1);
      toAnnotate.putUserData(IN_SELECTION_KEY, IN_SELECTION2);
    }
  }
  myHighlighters.removeAll(toRemove);
  myHighlighters.addAll(toAdd);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:43,代码来源:LivePreview.java


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