本文整理汇总了Java中com.intellij.codeInsight.highlighting.HighlightManager.addOccurrenceHighlight方法的典型用法代码示例。如果您正苦于以下问题:Java HighlightManager.addOccurrenceHighlight方法的具体用法?Java HighlightManager.addOccurrenceHighlight怎么用?Java HighlightManager.addOccurrenceHighlight使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.codeInsight.highlighting.HighlightManager
的用法示例。
在下文中一共展示了HighlightManager.addOccurrenceHighlight方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: highlightOccurrences
import com.intellij.codeInsight.highlighting.HighlightManager; //导入方法依赖的package包/类
private static void highlightOccurrences(String filter, Project project, Editor editor) {
final HighlightManager highlightManager = HighlightManager.getInstance(project);
EditorColorsManager colorManager = EditorColorsManager.getInstance();
final TextAttributes attributes = colorManager.getGlobalScheme().getAttributes(EditorColors.TEXT_SEARCH_RESULT_ATTRIBUTES);
String documentText = editor.getDocument().getText();
int i = -1;
while (true) {
int nextOccurrence = StringUtil.indexOfIgnoreCase(documentText, filter, i + 1);
if (nextOccurrence < 0) {
break;
}
i = nextOccurrence;
highlightManager.addOccurrenceHighlight(editor, i, i + filter.length(), attributes,
HighlightManager.HIDE_BY_TEXT_CHANGE, null, null);
}
}
示例2: itemHovered
import com.intellij.codeInsight.highlighting.HighlightManager; //导入方法依赖的package包/类
@Override
public void itemHovered(@Nullable BreadcrumbsPsiItem item) {
if (!Registry.is("editor.breadcrumbs.highlight.on.hover")) {
return;
}
HighlightManager hm = HighlightManager.getInstance(myProject);
if (myHighlighed != null) {
for (RangeHighlighter highlighter : myHighlighed) {
hm.removeSegmentHighlighter(myEditor, highlighter);
}
myHighlighed = null;
}
if (item != null) {
final TextRange range = item.getPsiElement().getTextRange();
final TextAttributes attributes = new TextAttributes();
final CrumbPresentation p = item.getPresentation();
final Color color = p != null ? p.getBackgroundColor(false, false, false) : BreadcrumbsComponent.ButtonSettings.DEFAULT_BG_COLOR;
final Color background = EditorColorsManager.getInstance().getGlobalScheme().getColor(EditorColors.CARET_ROW_COLOR);
attributes.setBackgroundColor(XmlTagTreeHighlightingUtil.makeTransparent(color, background != null ? background : Gray._200, 0.3));
myHighlighed = new ArrayList<RangeHighlighter>(1);
int flags = HighlightManager.HIDE_BY_ESCAPE | HighlightManager.HIDE_BY_TEXT_CHANGE | HighlightManager.HIDE_BY_ANY_KEY;
hm.addOccurrenceHighlight(myEditor, range.getStartOffset(), range.getEndOffset(), attributes, flags, myHighlighed, null);
}
}
示例3: highlight
import com.intellij.codeInsight.highlighting.HighlightManager; //导入方法依赖的package包/类
private static void highlight(@NotNull HighlightManager highlightManager,
@NotNull Collection<TextRange> textRanges, @NotNull Editor editor,
@NotNull TextAttributes ta, @Nullable Collection<RangeHighlighter> holder,
@Nullable Color scrollMarkColor) {
for (TextRange range : textRanges) {
highlightManager.addOccurrenceHighlight(editor, range.getStartOffset(),
range.getEndOffset(), ta, 0, holder, scrollMarkColor);
}
}
示例4: highlightWord
import com.intellij.codeInsight.highlighting.HighlightManager; //导入方法依赖的package包/类
private static void highlightWord(final CompletionVariant variant, final Project project) {
HighlightManager highlightManager = HighlightManager.getInstance(project);
EditorColorsManager colorManager = EditorColorsManager.getInstance();
TextAttributes attributes = colorManager.getGlobalScheme().getAttributes(EditorColors.TEXT_SEARCH_RESULT_ATTRIBUTES);
highlightManager.addOccurrenceHighlight(variant.editor, variant.offset, variant.offset + variant.variant.length(), attributes,
HighlightManager.HIDE_BY_ANY_KEY, null, null);
}
示例5: addHighlights
import com.intellij.codeInsight.highlighting.HighlightManager; //导入方法依赖的package包/类
protected void addHighlights(@NotNull Map<TextRange, TextAttributes> ranges,
@NotNull Editor editor,
@NotNull Collection<RangeHighlighter> highlighters,
@NotNull 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);
}
}
示例6: addHighlights
import com.intellij.codeInsight.highlighting.HighlightManager; //导入方法依赖的package包/类
private static void addHighlights(List<TextRange> ranges, Editor editor, ArrayList<RangeHighlighter> highlighters) {
EditorColorsManager colorsManager = EditorColorsManager.getInstance();
final TextAttributes attributes = colorsManager.getGlobalScheme().getAttributes(EditorColors.WRITE_SEARCH_RESULT_ATTRIBUTES);
final HighlightManager highlightManager = HighlightManager.getInstance(editor.getProject());
for (final TextRange range : ranges) {
highlightManager.addOccurrenceHighlight(editor, range.getStartOffset(), range.getEndOffset(), attributes, 0, highlighters, null);
}
for (RangeHighlighter highlighter : highlighters) {
highlighter.setGreedyToLeft(true);
highlighter.setGreedyToRight(true);
}
}
示例7: highlightWord
import com.intellij.codeInsight.highlighting.HighlightManager; //导入方法依赖的package包/类
private static void highlightWord(final Editor editor, final CompletionVariant variant, final Project project, CompletionData data) {
int delta = data.startOffset < variant.offset ? variant.variant.length() - data.myWordUnderCursor.length() : 0;
HighlightManager highlightManager = HighlightManager.getInstance(project);
EditorColorsManager colorManager = EditorColorsManager.getInstance();
TextAttributes attributes = colorManager.getGlobalScheme().getAttributes(EditorColors.TEXT_SEARCH_RESULT_ATTRIBUTES);
highlightManager.addOccurrenceHighlight(editor, variant.offset + delta, variant.offset + variant.variant.length() + delta, attributes,
HighlightManager.HIDE_BY_ANY_KEY, null, null);
}
示例8: highlightWord
import com.intellij.codeInsight.highlighting.HighlightManager; //导入方法依赖的package包/类
private static void highlightWord(final CompletionVariant variant, final Project project, CompletionData data) {
int delta = data.startOffset < variant.offset ? variant.variant.length() - data.myWordUnderCursor.length() : 0;
HighlightManager highlightManager = HighlightManager.getInstance(project);
EditorColorsManager colorManager = EditorColorsManager.getInstance();
TextAttributes attributes = colorManager.getGlobalScheme().getAttributes(EditorColors.TEXT_SEARCH_RESULT_ATTRIBUTES);
highlightManager.addOccurrenceHighlight(variant.editor, variant.offset + delta, variant.offset + variant.variant.length() + delta, attributes,
HighlightManager.HIDE_BY_ANY_KEY, null, null);
}
示例9: itemHovered
import com.intellij.codeInsight.highlighting.HighlightManager; //导入方法依赖的package包/类
private void itemHovered(Crumb crumb, InputEvent event) {
if (Boolean.TRUE) {
return;
}
HighlightManager hm = HighlightManager.getInstance(myProject);
if (myHighlighed != null) {
for (RangeHighlighter highlighter : myHighlighed) {
hm.removeSegmentHighlighter(myEditor, highlighter);
}
myHighlighed = null;
}
PsiElement psiElement = PsiCrumb.getElement(crumb);
if (psiElement != null) {
final TextRange range = psiElement.getTextRange();
final TextAttributes attributes = new TextAttributes();
final CrumbPresentation p = PsiCrumb.getPresentation(crumb);
Color color = p == null ? null : p.getBackgroundColor(false, false, false);
if (color == null) color = BreadcrumbsComponent.ButtonSettings.getBackgroundColor(false, false, false, false);
if (color == null) color = UIUtil.getLabelBackground();
final Color background = EditorColorsManager.getInstance().getGlobalScheme().getColor(EditorColors.CARET_ROW_COLOR);
attributes.setBackgroundColor(makeTransparent(color, background != null ? background : Gray._200, 0.3));
myHighlighed = new ArrayList<>(1);
int flags = HighlightManager.HIDE_BY_ESCAPE | HighlightManager.HIDE_BY_TEXT_CHANGE | HighlightManager.HIDE_BY_ANY_KEY;
hm.addOccurrenceHighlight(myEditor, range.getStartOffset(), range.getEndOffset(), attributes, flags, myHighlighed, null);
}
}
示例10: addHighlights
import com.intellij.codeInsight.highlighting.HighlightManager; //导入方法依赖的package包/类
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);
}
}