use of com.intellij.openapi.editor.markup.RangeHighlighter in project intellij-community by JetBrains.
the class DuplicatesImpl method replaceMatch.
private static boolean replaceMatch(final Project project, final MatchProvider provider, final Match match, @NotNull final Editor editor, final int idx, final int size, Ref<Boolean> showAll, final String confirmDuplicatePrompt, boolean skipPromptWhenOne) {
final ArrayList<RangeHighlighter> highlighters = previewMatch(project, match, editor);
try {
if (!ApplicationManager.getApplication().isUnitTestMode()) {
if ((!skipPromptWhenOne || size > 1) && (showAll.get() == null || !showAll.get())) {
final String prompt = provider.getConfirmDuplicatePrompt(match);
final ReplacePromptDialog promptDialog = new ReplacePromptDialog(false, provider.getReplaceDuplicatesTitle(idx, size), project) {
@Override
protected String getMessage() {
final String message = super.getMessage();
return prompt != null ? message + " " + prompt : message;
}
};
promptDialog.show();
final boolean allChosen = promptDialog.getExitCode() == FindManager.PromptResult.ALL;
showAll.set(allChosen);
if (allChosen && confirmDuplicatePrompt != null && prompt == null) {
if (Messages.showOkCancelDialog(project, "In order to replace all occurrences method signature will be changed. Proceed?", CommonBundle.getWarningTitle(), Messages.getWarningIcon()) != Messages.OK)
return true;
}
if (promptDialog.getExitCode() == FindManager.PromptResult.SKIP)
return false;
if (promptDialog.getExitCode() == FindManager.PromptResult.CANCEL)
return true;
}
}
} finally {
HighlightManager.getInstance(project).removeSegmentHighlighter(editor, highlighters.get(0));
}
// call change signature when needed
provider.prepareSignature(match);
new WriteCommandAction(project, MethodDuplicatesHandler.REFACTORING_NAME, MethodDuplicatesHandler.REFACTORING_NAME) {
@Override
protected void run(@NotNull Result result) throws Throwable {
try {
provider.processMatch(match);
} catch (IncorrectOperationException e) {
LOG.error(e);
}
}
}.execute();
return false;
}
use of com.intellij.openapi.editor.markup.RangeHighlighter in project intellij-community by JetBrains.
the class AnnotateStackTraceAction method getHyperlinkVirtualFile.
@Nullable
@CalledWithReadLock
private static VirtualFile getHyperlinkVirtualFile(@NotNull List<RangeHighlighter> links) {
RangeHighlighter key = ContainerUtil.getLastItem(links);
if (key == null)
return null;
HyperlinkInfo info = EditorHyperlinkSupport.getHyperlinkInfo(key);
if (!(info instanceof FileHyperlinkInfo))
return null;
OpenFileDescriptor descriptor = ((FileHyperlinkInfo) info).getDescriptor();
return descriptor != null ? descriptor.getFile() : null;
}
use of com.intellij.openapi.editor.markup.RangeHighlighter in project ideavim by JetBrains.
the class SearchGroup method removeSearchHighlight.
private static void removeSearchHighlight(@NotNull Editor editor) {
Collection<RangeHighlighter> ehl = EditorData.getLastHighlights(editor);
if (ehl == null) {
return;
}
for (RangeHighlighter rh : ehl) {
editor.getMarkupModel().removeHighlighter(rh);
}
ehl.clear();
EditorData.setLastHighlights(editor, null);
EditorData.setLastSearch(editor, null);
}
use of com.intellij.openapi.editor.markup.RangeHighlighter in project intellij-community by JetBrains.
the class VcsPreviewPanel method addHighlighter.
private void addHighlighter(@NotNull Range range, @NotNull ColorKey colorKey) {
TextRange textRange = DiffUtil.getLinesRange(myEditor.getDocument(), range.getLine1(), range.getLine2());
RangeHighlighter highlighter = LineStatusMarkerRenderer.createRangeHighlighter(range, textRange, myEditor.getMarkupModel());
highlighter.setLineMarkerRenderer(new LineStatusMarkerRenderer(range) {
@Override
public boolean canDoAction(MouseEvent e) {
return isInsideMarkerArea(e);
}
@Override
public void doAction(Editor editor, MouseEvent e) {
myDispatcher.getMulticaster().selectionInPreviewChanged(colorKey.getExternalName());
}
});
}
use of com.intellij.openapi.editor.markup.RangeHighlighter in project intellij-community by JetBrains.
the class EditorHyperlinkSupport method createHyperlink.
@NotNull
private RangeHighlighter createHyperlink(final int highlightStartOffset, final int highlightEndOffset, @Nullable final TextAttributes highlightAttributes, @NotNull final HyperlinkInfo hyperlinkInfo, @Nullable TextAttributes followedHyperlinkAttributes, int layer) {
TextAttributes textAttributes = highlightAttributes != null ? highlightAttributes : getHyperlinkAttributes();
final RangeHighlighter highlighter = myEditor.getMarkupModel().addRangeHighlighter(highlightStartOffset, highlightEndOffset, layer, textAttributes, HighlighterTargetArea.EXACT_RANGE);
associateHyperlink(highlighter, hyperlinkInfo, followedHyperlinkAttributes);
return highlighter;
}
Aggregations