Search in sources :

Example 1 with MarkdownLexerAdapter

use of org.intellij.plugins.markdown.lang.lexer.MarkdownLexerAdapter in project intellij-plugins by JetBrains.

the class MarkdownLazyElementType method doParseContents.

@Override
protected ASTNode doParseContents(@NotNull ASTNode chameleon, @NotNull PsiElement psi) {
    final Project project = psi.getProject();
    final Lexer lexer = new MarkdownLexerAdapter();
    final CharSequence chars = chameleon.getChars();
    final org.intellij.markdown.ast.ASTNode node = new MarkdownParser(MarkdownParserManager.FLAVOUR).parseInline(MarkdownElementType.markdownType(chameleon.getElementType()), chars, 0, chars.length());
    final PsiBuilder builder = PsiBuilderFactory.getInstance().createBuilder(project, chameleon, lexer, getLanguage(), chars);
    assert builder.getCurrentOffset() == 0;
    new PsiBuilderFillingVisitor(builder).visitNode(node);
    assert builder.eof();
    return builder.getTreeBuilt().getFirstChildNode();
}
Also used : Project(com.intellij.openapi.project.Project) Lexer(com.intellij.lexer.Lexer) MarkdownLexerAdapter(org.intellij.plugins.markdown.lang.lexer.MarkdownLexerAdapter) PsiBuilder(com.intellij.lang.PsiBuilder) MarkdownParser(org.intellij.markdown.parser.MarkdownParser) PsiBuilderFillingVisitor(org.intellij.plugins.markdown.lang.parser.PsiBuilderFillingVisitor)

Aggregations

PsiBuilder (com.intellij.lang.PsiBuilder)1 Lexer (com.intellij.lexer.Lexer)1 Project (com.intellij.openapi.project.Project)1 MarkdownParser (org.intellij.markdown.parser.MarkdownParser)1 MarkdownLexerAdapter (org.intellij.plugins.markdown.lang.lexer.MarkdownLexerAdapter)1 PsiBuilderFillingVisitor (org.intellij.plugins.markdown.lang.parser.PsiBuilderFillingVisitor)1