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;
}
}
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;
}
}
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();
}
}
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;
}
}
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);
}
Aggregations