本文整理汇总了Java中com.intellij.openapi.editor.highlighter.EditorHighlighter.setText方法的典型用法代码示例。如果您正苦于以下问题:Java EditorHighlighter.setText方法的具体用法?Java EditorHighlighter.setText怎么用?Java EditorHighlighter.setText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.openapi.editor.highlighter.EditorHighlighter
的用法示例。
在下文中一共展示了EditorHighlighter.setText方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testCpp
import com.intellij.openapi.editor.highlighter.EditorHighlighter; //导入方法依赖的package包/类
public void testCpp() throws Exception {
EditorHighlighter highlighter = HighlighterFactory.createHighlighter(getProject(), "A.cpp");
// 0123456789012345678 9 0123 45 6 7
highlighter.setText("#include try enum \"\\xff\\z\\\"xxx\"");
HighlighterIterator iterator = highlighter.createIterator(2);
assertEquals(CustomHighlighterTokenType.KEYWORD_1, iterator.getTokenType());
iterator = highlighter.createIterator(9);
assertEquals(CustomHighlighterTokenType.KEYWORD_2, iterator.getTokenType());
iterator = highlighter.createIterator(15);
assertEquals(CustomHighlighterTokenType.KEYWORD_1, iterator.getTokenType());
iterator = highlighter.createIterator(19);
assertEquals(StringEscapesTokenTypes.VALID_STRING_ESCAPE_TOKEN, iterator.getTokenType());
iterator = highlighter.createIterator(23);
assertEquals(StringEscapesTokenTypes.INVALID_CHARACTER_ESCAPE_TOKEN, iterator.getTokenType());
iterator = highlighter.createIterator(25);
assertEquals(StringEscapesTokenTypes.VALID_STRING_ESCAPE_TOKEN, iterator.getTokenType());
iterator = highlighter.createIterator(27);
assertEquals(CustomHighlighterTokenType.STRING, iterator.getTokenType());
}
示例2: testHaskel
import com.intellij.openapi.editor.highlighter.EditorHighlighter; //导入方法依赖的package包/类
public void testHaskel() throws Exception {
EditorHighlighter highlighter = HighlighterFactory.createHighlighter(getProject(), "A.hs");
// 0123456789012345678 9 0123 45 6 7
highlighter.setText("{-# #-} module");
HighlighterIterator iterator = highlighter.createIterator(2);
assertEquals(CustomHighlighterTokenType.MULTI_LINE_COMMENT, iterator.getTokenType());
iterator = highlighter.createIterator(12);
assertEquals(CustomHighlighterTokenType.KEYWORD_1, iterator.getTokenType());
}
示例3: initEditorHighlighter
import com.intellij.openapi.editor.highlighter.EditorHighlighter; //导入方法依赖的package包/类
@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;
}
示例4: doInitTextPainter
import com.intellij.openapi.editor.highlighter.EditorHighlighter; //导入方法依赖的package包/类
private static TextPainter doInitTextPainter(final PsiFile psiFile, final Editor editor) {
VirtualFile virtualFile = psiFile.getVirtualFile();
if (virtualFile == null) return null;
DocumentEx doc = (DocumentEx)PsiDocumentManager.getInstance(psiFile.getProject()).getDocument(psiFile);
if (doc == null) return null;
EditorHighlighter highlighter = HighlighterFactory.createHighlighter(psiFile.getProject(), virtualFile);
highlighter.setText(doc.getCharsSequence());
return new TextPainter(doc, highlighter, virtualFile.getPresentableUrl(), virtualFile.getPresentableName(),
psiFile, psiFile.getFileType(), editor);
}
示例5: printWithHighlighting
import com.intellij.openapi.editor.highlighter.EditorHighlighter; //导入方法依赖的package包/类
public static String printWithHighlighting(@NotNull LanguageConsoleView console, @NotNull Editor inputEditor, @NotNull TextRange textRange) {
String text;
EditorHighlighter highlighter;
if (inputEditor instanceof EditorWindow) {
PsiFile file = ((EditorWindow)inputEditor).getInjectedFile();
highlighter =
HighlighterFactory.createHighlighter(file.getVirtualFile(), EditorColorsManager.getInstance().getGlobalScheme(), console.getProject());
String fullText = InjectedLanguageUtil.getUnescapedText(file, null, null);
highlighter.setText(fullText);
text = textRange.substring(fullText);
}
else {
text = inputEditor.getDocument().getText(textRange);
highlighter = ((EditorEx)inputEditor).getHighlighter();
}
SyntaxHighlighter syntax =
highlighter instanceof LexerEditorHighlighter ? ((LexerEditorHighlighter)highlighter).getSyntaxHighlighter() : null;
((LanguageConsoleImpl)console).doAddPromptToHistory();
if (syntax != null) {
ConsoleViewUtil.printWithHighlighting(console, text, syntax);
}
else {
console.print(text, ConsoleViewContentType.USER_INPUT);
}
console.print("\n", ConsoleViewContentType.NORMAL_OUTPUT);
return text;
}
示例6: getHighlighter
import com.intellij.openapi.editor.highlighter.EditorHighlighter; //导入方法依赖的package包/类
@NotNull
@Override
public EditorHighlighter getHighlighter() {
EditorColorsScheme scheme = EditorColorsManager.getInstance().getGlobalScheme();
EditorHighlighter highlighter = HighlighterFactory.createHighlighter(myInjectedFile.getVirtualFile(), scheme, getProject());
highlighter.setText(getDocument().getText());
highlighter.setEditor(new LightHighlighterClient(getDocument(), getProject()));
return highlighter;
}
示例7: validateCache
import com.intellij.openapi.editor.highlighter.EditorHighlighter; //导入方法依赖的package包/类
private void validateCache() {
TodoTreeStructure treeStructure = getTodoTreeStructure();
// First of all we need to update "dirty" file set.
for (Iterator<VirtualFile> i = myDirtyFileSet.iterator(); i.hasNext();) {
VirtualFile file = i.next();
PsiFile psiFile = file.isValid() ? PsiManager.getInstance(myProject).findFile(file) : null;
if (psiFile == null || !treeStructure.accept(psiFile)) {
if (myFileTree.contains(file)) {
myFileTree.removeFile(file);
if (myFile2Highlighter.containsKey(file)) { // highlighter isn't needed any more
myFile2Highlighter.remove(file);
}
}
}
else { // file is valid and contains T.O.D.O items
myFileTree.removeFile(file);
myFileTree.add(file); // file can be moved. remove/add calls move it to another place
if (myFile2Highlighter.containsKey(file)) { // update highlighter text
Document document = PsiDocumentManager.getInstance(myProject).getDocument(psiFile);
EditorHighlighter highlighter = myFile2Highlighter.get(file);
highlighter.setText(document.getCharsSequence());
}
}
i.remove();
}
LOG.assertTrue(myDirtyFileSet.isEmpty());
// Now myDirtyFileSet should be empty
}
示例8: getHighlighter
import com.intellij.openapi.editor.highlighter.EditorHighlighter; //导入方法依赖的package包/类
/**
* @return <code>SelectInEditorManager</code> for the specified <code>psiFile</code>. Highlighters are
* lazy created and initialized.
*/
public EditorHighlighter getHighlighter(PsiFile psiFile, Document document) {
VirtualFile file = psiFile.getVirtualFile();
if (myFile2Highlighter.containsKey(file)) {
return myFile2Highlighter.get(file);
}
else {
EditorHighlighter highlighter = HighlighterFactory.createHighlighter(UsageTreeColorsScheme.getInstance().getScheme(), file.getName(), myProject);
highlighter.setText(document.getCharsSequence());
myFile2Highlighter.put(file, highlighter);
return highlighter;
}
}
示例9: select
import com.intellij.openapi.editor.highlighter.EditorHighlighter; //导入方法依赖的package包/类
@Override
public List<TextRange> select(PsiElement e, @NotNull CharSequence editorText, int cursorOffset, @NotNull Editor editor) {
List<TextRange> result;
if (!(e instanceof XmlToken) ||
XmlTokenSelectioner.shouldSelectToken((XmlToken)e) ||
((XmlToken)e).getTokenType() == XmlTokenType.XML_DATA_CHARACTERS) {
result = super.select(e, editorText, cursorOffset, editor);
}
else {
result = ContainerUtil.newArrayList();
}
final PsiElement parent = e.getParent();
if (parent instanceof XmlComment) {
result.addAll(expandToWholeLine(editorText, parent.getTextRange(), true));
}
PsiFile psiFile = e.getContainingFile();
addAttributeSelection(result, editor, editorText, e);
final FileViewProvider fileViewProvider = psiFile.getViewProvider();
for (Language lang : fileViewProvider.getLanguages()) {
final PsiFile langFile = fileViewProvider.getPsi(lang);
if (langFile != psiFile) addAttributeSelection(result, editor, editorText, fileViewProvider.findElementAt(cursorOffset, lang));
}
EditorHighlighter highlighter = HighlighterFactory.createHighlighter(e.getProject(), psiFile.getVirtualFile());
highlighter.setText(editorText);
addTagSelection2(e, result);
return result;
}
示例10: initEmptyEditorHighlighter
import com.intellij.openapi.editor.highlighter.EditorHighlighter; //导入方法依赖的package包/类
@NotNull
public static EditorHighlighter initEmptyEditorHighlighter(@NotNull CharSequence text) {
EditorHighlighter highlighter = createEmptyEditorHighlighter();
highlighter.setText(text);
return highlighter;
}