Search in sources :

Example 96 with PsiBuilder

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

the class PathExpression method parsePathExprQualifierForExprStatement.

/**
   * parses method calls with parentheses, property index access, etc
   */
@NotNull
public static Result parsePathExprQualifierForExprStatement(@NotNull PsiBuilder builder, @NotNull GroovyParser parser) {
    PsiBuilder.Marker marker = builder.mark();
    IElementType qualifierType = PrimaryExpression.parsePrimaryExpression(builder, parser);
    if (qualifierType != GroovyElementTypes.WRONGWAY) {
        return parseAfterQualifier(builder, parser, marker, qualifierType);
    } else {
        marker.drop();
        return Result.WRONG_WAY;
    }
}
Also used : IElementType(com.intellij.psi.tree.IElementType) PsiBuilder(com.intellij.lang.PsiBuilder) NotNull(org.jetbrains.annotations.NotNull)

Example 97 with PsiBuilder

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

the class PathExpression method parseAfterQualifier.

@NotNull
private static Result parseAfterQualifier(@NotNull PsiBuilder builder, @NotNull GroovyParser parser, @NotNull PsiBuilder.Marker marker, @NotNull IElementType qualifierType) {
    if (isPathElementStart(builder)) {
        if (isLParenthOrLCurlyAfterLiteral(builder, qualifierType)) {
            marker.rollbackTo();
            PsiBuilder.Marker newMarker = builder.mark();
            IElementType newQualifierType = PrimaryExpression.parsePrimaryExpression(builder, parser, true);
            assert newQualifierType != GroovyElementTypes.WRONGWAY;
            return parseAfterReference(builder, parser, newMarker);
        } else {
            return parseAfterReference(builder, parser, marker);
        }
    } else {
        marker.drop();
        if (qualifierType == GroovyElementTypes.LITERAL)
            return Result.LITERAL;
        return Result.INVOKED_EXPR;
    }
}
Also used : IElementType(com.intellij.psi.tree.IElementType) PsiBuilder(com.intellij.lang.PsiBuilder) NotNull(org.jetbrains.annotations.NotNull)

Example 98 with PsiBuilder

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

the class RegexExpression method subParse.

private static void subParse(PsiBuilder builder, PsiBuilder.Marker marker, GroovyParser parser) {
    IElementType type = builder.getTokenType();
    ParserUtils.getToken(builder, REGEX_DO);
    ParserUtils.getToken(builder, GroovyTokenTypes.mNLS);
    if (!BinaryExpression.EQUALITY.parseBinary(builder, parser)) {
        builder.error(GroovyBundle.message("expression.expected"));
    }
    PsiBuilder.Marker newMarker = marker.precede();
    marker.done(type == GroovyTokenTypes.mREGEX_FIND ? GroovyElementTypes.REGEX_FIND_EXPRESSION : GroovyElementTypes.REGEX_MATCH_EXPRESSION);
    if (REGEX_DO.contains(builder.getTokenType())) {
        subParse(builder, newMarker, parser);
    } else {
        newMarker.drop();
    }
}
Also used : IElementType(com.intellij.psi.tree.IElementType) PsiBuilder(com.intellij.lang.PsiBuilder)

Example 99 with PsiBuilder

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

the class RegexExpression method parse.

public static boolean parse(PsiBuilder builder, GroovyParser parser) {
    PsiBuilder.Marker marker = builder.mark();
    if (BinaryExpression.EQUALITY.parseBinary(builder, parser)) {
        IElementType type = builder.getTokenType();
        if (ParserUtils.getToken(builder, REGEX_DO)) {
            ParserUtils.getToken(builder, GroovyTokenTypes.mNLS);
            if (!BinaryExpression.EQUALITY.parseBinary(builder, parser)) {
                builder.error(GroovyBundle.message("expression.expected"));
            }
            PsiBuilder.Marker newMarker = marker.precede();
            marker.done(type == GroovyTokenTypes.mREGEX_FIND ? GroovyElementTypes.REGEX_FIND_EXPRESSION : GroovyElementTypes.REGEX_MATCH_EXPRESSION);
            if (REGEX_DO.contains(builder.getTokenType())) {
                subParse(builder, newMarker, parser);
            } else {
                newMarker.drop();
            }
        } else {
            marker.drop();
        }
        return true;
    } else {
        marker.drop();
        return false;
    }
}
Also used : IElementType(com.intellij.psi.tree.IElementType) PsiBuilder(com.intellij.lang.PsiBuilder)

Example 100 with PsiBuilder

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

the class BranchStatement method breakOrContinueParse.

/**
   * (BREAK | CONTINUE) ...
   *
   * @param builder
   * @return
   */
private static void breakOrContinueParse(PsiBuilder builder) {
    PsiBuilder.Marker marker = builder.mark();
    GroovyElementType result = GroovyTokenTypes.kBREAK.equals(builder.getTokenType()) ? GroovyElementTypes.BREAK_STATEMENT : GroovyElementTypes.CONTINUE_STATEMENT;
    builder.advanceLexer();
    ParserUtils.getToken(builder, GroovyTokenTypes.mIDENT);
    marker.done(result);
}
Also used : GroovyElementType(org.jetbrains.plugins.groovy.lang.lexer.GroovyElementType) PsiBuilder(com.intellij.lang.PsiBuilder)

Aggregations

PsiBuilder (com.intellij.lang.PsiBuilder)124 IElementType (com.intellij.psi.tree.IElementType)90 Nullable (org.jetbrains.annotations.Nullable)18 NotNull (org.jetbrains.annotations.NotNull)16 Project (com.intellij.openapi.project.Project)7 LighterASTNode (com.intellij.lang.LighterASTNode)6 GroovyElementType (org.jetbrains.plugins.groovy.lang.lexer.GroovyElementType)5 Language (com.intellij.lang.Language)3 ASTNode (com.intellij.lang.ASTNode)2 PsiElement (com.intellij.psi.PsiElement)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 PsiParser (com.intellij.lang.PsiParser)1 HtmlParsing (com.intellij.lang.html.HtmlParsing)1 Lexer (com.intellij.lexer.Lexer)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 PsiFile (com.intellij.psi.PsiFile)1 LeafPsiElement (com.intellij.psi.impl.source.tree.LeafPsiElement)1