Search in sources :

Example 46 with EditorHighlighter

use of com.intellij.openapi.editor.highlighter.EditorHighlighter in project intellij-community by JetBrains.

the class PrintManager method doInitTextPainter.

private static TextPainter doInitTextPainter(final PsiFile psiFile) {
    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());
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) DocumentEx(com.intellij.openapi.editor.ex.DocumentEx) EditorHighlighter(com.intellij.openapi.editor.highlighter.EditorHighlighter)

Example 47 with EditorHighlighter

use of com.intellij.openapi.editor.highlighter.EditorHighlighter in project intellij-community by JetBrains.

the class SimpleEditorPreview method updateView.

@Override
public void updateView() {
    EditorColorsScheme scheme = myOptions.getSelectedScheme();
    myEditor.setColorsScheme(scheme);
    EditorHighlighter highlighter = null;
    if (myPage instanceof EditorHighlightingProvidingColorSettingsPage) {
        highlighter = ((EditorHighlightingProvidingColorSettingsPage) myPage).createEditorHighlighter(scheme);
    }
    if (highlighter == null) {
        final SyntaxHighlighter pageHighlighter = myPage.getHighlighter();
        highlighter = HighlighterFactory.createHighlighter(pageHighlighter, scheme);
    }
    myEditor.setHighlighter(highlighter);
    updateHighlighters();
    myEditor.reinitSettings();
}
Also used : EditorColorsScheme(com.intellij.openapi.editor.colors.EditorColorsScheme) EditorHighlightingProvidingColorSettingsPage(com.intellij.openapi.options.colors.EditorHighlightingProvidingColorSettingsPage) SyntaxHighlighter(com.intellij.openapi.fileTypes.SyntaxHighlighter) EditorHighlighter(com.intellij.openapi.editor.highlighter.EditorHighlighter)

Example 48 with EditorHighlighter

use of com.intellij.openapi.editor.highlighter.EditorHighlighter in project intellij-community by JetBrains.

the class CustomFileTypeEditorTest method testCpp.

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());
}
Also used : HighlighterIterator(com.intellij.openapi.editor.highlighter.HighlighterIterator) EditorHighlighter(com.intellij.openapi.editor.highlighter.EditorHighlighter)

Example 49 with EditorHighlighter

use of com.intellij.openapi.editor.highlighter.EditorHighlighter in project intellij-community by JetBrains.

the class CustomFileTypeEditorTest method testHaskel.

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());
}
Also used : HighlighterIterator(com.intellij.openapi.editor.highlighter.HighlighterIterator) EditorHighlighter(com.intellij.openapi.editor.highlighter.EditorHighlighter)

Example 50 with EditorHighlighter

use of com.intellij.openapi.editor.highlighter.EditorHighlighter in project intellij-community by JetBrains.

the class JavaBraceMatcherTest method testBrokenText.

public void testBrokenText() {
    myFixture.configureByText("a.java", "import java.util.ArrayList;" + "class A {" + "  ArrayList<caret><String");
    final Editor editor = myFixture.getEditor();
    final EditorHighlighter editorHighlighter = ((EditorEx) editor).getHighlighter();
    final HighlighterIterator iterator = editorHighlighter.createIterator(editor.getCaretModel().getOffset());
    boolean matched = BraceMatchingUtil.matchBrace(editor.getDocument().getCharsSequence(), myFixture.getFile().getFileType(), iterator, true);
    assertFalse(matched);
}
Also used : EditorEx(com.intellij.openapi.editor.ex.EditorEx) Editor(com.intellij.openapi.editor.Editor) HighlighterIterator(com.intellij.openapi.editor.highlighter.HighlighterIterator) EditorHighlighter(com.intellij.openapi.editor.highlighter.EditorHighlighter)

Aggregations

EditorHighlighter (com.intellij.openapi.editor.highlighter.EditorHighlighter)63 EditorEx (com.intellij.openapi.editor.ex.EditorEx)36 HighlighterIterator (com.intellij.openapi.editor.highlighter.HighlighterIterator)36 Document (com.intellij.openapi.editor.Document)13 IElementType (com.intellij.psi.tree.IElementType)11 Editor (com.intellij.openapi.editor.Editor)8 FileType (com.intellij.openapi.fileTypes.FileType)8 VirtualFile (com.intellij.openapi.vfs.VirtualFile)8 NotNull (org.jetbrains.annotations.NotNull)8 EditorColorsScheme (com.intellij.openapi.editor.colors.EditorColorsScheme)7 PsiFile (com.intellij.psi.PsiFile)7 LexerEditorHighlighter (com.intellij.openapi.editor.ex.util.LexerEditorHighlighter)6 SyntaxHighlighter (com.intellij.openapi.fileTypes.SyntaxHighlighter)5 PsiElement (com.intellij.psi.PsiElement)5 Language (com.intellij.lang.Language)4 CaretModel (com.intellij.openapi.editor.CaretModel)4 Project (com.intellij.openapi.project.Project)4 BraceMatcher (com.intellij.codeInsight.highlighting.BraceMatcher)3 EditorWindow (com.intellij.injected.editor.EditorWindow)3 LogicalPosition (com.intellij.openapi.editor.LogicalPosition)3