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


Java HighlightManager.getInstance方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例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: 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

示例8: 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

示例9: 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

示例10: 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

示例11: 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:consulo,项目名称:consulo,代码行数:22,代码来源:InplaceRefactoring.java

示例12: highlightReplacedOccurences

import com.intellij.codeInsight.highlighting.HighlightManager; //导入方法依赖的package包/类
protected static void highlightReplacedOccurences(Project project, Editor editor, PsiElement[] replacedOccurences)
{
	if(editor == null)
	{
		return;
	}
	if(ApplicationManager.getApplication().isUnitTestMode())
	{
		return;
	}
	HighlightManager highlightManager = HighlightManager.getInstance(project);
	EditorColorsManager colorsManager = EditorColorsManager.getInstance();
	TextAttributes attributes = colorsManager.getGlobalScheme().getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES);
	highlightManager.addOccurrenceHighlights(editor, replacedOccurences, attributes, true, null);
	WindowManager.getInstance().getStatusBar(project).setInfo(RefactoringBundle.message("press.escape.to.remove.the.highlighting"));
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:17,代码来源:IntroduceVariableBase.java

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

示例14: showMultipleExitPointsMessage

import com.intellij.codeInsight.highlighting.HighlightManager; //导入方法依赖的package包/类
private void showMultipleExitPointsMessage() {
  if (myShowErrorDialogs) {
    HighlightManager highlightManager = HighlightManager.getInstance(myProject);
    PsiStatement[] exitStatementsArray = myExitStatements.toArray(new PsiStatement[myExitStatements.size()]);
    EditorColorsManager manager = EditorColorsManager.getInstance();
    TextAttributes attributes = manager.getGlobalScheme().getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES);
    highlightManager.addOccurrenceHighlights(myEditor, exitStatementsArray, attributes, true, null);
    String message = RefactoringBundle
      .getCannotRefactorMessage(RefactoringBundle.message("there.are.multiple.exit.points.in.the.selected.code.fragment"));
    CommonRefactoringUtil.showErrorHint(myProject, myEditor, message, myRefactoringName, myHelpId);
    WindowManager.getInstance().getStatusBar(myProject).setInfo(RefactoringBundle.message("press.escape.to.remove.the.highlighting"));
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:ExtractMethodProcessor.java

示例15: highlightPrepareError

import com.intellij.codeInsight.highlighting.HighlightManager; //导入方法依赖的package包/类
public static void highlightPrepareError(PrepareFailedException e, PsiFile file, Editor editor, final Project project) {
  if (e.getFile() == file) {
    final TextRange textRange = e.getTextRange();
    final HighlightManager highlightManager = HighlightManager.getInstance(project);
    EditorColorsManager colorsManager = EditorColorsManager.getInstance();
    TextAttributes attributes = colorsManager.getGlobalScheme().getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES);
    highlightManager.addRangeHighlight(editor, textRange.getStartOffset(), textRange.getEndOffset(), attributes, true, null);
    final LogicalPosition logicalPosition = editor.offsetToLogicalPosition(textRange.getStartOffset());
    editor.getScrollingModel().scrollTo(logicalPosition, ScrollType.MAKE_VISIBLE);
    WindowManager.getInstance().getStatusBar(project).setInfo(RefactoringBundle.message("press.escape.to.remove.the.highlighting"));
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:ExtractMethodHandler.java


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