Skip to content

Commit

Permalink
QL: Remove delegating method (#76418) (#76426)
Browse files Browse the repository at this point in the history
Remove typedParsing method in favor of ParserUtils

Follow-up to #76399
  • Loading branch information
costin authored Aug 12, 2021
1 parent 874e77b commit a0665b3
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,8 @@ public Object visit(ParseTree tree) {
return ParserUtils.visit(super::visit, tree);
}

protected <T> T typedParsing(ParseTree ctx, Class<T> type) {
return ParserUtils.typedParsing(this, ctx, type);
}

protected LogicalPlan plan(ParseTree ctx) {
return typedParsing(ctx, LogicalPlan.class);
return ParserUtils.typedParsing(this, ctx, LogicalPlan.class);
}

protected List<LogicalPlan> plans(List<? extends ParserRuleContext> ctxs) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
import static java.util.Collections.emptyList;
import static java.util.stream.Collectors.toList;
import static org.elasticsearch.xpack.ql.parser.ParserUtils.source;
import static org.elasticsearch.xpack.ql.parser.ParserUtils.typedParsing;
import static org.elasticsearch.xpack.ql.parser.ParserUtils.visitList;


Expand All @@ -71,7 +72,7 @@ public ExpressionBuilder(ParserParams params) {
}

protected Expression expression(ParseTree ctx) {
return typedParsing(ctx, Expression.class);
return typedParsing(this, ctx, Expression.class);
}

protected List<Expression> expressions(List<? extends ParserRuleContext> contexts) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,8 @@ public Object visit(ParseTree tree) {
return ParserUtils.visit(super::visit, tree);
}

protected <T> T typedParsing(ParseTree ctx, Class<T> type) {
return ParserUtils.typedParsing(this, ctx, type);
}

protected LogicalPlan plan(ParseTree ctx) {
return typedParsing(ctx, LogicalPlan.class);
return ParserUtils.typedParsing(this, ctx, LogicalPlan.class);
}

protected List<LogicalPlan> plans(List<? extends ParserRuleContext> ctxs) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
import org.antlr.v4.runtime.Token;
import org.antlr.v4.runtime.tree.ParseTree;
import org.antlr.v4.runtime.tree.TerminalNode;
import org.elasticsearch.core.Booleans;
import org.elasticsearch.common.Strings;
import org.elasticsearch.core.Booleans;
import org.elasticsearch.core.Tuple;
import org.elasticsearch.xpack.ql.QlIllegalArgumentException;
import org.elasticsearch.xpack.ql.expression.Alias;
Expand Down Expand Up @@ -136,6 +136,7 @@
import static java.util.Collections.singletonList;
import static org.elasticsearch.xpack.ql.parser.ParserUtils.source;
import static org.elasticsearch.xpack.ql.parser.ParserUtils.text;
import static org.elasticsearch.xpack.ql.parser.ParserUtils.typedParsing;
import static org.elasticsearch.xpack.ql.parser.ParserUtils.visitList;
import static org.elasticsearch.xpack.sql.type.SqlDataTypeConverter.canConvert;
import static org.elasticsearch.xpack.sql.type.SqlDataTypeConverter.converterFor;
Expand All @@ -154,7 +155,7 @@ abstract class ExpressionBuilder extends IdentifierBuilder {
}

protected Expression expression(ParseTree ctx) {
return typedParsing(ctx, Expression.class);
return typedParsing(this, ctx, Expression.class);
}

protected List<Expression> expressions(List<? extends ParserRuleContext> contexts) {
Expand Down Expand Up @@ -407,7 +408,7 @@ public DataType visitPrimitiveDataType(PrimitiveDataTypeContext ctx) {
public Cast visitCastExpression(CastExpressionContext ctx) {
CastTemplateContext castTc = ctx.castTemplate();
if (castTc != null) {
return new Cast(source(castTc), expression(castTc.expression()), typedParsing(castTc.dataType(), DataType.class));
return new Cast(source(castTc), expression(castTc.expression()), typedParsing(this, castTc.dataType(), DataType.class));
} else {
ConvertTemplateContext convertTc = ctx.convertTemplate();
DataType dataType = dataType(source(convertTc.dataType()), convertTc.dataType().getText());
Expand All @@ -426,7 +427,7 @@ private static DataType dataType(Source ctx, String string) {

@Override
public Object visitCastOperatorExpression(SqlBaseParser.CastOperatorExpressionContext ctx) {
return new Cast(source(ctx), expression(ctx.primaryExpression()), typedParsing(ctx.dataType(), DataType.class));
return new Cast(source(ctx), expression(ctx.primaryExpression()), typedParsing(this, ctx.dataType(), DataType.class));
}

@Override
Expand Down

0 comments on commit a0665b3

Please sign in to comment.