use of com.intellij.lexer.LayeredLexer in project intellij-plugins by JetBrains.
the class CfmlIndexPatternBuilder method getIndexingLexer.
public Lexer getIndexingLexer(@NotNull final PsiFile file) {
if (file instanceof CfmlFile) {
Project project = file.getProject();
SqlLanguageDialect dialect = SqlDialectMappings.getMapping(project, file.getVirtualFile());
Lexer sqlLexer = LanguageParserDefinitions.INSTANCE.forLanguage(dialect).createLexer(project);
LayeredLexer cfmlLayeredLexer = new LayeredLexer(new CfmlLexer(true, project));
cfmlLayeredLexer.registerLayer(new HtmlHighlightingLexer(), CfmlElementTypes.TEMPLATE_TEXT);
cfmlLayeredLexer.registerLayer(sqlLexer, CfmlElementTypes.SQL);
return cfmlLayeredLexer;
}
return null;
}
use of com.intellij.lexer.LayeredLexer in project intellij-community by JetBrains.
the class CustomFileHighlighter method getHighlightingLexer.
@Override
@NotNull
public Lexer getHighlightingLexer() {
Lexer customFileTypeLexer = new CustomFileTypeLexer(myTable, true);
if (myTable.isHasStringEscapes()) {
customFileTypeLexer = new LayeredLexer(customFileTypeLexer);
((LayeredLexer) customFileTypeLexer).registerSelfStoppingLayer(new StringLiteralLexer('\"', CustomHighlighterTokenType.STRING, true, "x"), new IElementType[] { CustomHighlighterTokenType.STRING }, IElementType.EMPTY_ARRAY);
((LayeredLexer) customFileTypeLexer).registerSelfStoppingLayer(new StringLiteralLexer('\'', CustomHighlighterTokenType.STRING, true, "x"), new IElementType[] { CustomHighlighterTokenType.SINGLE_QUOTED_STRING }, IElementType.EMPTY_ARRAY);
}
return customFileTypeLexer;
}
use of com.intellij.lexer.LayeredLexer in project intellij-community by JetBrains.
the class PythonEditorHighlighter method setEditor.
@Override
public void setEditor(@NotNull HighlighterClient editor) {
Lexer l = getLexer();
if (l instanceof LayeredLexer) {
editor.getDocument().putUserData(KEY, editor.getDocument().getText().indexOf(PyNames.UNICODE_LITERALS) == -1);
}
super.setEditor(editor);
}
use of com.intellij.lexer.LayeredLexer in project intellij-community by JetBrains.
the class PythonEditorHighlighter method documentChanged.
@Override
public void documentChanged(DocumentEvent e) {
synchronized (this) {
final Document document = e.getDocument();
Lexer l = getLexer();
// we should update the whole document
if (l instanceof LayeredLexer) {
Lexer delegate = ((LayeredLexer) l).getDelegate();
int offset = e.getOffset();
int lineNumber = document.getLineNumber(offset);
TextRange tr = new TextRange(document.getLineStartOffset(lineNumber), document.getLineEndOffset(lineNumber));
document.putUserData(KEY, document.getText(tr).indexOf(PyNames.UNICODE_LITERALS) == -1);
Boolean hasUnicodeImport = document.getUserData(KEY);
if (delegate instanceof PythonHighlightingLexer && (((PythonHighlightingLexer) delegate).getImportOffset() > e.getOffset() || hasUnicodeImport != hadUnicodeImport)) {
((PythonHighlightingLexer) delegate).clearState(e.getDocument().getTextLength());
setText(document.getCharsSequence());
} else
super.documentChanged(e);
} else
super.documentChanged(e);
}
}
use of com.intellij.lexer.LayeredLexer in project intellij-community by JetBrains.
the class PyHighlighter method getHighlightingLexer.
@NotNull
public Lexer getHighlightingLexer() {
LayeredLexer ret = new LayeredLexer(createHighlightingLexer(myLanguageLevel));
ret.registerLayer(new PyStringLiteralLexer(PyTokenTypes.SINGLE_QUOTED_STRING), PyTokenTypes.SINGLE_QUOTED_STRING);
ret.registerLayer(new PyStringLiteralLexer(PyTokenTypes.SINGLE_QUOTED_UNICODE), PyTokenTypes.SINGLE_QUOTED_UNICODE);
ret.registerLayer(new PyStringLiteralLexer(PyTokenTypes.TRIPLE_QUOTED_STRING), PyTokenTypes.TRIPLE_QUOTED_STRING);
ret.registerLayer(new PyStringLiteralLexer(PyTokenTypes.TRIPLE_QUOTED_UNICODE), PyTokenTypes.TRIPLE_QUOTED_UNICODE);
return ret;
}
Aggregations