Search in sources :

Example 1 with LexerEditorHighlighterLexer

use of com.intellij.psi.impl.search.LexerEditorHighlighterLexer in project intellij-community by JetBrains.

the class EditorHighlighterCache method getLexerBasedOnLexerHighlighter.

@Nullable
public static Lexer getLexerBasedOnLexerHighlighter(CharSequence text, VirtualFile virtualFile, Project project) {
    EditorHighlighter highlighter = null;
    PsiFile psiFile = virtualFile != null ? PsiManager.getInstance(project).findFile(virtualFile) : null;
    final Document document = psiFile != null ? PsiDocumentManager.getInstance(project).getDocument(psiFile) : null;
    final EditorHighlighter cachedEditorHighlighter;
    boolean alreadyInitializedHighlighter = false;
    if (document != null && (cachedEditorHighlighter = getEditorHighlighterForCachesBuilding(document)) != null && PlatformIdTableBuilding.checkCanUseCachedEditorHighlighter(text, cachedEditorHighlighter)) {
        highlighter = cachedEditorHighlighter;
        alreadyInitializedHighlighter = true;
    } else if (virtualFile != null) {
        highlighter = EditorHighlighterFactory.getInstance().createEditorHighlighter(project, virtualFile);
    }
    if (highlighter != null) {
        return new LexerEditorHighlighterLexer(highlighter, alreadyInitializedHighlighter);
    }
    return null;
}
Also used : LexerEditorHighlighterLexer(com.intellij.psi.impl.search.LexerEditorHighlighterLexer) PsiFile(com.intellij.psi.PsiFile) Document(com.intellij.openapi.editor.Document) EditorHighlighter(com.intellij.openapi.editor.highlighter.EditorHighlighter) LexerEditorHighlighter(com.intellij.openapi.editor.ex.util.LexerEditorHighlighter) Nullable(org.jetbrains.annotations.Nullable)

Example 2 with LexerEditorHighlighterLexer

use of com.intellij.psi.impl.search.LexerEditorHighlighterLexer in project intellij-community by JetBrains.

the class SyntaxHighlighterOverEditorHighlighter method resetPosition.

public void resetPosition(int startOffset) {
    if (lexer instanceof LexerEditorHighlighterLexer) {
        ((LexerEditorHighlighterLexer) lexer).resetPosition(startOffset);
        HighlighterIterator iterator = ((LexerEditorHighlighterLexer) lexer).getHighlighterIterator();
        if (iterator instanceof LayeredHighlighterIterator) {
            layeredHighlighterIterator = (LayeredHighlighterIterator) iterator;
        } else {
            layeredHighlighterIterator = null;
        }
    } else {
        CharSequence text = lexer.getBufferSequence();
        lexer.start(text, startOffset, text.length());
    }
}
Also used : LayeredHighlighterIterator(com.intellij.openapi.editor.ex.util.LayeredHighlighterIterator) LexerEditorHighlighterLexer(com.intellij.psi.impl.search.LexerEditorHighlighterLexer) HighlighterIterator(com.intellij.openapi.editor.highlighter.HighlighterIterator) LayeredHighlighterIterator(com.intellij.openapi.editor.ex.util.LayeredHighlighterIterator)

Aggregations

LexerEditorHighlighterLexer (com.intellij.psi.impl.search.LexerEditorHighlighterLexer)2 Document (com.intellij.openapi.editor.Document)1 LayeredHighlighterIterator (com.intellij.openapi.editor.ex.util.LayeredHighlighterIterator)1 LexerEditorHighlighter (com.intellij.openapi.editor.ex.util.LexerEditorHighlighter)1 EditorHighlighter (com.intellij.openapi.editor.highlighter.EditorHighlighter)1 HighlighterIterator (com.intellij.openapi.editor.highlighter.HighlighterIterator)1 PsiFile (com.intellij.psi.PsiFile)1 Nullable (org.jetbrains.annotations.Nullable)1