Skip to content

Commit 1b617f1

Browse files
authored
QL: Remove delegating method (#76418)
Remove typedParsing method in favor of ParserUtils Follow-up to #76399
1 parent aaeecd7 commit 1b617f1

File tree

4 files changed

+9
-15
lines changed

4 files changed

+9
-15
lines changed

x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/parser/AbstractBuilder.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,8 @@ public Object visit(ParseTree tree) {
2424
return ParserUtils.visit(super::visit, tree);
2525
}
2626

27-
protected <T> T typedParsing(ParseTree ctx, Class<T> type) {
28-
return ParserUtils.typedParsing(this, ctx, type);
29-
}
30-
3127
protected LogicalPlan plan(ParseTree ctx) {
32-
return typedParsing(ctx, LogicalPlan.class);
28+
return ParserUtils.typedParsing(this, ctx, LogicalPlan.class);
3329
}
3430

3531
protected List<LogicalPlan> plans(List<? extends ParserRuleContext> ctxs) {

x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/parser/ExpressionBuilder.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
import static java.util.Collections.emptyList;
6060
import static java.util.stream.Collectors.toList;
6161
import static org.elasticsearch.xpack.ql.parser.ParserUtils.source;
62+
import static org.elasticsearch.xpack.ql.parser.ParserUtils.typedParsing;
6263
import static org.elasticsearch.xpack.ql.parser.ParserUtils.visitList;
6364

6465

@@ -71,7 +72,7 @@ public ExpressionBuilder(ParserParams params) {
7172
}
7273

7374
protected Expression expression(ParseTree ctx) {
74-
return typedParsing(ctx, Expression.class);
75+
return typedParsing(this, ctx, Expression.class);
7576
}
7677

7778
protected List<Expression> expressions(List<? extends ParserRuleContext> contexts) {

x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/parser/AbstractBuilder.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,8 @@ public Object visit(ParseTree tree) {
3131
return ParserUtils.visit(super::visit, tree);
3232
}
3333

34-
protected <T> T typedParsing(ParseTree ctx, Class<T> type) {
35-
return ParserUtils.typedParsing(this, ctx, type);
36-
}
37-
3834
protected LogicalPlan plan(ParseTree ctx) {
39-
return typedParsing(ctx, LogicalPlan.class);
35+
return ParserUtils.typedParsing(this, ctx, LogicalPlan.class);
4036
}
4137

4238
protected List<LogicalPlan> plans(List<? extends ParserRuleContext> ctxs) {

x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/parser/ExpressionBuilder.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
import org.antlr.v4.runtime.Token;
1111
import org.antlr.v4.runtime.tree.ParseTree;
1212
import org.antlr.v4.runtime.tree.TerminalNode;
13-
import org.elasticsearch.core.Booleans;
1413
import org.elasticsearch.common.Strings;
14+
import org.elasticsearch.core.Booleans;
1515
import org.elasticsearch.core.Tuple;
1616
import org.elasticsearch.xpack.ql.QlIllegalArgumentException;
1717
import org.elasticsearch.xpack.ql.expression.Alias;
@@ -136,6 +136,7 @@
136136
import static java.util.Collections.singletonList;
137137
import static org.elasticsearch.xpack.ql.parser.ParserUtils.source;
138138
import static org.elasticsearch.xpack.ql.parser.ParserUtils.text;
139+
import static org.elasticsearch.xpack.ql.parser.ParserUtils.typedParsing;
139140
import static org.elasticsearch.xpack.ql.parser.ParserUtils.visitList;
140141
import static org.elasticsearch.xpack.sql.type.SqlDataTypeConverter.canConvert;
141142
import static org.elasticsearch.xpack.sql.type.SqlDataTypeConverter.converterFor;
@@ -154,7 +155,7 @@ abstract class ExpressionBuilder extends IdentifierBuilder {
154155
}
155156

156157
protected Expression expression(ParseTree ctx) {
157-
return typedParsing(ctx, Expression.class);
158+
return typedParsing(this, ctx, Expression.class);
158159
}
159160

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

427428
@Override
428429
public Object visitCastOperatorExpression(SqlBaseParser.CastOperatorExpressionContext ctx) {
429-
return new Cast(source(ctx), expression(ctx.primaryExpression()), typedParsing(ctx.dataType(), DataType.class));
430+
return new Cast(source(ctx), expression(ctx.primaryExpression()), typedParsing(this, ctx.dataType(), DataType.class));
430431
}
431432

432433
@Override

0 commit comments

Comments
 (0)