use of com.intellij.openapi.editor.markup.RangeHighlighter in project intellij-community by JetBrains.
the class MavenDomTestCase method assertHighlighted.
protected void assertHighlighted(VirtualFile file, HighlightInfo... expected) throws IOException {
Editor editor = getEditor(file);
HighlightUsagesHandler.invoke(myProject, editor, getTestPsiFile(file));
RangeHighlighter[] highlighters = editor.getMarkupModel().getAllHighlighters();
List<HighlightInfo> actual = new ArrayList<>();
for (RangeHighlighter each : highlighters) {
if (!each.isValid())
continue;
int offset = each.getStartOffset();
PsiElement element = getTestPsiFile(file).findElementAt(offset);
element = PsiTreeUtil.getParentOfType(element, XmlTag.class);
String text = editor.getDocument().getText().substring(offset, each.getEndOffset());
actual.add(new HighlightInfo(element, text));
}
assertUnorderedElementsAreEqual(actual, expected);
}
use of com.intellij.openapi.editor.markup.RangeHighlighter in project intellij-community by JetBrains.
the class XmlTagInplaceRenamer method addHighlights.
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);
}
}
use of com.intellij.openapi.editor.markup.RangeHighlighter in project ideavim by JetBrains.
the class SearchGroup method searchAndReplace.
public boolean searchAndReplace(@NotNull Editor editor, @NotNull LineRange range, @NotNull String excmd, String exarg) {
// Explicitly exit visual mode here, so that visual mode marks don't change when we move the cursor to a match.
if (CommandState.getInstance(editor).getMode() == CommandState.Mode.VISUAL) {
VimPlugin.getMotion().exitVisual(editor);
}
CharPointer cmd = new CharPointer(new StringBuffer(exarg));
//sub_nsubs = 0;
//sub_nlines = 0;
int which_pat;
if (excmd.equals("~")) {
which_pat = RE_LAST;
/* use last used regexp */
} else {
which_pat = RE_SUBST;
/* use last substitute regexp */
}
CharPointer pat;
CharPointer sub;
char delimiter;
/* new pattern and substitution */
if (excmd.charAt(0) == 's' && !cmd.isNul() && !Character.isWhitespace(cmd.charAt()) && "0123456789cegriIp|\"".indexOf(cmd.charAt()) == -1) {
/* don't accept alphanumeric for separator */
if (CharacterClasses.isAlpha(cmd.charAt())) {
VimPlugin.showMessage(MessageHelper.message(Msg.E146));
return false;
}
/*
* undocumented vi feature:
* "\/sub/" and "\?sub?" use last used search pattern (almost like
* //sub/r). "\&sub&" use last substitute pattern (like //sub/).
*/
if (cmd.charAt() == '\\') {
cmd.inc();
if ("/?&".indexOf(cmd.charAt()) == -1) {
VimPlugin.showMessage(MessageHelper.message(Msg.e_backslash));
return false;
}
if (cmd.charAt() != '&') {
which_pat = RE_SEARCH;
/* use last '/' pattern */
}
pat = new CharPointer("");
/* empty search pattern */
delimiter = cmd.charAt();
/* remember delimiter character */
cmd.inc();
} else /* find the end of the regexp */
{
which_pat = RE_LAST;
/* use last used regexp */
delimiter = cmd.charAt();
/* remember delimiter character */
cmd.inc();
pat = cmd.ref(0);
/* remember start of search pat */
cmd = RegExp.skip_regexp(cmd, delimiter, true);
if (cmd.charAt() == delimiter) /* end delimiter found */
{
cmd.set('