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


Java HighlightManager类代码示例

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


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

示例1: isClearHighlights

import com.intellij.codeInsight.highlighting.HighlightManager; //导入依赖的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

示例2: actionPerformed

import com.intellij.codeInsight.highlighting.HighlightManager; //导入依赖的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

示例3: addHighlights

import com.intellij.codeInsight.highlighting.HighlightManager; //导入依赖的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

示例4: showSideEffectsWarning

import com.intellij.codeInsight.highlighting.HighlightManager; //导入依赖的package包/类
public static RemoveUnusedVariableUtil.RemoveMode showSideEffectsWarning(List<PsiElement> sideEffects,
                                         PsiVariable variable,
                                         Editor editor,
                                         boolean canCopeWithSideEffects,
                                         @NonNls String beforeText,
                                         @NonNls String afterText) {
  if (sideEffects.isEmpty()) return RemoveUnusedVariableUtil.RemoveMode.DELETE_ALL;
  if (ApplicationManager.getApplication().isUnitTestMode()) {
    return canCopeWithSideEffects
           ? RemoveUnusedVariableUtil.RemoveMode.MAKE_STATEMENT
           : RemoveUnusedVariableUtil.RemoveMode.DELETE_ALL;
  }
  Project project = editor.getProject();
  HighlightManager highlightManager = HighlightManager.getInstance(project);
  PsiElement[] elements = PsiUtilCore.toPsiElementArray(sideEffects);
  EditorColorsManager manager = EditorColorsManager.getInstance();
  TextAttributes attributes = manager.getGlobalScheme().getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES);
  highlightManager.addOccurrenceHighlights(editor, elements, attributes, true, null);

  SideEffectWarningDialog dialog = new SideEffectWarningDialog(project, false, variable, beforeText, afterText, canCopeWithSideEffects);
  dialog.show();
  int code = dialog.getExitCode();
  return RemoveUnusedVariableUtil.RemoveMode.values()[code];
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:RemoveUnusedVariableFix.java

示例5: 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);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:ThreadDumpPanel.java

示例6: highlightAllOccurrences

import com.intellij.codeInsight.highlighting.HighlightManager; //导入依赖的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

示例7: updateCursorHighlighting

import com.intellij.codeInsight.highlighting.HighlightManager; //导入依赖的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

示例8: findNextUsageInFile

