use of com.intellij.openapi.editor.highlighter.EditorHighlighter in project intellij-community by JetBrains.
the class EditorActionUtil method isLexemeBoundary.
/**
* Finds out whether there's a boundary between two lexemes of different type at given offset.
*/
public static boolean isLexemeBoundary(@NotNull Editor editor, int offset) {
if (!(editor instanceof EditorEx) || offset <= 0 || offset >= editor.getDocument().getTextLength() || DocumentUtil.isInsideSurrogatePair(editor.getDocument(), offset)) {
return false;
}
if (CharArrayUtil.isEmptyOrSpaces(editor.getDocument().getImmutableCharSequence(), offset - 1, offset + 1))
return false;
EditorHighlighter highlighter = ((EditorEx) editor).getHighlighter();
HighlighterIterator it = highlighter.createIterator(offset);
if (it.getStart() != offset) {
return false;
}
IElementType rightToken = it.getTokenType();
it.retreat();
IElementType leftToken = it.getTokenType();
return !Comparing.equal(leftToken, rightToken);
}
use of com.intellij.openapi.editor.highlighter.EditorHighlighter in project intellij-community by JetBrains.
the class MergePanel2 method setupHighlighterSettings.
private void setupHighlighterSettings(Editor left, Editor base, Editor right) {
Editor[] editors = new Editor[] { left, base, right };
DiffContent[] contents = myData.getContents();
FileType[] types = DiffUtil.chooseContentTypes(contents);
VirtualFile fallbackFile = contents[1].getFile();
FileType fallbackType = contents[1].getContentType();
for (int i = 0; i < 3; i++) {
Editor editor = editors[i];
DiffContent content = contents[i];
EditorHighlighter highlighter = createHighlighter(types[i], content.getFile(), fallbackFile, fallbackType, myData.getProject()).createHighlighter();
if (highlighter != null) {
((EditorEx) editor).setHighlighter(highlighter);
}
}
}
use of com.intellij.openapi.editor.highlighter.EditorHighlighter in project intellij-community by JetBrains.
the class UnifiedDiffViewer method buildHighlighter.
@Nullable
private EditorHighlighter buildHighlighter(@Nullable Project project, @NotNull DocumentContent content1, @NotNull DocumentContent content2, @NotNull CharSequence text1, @NotNull CharSequence text2, @NotNull List<HighlightRange> ranges, int textLength) {
EditorHighlighter highlighter1 = DiffUtil.initEditorHighlighter(project, content1, text1);
EditorHighlighter highlighter2 = DiffUtil.initEditorHighlighter(project, content2, text2);
if (highlighter1 == null && highlighter2 == null)
return null;
if (highlighter1 == null)
highlighter1 = DiffUtil.initEmptyEditorHighlighter(text1);
if (highlighter2 == null)
highlighter2 = DiffUtil.initEmptyEditorHighlighter(text2);
return new UnifiedEditorHighlighter(myDocument, highlighter1, highlighter2, ranges, textLength);
}
use of com.intellij.openapi.editor.highlighter.EditorHighlighter in project intellij-community by JetBrains.
the class DiffUtil method initEditorHighlighter.
@Nullable
public static EditorHighlighter initEditorHighlighter(@Nullable Project project, @NotNull DocumentContent content, @NotNull CharSequence text) {
EditorHighlighter highlighter = createEditorHighlighter(project, content);
if (highlighter == null)
return null;
highlighter.setText(text);
return highlighter;
}
use of com.intellij.openapi.editor.highlighter.EditorHighlighter in project intellij-community by JetBrains.
the class PrintManager method doInitTextPainter.
private static TextPainter doInitTextPainter(@NotNull final DocumentEx doc, Project project) {
EditorHighlighter highlighter = HighlighterFactory.createHighlighter(project, "unknown");
highlighter.setText(doc.getCharsSequence());
return new TextPainter(doc, highlighter, "unknown", "unknown", project, FileTypes.PLAIN_TEXT, null);
}
Aggregations