Search in sources :

Example 31 with PsiBuilder

use of com.intellij.lang.PsiBuilder in project intellij-community by JetBrains.

the class JavaFileElementType method parseContents.

@Override
public ASTNode parseContents(final ASTNode chameleon) {
    final PsiBuilder builder = JavaParserUtil.createBuilder(chameleon);
    doParse(builder);
    return builder.getTreeBuilt().getFirstChildNode();
}
Also used : PsiBuilder(com.intellij.lang.PsiBuilder)

Example 32 with PsiBuilder

use of com.intellij.lang.PsiBuilder in project intellij-community by JetBrains.

the class JavaFileElementType method parseContentsLight.

@Override
public FlyweightCapableTreeStructure<LighterASTNode> parseContentsLight(final ASTNode chameleon) {
    final PsiBuilder builder = JavaParserUtil.createBuilder(chameleon);
    doParse(builder);
    return builder.getLightTree();
}
Also used : PsiBuilder(com.intellij.lang.PsiBuilder)

Example 33 with PsiBuilder

use of com.intellij.lang.PsiBuilder in project intellij-community by JetBrains.

the class GroovyDocParser method parse.

@Override
@NotNull
public ASTNode parse(@NotNull IElementType root, @NotNull PsiBuilder builder) {
    PsiBuilder.Marker rootMarker = builder.mark();
    new GroovyDocParsing().parse(builder);
    rootMarker.done(root);
    return builder.getTreeBuilt();
}
Also used : GroovyDocParsing(org.jetbrains.plugins.groovy.lang.groovydoc.parser.parsing.GroovyDocParsing) PsiBuilder(com.intellij.lang.PsiBuilder) NotNull(org.jetbrains.annotations.NotNull)

Example 34 with PsiBuilder

use of com.intellij.lang.PsiBuilder in project intellij-community by JetBrains.

the class SwitchStatement method parseCaseLabel.

/**
   * Parses one or more sequential 'case' or 'default' labels
   */
public static boolean parseCaseLabel(PsiBuilder builder, GroovyParser parser) {
    IElementType elem = builder.getTokenType();
    if (elem != GroovyTokenTypes.kCASE && elem != GroovyTokenTypes.kDEFAULT) {
        return false;
    }
    PsiBuilder.Marker label = builder.mark();
    builder.advanceLexer();
    if (GroovyTokenTypes.kCASE.equals(elem) && !AssignmentExpression.parse(builder, parser)) {
        builder.error(GroovyBundle.message("expression.expected"));
    }
    ParserUtils.getToken(builder, GroovyTokenTypes.mCOLON, GroovyBundle.message("colon.expected"));
    label.done(GroovyElementTypes.CASE_LABEL);
    PsiBuilder.Marker beforeNls = builder.mark();
    ParserUtils.getToken(builder, GroovyTokenTypes.mNLS);
    if (parseCaseLabel(builder, parser)) {
        beforeNls.drop();
    } else {
        beforeNls.rollbackTo();
    }
    return true;
}
Also used : IElementType(com.intellij.psi.tree.IElementType) PsiBuilder(com.intellij.lang.PsiBuilder)

Example 35 with PsiBuilder

use of com.intellij.lang.PsiBuilder in project intellij-community by JetBrains.

the class Declaration method tryParseWithGenerics.

private static IElementType tryParseWithGenerics(@NotNull PsiBuilder builder, boolean isInClass, boolean isInAnnotation, @Nullable String typeDefinitionName, @NotNull GroovyParser parser, boolean modifiersParsed, boolean expressionPossible, boolean acceptTypeParameters) {
    if (acceptTypeParameters) {
        TypeParameters.parse(builder);
    } else {
        final PsiBuilder.Marker error = builder.mark();
        TypeParameters.parse(builder);
        error.error(GroovyBundle.message("type.parameters.are.unexpected"));
    }
    //point to begin of type or variable
    PsiBuilder.Marker checkMarker = builder.mark();
    switch(TypeSpec.parse(builder, false, expressionPossible)) {
        case PATH_REF:
        case REF_WITH_TYPE_PARAMS:
            checkMarker.drop();
            break;
        case FAIL:
            checkMarker.rollbackTo();
            break;
        case IDENTIFIER:
            // declaration name element can be parsed as type element
            IElementType result = VariableDefinitions.parseDefinitions(builder, isInClass, isInAnnotation, typeDefinitionName, modifiersParsed, false, parser);
            if (result == GroovyElementTypes.WRONGWAY) {
                checkMarker.rollbackTo();
            } else {
                checkMarker.drop();
                return result;
            }
    }
    return VariableDefinitions.parseDefinitions(builder, isInClass, isInAnnotation, typeDefinitionName, modifiersParsed, false, parser);
}
Also used : IElementType(com.intellij.psi.tree.IElementType) PsiBuilder(com.intellij.lang.PsiBuilder)

Aggregations

PsiBuilder (com.intellij.lang.PsiBuilder)104 IElementType (com.intellij.psi.tree.IElementType)78 Nullable (org.jetbrains.annotations.Nullable)18 NotNull (org.jetbrains.annotations.NotNull)16 Project (com.intellij.openapi.project.Project)5 GroovyElementType (org.jetbrains.plugins.groovy.lang.lexer.GroovyElementType)5 Language (com.intellij.lang.Language)3 ASTNode (com.intellij.lang.ASTNode)2 ILazyParseableElementType (com.intellij.psi.tree.ILazyParseableElementType)2 ParsingContext (com.jetbrains.python.parsing.ParsingContext)2 StatementParsing (com.jetbrains.python.parsing.StatementParsing)2 ParserDefinition (com.intellij.lang.ParserDefinition)1 HtmlParsing (com.intellij.lang.html.HtmlParsing)1 Lexer (com.intellij.lexer.Lexer)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 PsiElement (com.intellij.psi.PsiElement)1 PsiFile (com.intellij.psi.PsiFile)1 LeafPsiElement (com.intellij.psi.impl.source.tree.LeafPsiElement)1 SmartList (com.intellij.util.SmartList)1 Stack (com.intellij.util.containers.Stack)1