import com.intellij.codeInsight.highlighting.HighlightManager; //导入依赖的package包/类
private boolean findNextUsageInFile(@NotNull FileEditor fileEditor, @NotNull SearchResults.Direction direction) {
  if (fileEditor instanceof TextEditor) {
    TextEditor textEditor = (TextEditor)fileEditor;
    Editor editor = textEditor.getEditor();
    if (tryToFindNextUsageViaEditorSearchComponent(editor, direction)) {
      return true;
    }

    RangeHighlighter[] highlighters = ((HighlightManagerImpl)HighlightManager.getInstance(myProject)).getHighlighters(editor);
    if (highlighters.length > 0) {
      return highlightNextHighlighter(highlighters, editor, editor.getCaretModel().getOffset(), direction == SearchResults.Direction.DOWN, false);
    }
  }

  if (direction == SearchResults.Direction.DOWN) {
    return myFindUsagesManager.findNextUsageInFile(fileEditor);
  }
  return myFindUsagesManager.findPreviousUsageInFile(fileEditor);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:FindManagerImpl.java

示例9: highlightTemplateVariables

import com.intellij.codeInsight.highlighting.HighlightManager; //导入依赖的package包/类
private void highlightTemplateVariables(Template template, Editor topLevelEditor) {
  //add highlights
  if (myHighlighters != null) { // can be null if finish is called during testing
    Map<TextRange, TextAttributes> rangesToHighlight = new HashMap<TextRange, TextAttributes>();
    final TemplateState templateState = TemplateManagerImpl.getTemplateState(topLevelEditor);
    if (templateState != null) {
      EditorColorsManager colorsManager = EditorColorsManager.getInstance();
      for (int i = 0; i < templateState.getSegmentsCount(); i++) {
        final TextRange segmentOffset = templateState.getSegmentRange(i);
        final String name = template.getSegmentName(i);
        TextAttributes attributes = null;
        if (name.equals(PRIMARY_VARIABLE_NAME)) {
          attributes = colorsManager.getGlobalScheme().getAttributes(EditorColors.WRITE_SEARCH_RESULT_ATTRIBUTES);
        }
        else if (name.equals(OTHER_VARIABLE_NAME)) {
          attributes = colorsManager.getGlobalScheme().getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES);
        }
        if (attributes == null) continue;
        rangesToHighlight.put(segmentOffset, attributes);
      }
    }
    addHighlights(rangesToHighlight, topLevelEditor, myHighlighters, HighlightManager.getInstance(myProject));
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:InplaceRefactoring.java

示例10: finish

import com.intellij.codeInsight.highlighting.HighlightManager; //导入依赖的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

示例11: 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);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:BreadcrumbsXmlWrapper.java

示例12: highlightElement

import com.intellij.codeInsight.highlighting.HighlightManager; //导入依赖的package包/类
private static void highlightElement(@NotNull PsiElement element) {
  final Project project = element.getProject();
  final FileEditorManager editorManager =
    FileEditorManager.getInstance(project);
  final HighlightManager highlightManager =
    HighlightManager.getInstance(project);
  final EditorColorsManager editorColorsManager =
    EditorColorsManager.getInstance();
  final Editor editor = editorManager.getSelectedTextEditor();
  final EditorColorsScheme globalScheme =
    editorColorsManager.getGlobalScheme();
  final TextAttributes textattributes =
    globalScheme.getAttributes(
      EditorColors.SEARCH_RESULT_ATTRIBUTES);
  final PsiElement[] elements = new PsiElement[]{element};
  highlightManager.addOccurrenceHighlights(editor, elements,
                                           textattributes, true, null);

  StatusBar.Info.set(IntentionPowerPackBundle.message(
    "status.bar.escape.highlighting.message"), project);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:MoveDeclarationIntention.java

示例13: showSideEffectsWarning

import com.intellij.codeInsight.highlighting.HighlightManager; //导入依赖的package包/类
public static int showSideEffectsWarning(List<PsiElement> sideEffects,
                                         PsiVariable variable,
                                         Editor editor,
                                         boolean canCopeWithSideEffects,
                                         @NonNls String beforeText,
                                         @NonNls String afterText) {
  if (sideEffects.isEmpty()) return RemoveUnusedVariableUtil.DELETE_ALL;
  if (ApplicationManager.getApplication().isUnitTestMode()) {
    return canCopeWithSideEffects
           ? RemoveUnusedVariableUtil.MAKE_STATEMENT
           : RemoveUnusedVariableUtil.DELETE_ALL;
  }
  Project project = editor.getProject();
  HighlightManager highlightManager = HighlightManager.getInstance(project);
  PsiElement[] elements = PsiUtilCore.toPsiElementArray(sideEffects);
  EditorColorsManager manager = EditorColorsManager.getInstance();
  TextAttributes attributes = manager.getGlobalScheme().getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES);
  highlightManager.addOccurrenceHighlights(editor, elements, attributes, true, null);

  SideEffectWarningDialog dialog = new SideEffectWarningDialog(project, false, variable, beforeText, afterText, canCopeWithSideEffects);
  dialog.show();
  return dialog.getExitCode();
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:24,代码来源:RemoveUnusedVariableFix.java

示例14: highlightElement

import com.intellij.codeInsight.highlighting.HighlightManager; //导入依赖的package包/类
public static void highlightElement(Editor editor, @NotNull com.intellij.openapi.project.Project project, @NotNull PsiElement[] elements)
{
    final HighlightManager highlightManager =
            HighlightManager.getInstance(project);
    final EditorColorsManager editorColorsManager =
            EditorColorsManager.getInstance();
    final EditorColorsScheme globalScheme =
            editorColorsManager.getGlobalScheme();
    final TextAttributes textattributes =
            globalScheme.getAttributes(
                    EditorColors.TEXT_SEARCH_RESULT_ATTRIBUTES);

    highlightManager.addOccurrenceHighlights(
            editor, elements, textattributes, true, null);
    final WindowManager windowManager = WindowManager.getInstance();
    final StatusBar statusBar = windowManager.getStatusBar(project);
    statusBar.setInfo("Press Esc to remove highlighting");
}
 
开发者ID:cefolger,项目名称:needsmoredojo,代码行数:19,代码来源:HighlightingUtil.java

示例15: updateCursorHighlighting

import com.intellij.codeInsight.highlighting.HighlightManager; //导入依赖的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) {
    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:consulo,项目名称:consulo,代码行数:27,代码来源:LivePreview.java


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