Search in sources :

Example 1 with PsiParser

use of com.intellij.lang.PsiParser in project Perl5-IDEA by Camelcade.

the class TemplateToolkitPerlCodeElementType method doParseContents.

@Override
protected ASTNode doParseContents(@NotNull ASTNode chameleon, @NotNull PsiElement psi) {
    Project project = psi.getProject();
    PsiBuilder builder = PsiBuilderFactory.getInstance().createBuilder(project, chameleon, new PerlMergingLexerAdapter(project), PerlLanguage.INSTANCE, chameleon.getText());
    PsiParser parser = PerlParserImpl.INSTANCE;
    return parser.parse(this, builder).getFirstChildNode();
}
Also used : Project(com.intellij.openapi.project.Project) PerlMergingLexerAdapter(com.perl5.lang.perl.lexer.adapters.PerlMergingLexerAdapter) PsiBuilder(com.intellij.lang.PsiBuilder) PsiParser(com.intellij.lang.PsiParser)

Example 2 with PsiParser

use of com.intellij.lang.PsiParser in project intellij by bazelbuild.

the class BuildParserTest method createAST.

private ASTNode createAST(String text) {
    ParserDefinition definition = new BuildParserDefinition();
    PsiParser parser = definition.createParser(getProject());
    Lexer lexer = definition.createLexer(getProject());
    PsiBuilderImpl psiBuilder = new PsiBuilderImpl(getProject(), null, definition, lexer, new CharTableImpl(), text, null, null);
    PsiBuilderAdapter adapter = new PsiBuilderAdapter(psiBuilder) {

        @Override
        public void error(String messageText) {
            super.error(messageText);
            errors.add(messageText);
        }
    };
    return parser.parse(definition.getFileNodeType(), adapter);
}
Also used : CharTableImpl(com.intellij.psi.impl.source.CharTableImpl) Lexer(com.intellij.lexer.Lexer) ParserDefinition(com.intellij.lang.ParserDefinition) PsiBuilderAdapter(com.intellij.lang.impl.PsiBuilderAdapter) PsiBuilderImpl(com.intellij.lang.impl.PsiBuilderImpl) PsiParser(com.intellij.lang.PsiParser)

Aggregations

PsiParser (com.intellij.lang.PsiParser)2 ParserDefinition (com.intellij.lang.ParserDefinition)1 PsiBuilder (com.intellij.lang.PsiBuilder)1 PsiBuilderAdapter (com.intellij.lang.impl.PsiBuilderAdapter)1 PsiBuilderImpl (com.intellij.lang.impl.PsiBuilderImpl)1 Lexer (com.intellij.lexer.Lexer)1 Project (com.intellij.openapi.project.Project)1 CharTableImpl (com.intellij.psi.impl.source.CharTableImpl)1 PerlMergingLexerAdapter (com.perl5.lang.perl.lexer.adapters.PerlMergingLexerAdapter)1