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


Java HighlightManager.addOccurrenceHighlights方法代码示例

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


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

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

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

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

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

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

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

示例7: 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:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:IntroduceVariableBase.java

示例8: actionPerformed

import com.intellij.codeInsight.highlighting.HighlightManager; //导入方法依赖的package包/类
@Override
public void actionPerformed(AnActionEvent e) {
  DataContext dataContext = e.getDataContext();
  Editor editor = CommonDataKeys.EDITOR.getData(dataContext);
  Project project = CommonDataKeys.PROJECT.getData(dataContext);
  List<PsiElement> elements = getElementsToCopy(editor, dataContext);

  if (!doCopy(elements, project, editor) && editor != null && project != null) {
    Document document = editor.getDocument();
    PsiFile file = PsiDocumentManager.getInstance(project).getCachedPsiFile(document);
    if (file != null) {
      String toCopy = getFileFqn(file) + ":" + (editor.getCaretModel().getLogicalPosition().line + 1);
      CopyPasteManager.getInstance().setContents(new StringSelection(toCopy));
      setStatusBarText(project, toCopy + " has been copied");
    }
    return;
  }

  HighlightManager highlightManager = HighlightManager.getInstance(project);
  EditorColorsManager manager = EditorColorsManager.getInstance();
  TextAttributes attributes = manager.getGlobalScheme().getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES);
  if (elements.size() == 1 && editor != null && project != null) {
    PsiElement element = elements.get(0);
    PsiElement nameIdentifier = IdentifierUtil.getNameIdentifier(element);
    if (nameIdentifier != null) {
      highlightManager.addOccurrenceHighlights(editor, new PsiElement[]{nameIdentifier}, attributes, true, null);
    } else {
      PsiReference reference = TargetElementUtil.findReference(editor, editor.getCaretModel().getOffset());
      if (reference != null) {
        highlightManager.addOccurrenceHighlights(editor, new PsiReference[]{reference}, attributes, true, null);
      } else if (element != PsiDocumentManager.getInstance(project).getCachedPsiFile(editor.getDocument())) {
        highlightManager.addOccurrenceHighlights(editor, new PsiElement[]{element}, attributes, true, null);
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:37,代码来源:CopyReferenceAction.java

示例9: highlightOccurrences

import com.intellij.codeInsight.highlighting.HighlightManager; //导入方法依赖的package包/类
public static void highlightOccurrences(Project project, @Nullable Editor editor, PsiElement[] elements) {
  if (editor == null) return;
  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 (elements.length > 0) {
    highlightManager.addOccurrenceHighlights(editor, elements, attributes, false, highlighters);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:GroovyRefactoringUtil.java

示例10: showDialog

import com.intellij.codeInsight.highlighting.HighlightManager; //导入方法依赖的package包/类
@Nullable
private Settings showDialog(@NotNull GrIntroduceContext context) {

  // Add occurrences highlighting
  ArrayList<RangeHighlighter> highlighters = new ArrayList<RangeHighlighter>();
  HighlightManager highlightManager = null;
  if (context.getEditor() != null) {
    highlightManager = HighlightManager.getInstance(context.getProject());
    EditorColorsManager colorsManager = EditorColorsManager.getInstance();
    TextAttributes attributes = colorsManager.getGlobalScheme().getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES);
    if (context.getOccurrences().length > 1) {
      highlightManager.addOccurrenceHighlights(context.getEditor(), context.getOccurrences(), attributes, true, highlighters);
    }
  }

  GrIntroduceDialog<Settings> dialog = getDialog(context);

  dialog.show();
  if (dialog.isOK()) {
    if (context.getEditor() != null) {
      for (RangeHighlighter highlighter : highlighters) {
        highlightManager.removeSegmentHighlighter(context.getEditor(), highlighter);
      }
    }
    return dialog.getSettings();
  }
  else {
    if (context.getOccurrences().length > 1) {
      WindowManager.getInstance().getStatusBar(context.getProject())
        .setInfo(GroovyRefactoringBundle.message("press.escape.to.remove.the.highlighting"));
    }
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:35,代码来源:GrIntroduceHandlerBase.java

示例11: actionPerformed

import com.intellij.codeInsight.highlighting.HighlightManager; //导入方法依赖的package包/类
@Override
public void actionPerformed(AnActionEvent e) {
  DataContext dataContext = e.getDataContext();
  Editor editor = PlatformDataKeys.EDITOR.getData(dataContext);
  Project project = PlatformDataKeys.PROJECT.getData(dataContext);
  PsiElement element = getElementToCopy(editor, dataContext);

  if (!doCopy(element, project, editor) && editor != null) {
    Document document = editor.getDocument();
    PsiFile file = PsiDocumentManager.getInstance(project).getCachedPsiFile(document);
    if (file != null) {
      String toCopy = getFileFqn(file) + ":" + (editor.getCaretModel().getLogicalPosition().line + 1);
      CopyPasteManager.getInstance().setContents(new StringSelection(toCopy));
      setStatusBarText(project, toCopy + " has been copied");
    }
    return;
  }

  HighlightManager highlightManager = HighlightManager.getInstance(project);
  EditorColorsManager manager = EditorColorsManager.getInstance();
  TextAttributes attributes = manager.getGlobalScheme().getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES);
  if (element != null && editor != null) {
    PsiElement nameIdentifier = IdentifierUtil.getNameIdentifier(element);
    if (nameIdentifier != null) {
      highlightManager.addOccurrenceHighlights(editor, new PsiElement[]{nameIdentifier}, attributes, true, null);
    } else {
      PsiReference reference = TargetElementUtilBase.findReference(editor, editor.getCaretModel().getOffset());
      if (reference != null) {
        highlightManager.addOccurrenceHighlights(editor, new PsiReference[]{reference}, attributes, true, null);
      } else if (element != PsiDocumentManager.getInstance(project).getCachedPsiFile(editor.getDocument())) {
        highlightManager.addOccurrenceHighlights(editor, new PsiElement[]{element}, attributes, true, null);
      }
    }
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:36,代码来源:CopyReferenceAction.java

示例12: actionPerformed

import com.intellij.codeInsight.highlighting.HighlightManager; //导入方法依赖的package包/类
@RequiredDispatchThread
@Override
public void actionPerformed(@Nonnull AnActionEvent e) {
  DataContext dataContext = e.getDataContext();
  Editor editor = dataContext.getData(CommonDataKeys.EDITOR);
  Project project = dataContext.getData(CommonDataKeys.PROJECT);
  List<PsiElement> elements = getElementsToCopy(editor, dataContext);

  if (!doCopy(elements, project, editor) && editor != null && project != null) {
    Document document = editor.getDocument();
    PsiFile file = PsiDocumentManager.getInstance(project).getCachedPsiFile(document);
    if (file != null) {
      String toCopy = getFileFqn(file) + ":" + (editor.getCaretModel().getLogicalPosition().line + 1);
      CopyPasteManager.getInstance().setContents(new StringSelection(toCopy));
      setStatusBarText(project, toCopy + " has been copied");
    }
    return;
  }

  HighlightManager highlightManager = HighlightManager.getInstance(project);
  EditorColorsManager manager = EditorColorsManager.getInstance();
  TextAttributes attributes = manager.getGlobalScheme().getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES);
  if (elements.size() == 1 && editor != null && project != null) {
    PsiElement element = elements.get(0);
    PsiElement nameIdentifier = IdentifierUtil.getNameIdentifier(element);
    if (nameIdentifier != null) {
      highlightManager.addOccurrenceHighlights(editor, new PsiElement[]{nameIdentifier}, attributes, true, null);
    } else {
      PsiReference reference = TargetElementUtil.findReference(editor, editor.getCaretModel().getOffset());
      if (reference != null) {
        highlightManager.addOccurrenceHighlights(editor, new PsiReference[]{reference}, attributes, true, null);
      } else if (element != PsiDocumentManager.getInstance(project).getCachedPsiFile(editor.getDocument())) {
        highlightManager.addOccurrenceHighlights(editor, new PsiElement[]{element}, attributes, true, null);
      }
    }
  }
}
 
开发者ID:consulo,项目名称:consulo,代码行数:38,代码来源:CopyReferenceAction.java

示例13: highlightOccurences

import com.intellij.codeInsight.highlighting.HighlightManager; //导入方法依赖的package包/类
private static ArrayList<RangeHighlighter> highlightOccurences(Project project, Editor editor, JSExpression[] occurences)
{
	HighlightManager highlightManager = HighlightManager.getInstance(project);
	EditorColorsManager colorsManager = EditorColorsManager.getInstance();
	TextAttributes attributes = colorsManager.getGlobalScheme().getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES);
	ArrayList<RangeHighlighter> result = new ArrayList<RangeHighlighter>();
	highlightManager.addOccurrenceHighlights(editor, occurences, attributes, true, result);
	WindowManager.getInstance().getStatusBar(project).setInfo(RefactoringBundle.message("press.escape.to.remove.the.highlighting"));
	return result;
}
 
开发者ID:consulo,项目名称:consulo-javascript,代码行数:11,代码来源:JSBaseIntroduceHandler.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:consulo,项目名称:consulo-java,代码行数:15,代码来源:ExtractMethodProcessor.java

示例15: getSettings

import com.intellij.codeInsight.highlighting.HighlightManager; //导入方法依赖的package包/类
@Override
public IntroduceVariableSettings getSettings(Project project, Editor editor,
                                             PsiExpression expr, PsiExpression[] occurrences,
                                             TypeSelectorManagerImpl typeSelectorManager,
                                             boolean declareFinalIfAll,
                                             boolean anyAssignmentLHS,
                                             final InputValidator validator,
                                             PsiElement anchor, OccurrencesChooser.ReplaceChoice replaceChoice) {
  if (replaceChoice == null && ApplicationManager.getApplication().isUnitTestMode()) {
    replaceChoice = OccurrencesChooser.ReplaceChoice.NO;
  }
  if (replaceChoice != null) {
    return super.getSettings(project, editor, expr, occurrences, typeSelectorManager, declareFinalIfAll, anyAssignmentLHS, validator,
                             anchor, replaceChoice);
  }
  ArrayList<RangeHighlighter> highlighters = new ArrayList<RangeHighlighter>();
  HighlightManager highlightManager = null;
  if (editor != null) {
    highlightManager = HighlightManager.getInstance(project);
    EditorColorsManager colorsManager = EditorColorsManager.getInstance();
    TextAttributes attributes = colorsManager.getGlobalScheme().getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES);
    if (occurrences.length > 1) {
      highlightManager.addOccurrenceHighlights(editor, occurrences, attributes, true, highlighters);
    }
  }

  IntroduceVariableDialog dialog = new IntroduceVariableDialog(
    project, expr, occurrences.length, anyAssignmentLHS, declareFinalIfAll,
    typeSelectorManager,
    validator);
  if (!dialog.showAndGet()) {
    if (occurrences.length > 1) {
      WindowManager.getInstance().getStatusBar(project).setInfo(RefactoringBundle.message("press.escape.to.remove.the.highlighting"));
    }
  }
  else {
    if (editor != null) {
      for (RangeHighlighter highlighter : highlighters) {
        highlightManager.removeSegmentHighlighter(editor, highlighter);
      }
    }
  }

  return dialog;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:46,代码来源:IntroduceVariableHandler.java


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