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;
}
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());
}
}
Aggregations