本文整理汇总了Java中com.intellij.codeInsight.highlighting.HighlightManager.removeSegmentHighlighter方法的典型用法代码示例。如果您正苦于以下问题:Java HighlightManager.removeSegmentHighlighter方法的具体用法?Java HighlightManager.removeSegmentHighlighter怎么用?Java HighlightManager.removeSegmentHighlighter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.codeInsight.highlighting.HighlightManager
的用法示例。
在下文中一共展示了HighlightManager.removeSegmentHighlighter方法的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);
}
}
}
示例2: 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();
}
}
}
示例3: 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);
}
}
示例4: 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();
}
}
}
示例5: clearHighlights
import com.intellij.codeInsight.highlighting.HighlightManager; //导入方法依赖的package包/类
private static void clearHighlights(Editor editor, HighlightManager highlightManager,
List<TextRange> toRemoves) {
if (editor instanceof EditorWindow) {
editor = ((EditorWindow) editor).getDelegate();
}
RangeHighlighter[] highlighters =
((HighlightManagerImpl) highlightManager).getHighlighters(editor);
Arrays.sort(highlighters, (o1, o2) -> o1.getStartOffset() - o2.getStartOffset());
Collections.sort(toRemoves, (o1, o2) -> o1.getStartOffset() - o2.getStartOffset());
int i = 0;
int j = 0;
while (i < highlighters.length && j < toRemoves.size()) {
RangeHighlighter highlighter = highlighters[i];
final TextAttributes ta = highlighter.getTextAttributes();
final TextRange textRange = TextRange.create(highlighter);
final TextRange toRemove = toRemoves.get(j);
if (ta != null && ta instanceof NamedTextAttr // wrap
&& highlighter.getLayer() == HighlighterLayer.SELECTION - 1 // wrap
&& toRemove.equals(textRange)) {
highlightManager.removeSegmentHighlighter(editor, highlighter);
i++;
} else if (toRemove.getStartOffset() > textRange.getEndOffset()) {
i++;
} else if (toRemove.getEndOffset() < textRange.getStartOffset()) {
j++;
} else {
i++;
j++;
}
}
}
示例6: finish
import com.intellij.codeInsight.highlighting.HighlightManager; //导入方法依赖的package包/类
private void finish() {
ourRenamersStack.pop();
if (this.myHighlighters != null) {
Project project = this.myEditor.getProject();
if (project != null && !project.isDisposed()) {
HighlightManager highlightManager = HighlightManager.getInstance(project);
Iterator var3 = this.myHighlighters.iterator();
while (var3.hasNext()) {
RangeHighlighter highlighter = (RangeHighlighter) var3.next();
highlightManager.removeSegmentHighlighter(this.myEditor, highlighter);
}
}
}
}
示例7: finish
import com.intellij.codeInsight.highlighting.HighlightManager; //导入方法依赖的package包/类
private void finish() {
ourRenamersStack.pop();
if (myHighlighters != null) {
final HighlightManager highlightManager = HighlightManager.getInstance(myEditor.getProject());
for (final RangeHighlighter highlighter : myHighlighters) {
highlightManager.removeSegmentHighlighter(myEditor, highlighter);
}
}
}
示例8: 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;
}
示例9: clearHighlighters
import com.intellij.codeInsight.highlighting.HighlightManager; //导入方法依赖的package包/类
/**
* Clear all highlighters in an editor that are set up by this class
*
* @param editor the editor
*/
public static void clearHighlighters(final Editor editor) {
final List<RangeHighlighter> hl = editor.getUserData(HIGHLIGHTERS_KEY);
if (hl != null) {
if (purgeInvalidHighlighters(editor, hl)) {
final HighlightManager mgr = HighlightManager.getInstance(editor.getProject());
for (Iterator<RangeHighlighter> iterator = hl.iterator(); iterator.hasNext();) {
RangeHighlighter highlighter = iterator.next();
mgr.removeSegmentHighlighter(editor, highlighter);
iterator.remove();
}
}
}
}
示例10: 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);
}
}
示例11: detach
import com.intellij.codeInsight.highlighting.HighlightManager; //导入方法依赖的package包/类
public void detach() {
myEditor.getDocument().removeDocumentListener(this);
HighlightManager highlightManager = HighlightManager.getInstance(myProject);
for (RangeHighlighter highlighter : myHighlighters) {
highlightManager.removeSegmentHighlighter(myEditor, highlighter);
}
myHighlighters.clear();
myBalloon.hide();
myDetector = null;
FinishMarkAction.finish(myProject, myEditor, myMarkAction);
myEditor.putUserData(INPLACE_CHANGE_SIGNATURE, null);
}
示例12: processDuplicates
import com.intellij.codeInsight.highlighting.HighlightManager; //导入方法依赖的package包/类
public static void processDuplicates(@NotNull MatchProvider provider, @NotNull Project project, @NotNull Editor editor)
{
Boolean hasDuplicates = provider.hasDuplicates();
if(hasDuplicates == null || hasDuplicates.booleanValue())
{
List<Match> duplicates = provider.getDuplicates();
ArrayList<RangeHighlighter> highlighters = null;
if(duplicates.size() == 1)
{
highlighters = previewMatch(project, duplicates.get(0), editor);
}
final int answer = ApplicationManager.getApplication().isUnitTestMode() || hasDuplicates == null ? Messages.YES : Messages.showYesNoDialog(project,
RefactoringBundle.message("0.has.detected.1.code.fragments.in.this.file.that.can.be.replaced.with.a.call.to.extracted.method",
ApplicationNamesInfo.getInstance().getProductName(), duplicates.size()), "Process Duplicates", Messages.getQuestionIcon());
if(answer == Messages.YES)
{
PsiDocumentManager.getInstance(project).commitAllDocuments();
invoke(project, editor, provider, hasDuplicates != null);
}
else if(highlighters != null)
{
final HighlightManager highlightManager = HighlightManager.getInstance(project);
for(RangeHighlighter highlighter : highlighters)
{
highlightManager.removeSegmentHighlighter(editor, highlighter);
}
}
}
}
示例13: convertExpressionToField
import com.intellij.codeInsight.highlighting.HighlightManager; //导入方法依赖的package包/类
private boolean convertExpressionToField(PsiExpression selectedExpr,
@Nullable Editor editor,
PsiFile file,
final Project project,
PsiType tempType) {
if (myParentClass == null) {
if (FileTypeUtils.isInServerPageFile(file)) {
CommonRefactoringUtil.showErrorHint(project, editor, RefactoringBundle.message("error.not.supported.for.jsp", getRefactoringName()),
getRefactoringName(), getHelpID());
return true;
}
else {
LOG.assertTrue(false);
return true;
}
}
if (!validClass(myParentClass, editor)) {
return true;
}
if (!CommonRefactoringUtil.checkReadOnlyStatus(project, file)) return true;
final OccurrenceManager occurrenceManager = createOccurrenceManager(selectedExpr, myParentClass);
final PsiExpression[] occurrences = occurrenceManager.getOccurrences();
final PsiElement anchorStatementIfAll = occurrenceManager.getAnchorStatementForAll();
List<RangeHighlighter> highlighters = null;
if (editor != null) {
highlighters = RefactoringUtil.highlightAllOccurrences(project, occurrences, editor);
}
PsiElement tempAnchorElement = RefactoringUtil.getParentExpressionAnchorElement(selectedExpr);
if (!Comparing.strEqual(IntroduceConstantHandler.REFACTORING_NAME, getRefactoringName()) &&
IntroduceVariableBase.checkAnchorBeforeThisOrSuper(project, editor, tempAnchorElement, getRefactoringName(), getHelpID()))
return true;
final Settings settings =
showRefactoringDialog(project, editor, myParentClass, selectedExpr, tempType,
occurrences, tempAnchorElement, anchorStatementIfAll);
if (settings == null) return true;
if (settings.getForcedType() != null) {
tempType = settings.getForcedType();
}
final PsiType type = tempType;
if (editor != null) {
HighlightManager highlightManager = HighlightManager.getInstance(project);
for (RangeHighlighter highlighter : highlighters) {
highlightManager.removeSegmentHighlighter(editor, highlighter);
}
}
final Runnable runnable =
new ConvertToFieldRunnable(settings.getSelectedExpr(), settings, type, settings.getOccurrences(), occurrenceManager,
anchorStatementIfAll, tempAnchorElement, editor,
myParentClass);
new WriteCommandAction(project, getRefactoringName()){
@Override
protected void run(@NotNull Result result) throws Throwable {
runnable.run();
}
}.execute();
return false;
}
示例14: 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;
}
示例15: replaceDuplicates
import com.intellij.codeInsight.highlighting.HighlightManager; //导入方法依赖的package包/类
private static void replaceDuplicates(PsiElement callElement,
Editor editor,
Consumer<Pair<SimpleMatch, PsiElement>> replacer,
List<SimpleMatch> duplicates) {
if (duplicates.size() > 0) {
final String message = RefactoringBundle
.message("0.has.detected.1.code.fragments.in.this.file.that.can.be.replaced.with.a.call.to.extracted.method",
ApplicationNamesInfo.getInstance().getProductName(), duplicates.size());
final boolean isUnittest = ApplicationManager.getApplication().isUnitTestMode();
final Project project = callElement.getProject();
final int exitCode = !isUnittest ? Messages.showYesNoDialog(project, message,
RefactoringBundle.message("refactoring.extract.method.dialog.title"),
Messages.getInformationIcon()) :
Messages.YES;
if (exitCode == Messages.YES) {
boolean replaceAll = false;
final Map<SimpleMatch, RangeHighlighter> highlighterMap = new HashMap<SimpleMatch, RangeHighlighter>();
for (SimpleMatch match : duplicates) {
if (!match.getStartElement().isValid() || !match.getEndElement().isValid()) continue;
final Pair<SimpleMatch, PsiElement> replacement = Pair.create(match, callElement);
if (!replaceAll) {
highlightInEditor(project, match, editor, highlighterMap);
int promptResult = FindManager.PromptResult.ALL;
//noinspection ConstantConditions
if (!isUnittest) {
ReplacePromptDialog promptDialog =
new ReplacePromptDialog(false, RefactoringBundle.message("replace.fragment"), project);
promptDialog.show();
promptResult = promptDialog.getExitCode();
}
if (promptResult == FindManager.PromptResult.SKIP) {
final HighlightManager highlightManager = HighlightManager.getInstance(project);
final RangeHighlighter highlighter = highlighterMap.get(match);
if (highlighter != null) highlightManager.removeSegmentHighlighter(editor, highlighter);
continue;
}
if (promptResult == FindManager.PromptResult.CANCEL) break;
if (promptResult == FindManager.PromptResult.OK) {
replaceDuplicate(project, replacer, replacement);
}
else if (promptResult == FindManager.PromptResult.ALL) {
replaceDuplicate(project, replacer, replacement);
replaceAll = true;
}
}
else {
replaceDuplicate(project, replacer, replacement);
}
}
}
}
}