Skip to content

Commit

Permalink
Converts UpdateTargetStep.Element#key to Literal from ExprLit
Browse files Browse the repository at this point in the history
  • Loading branch information
johnedquinn committed Dec 9, 2024
1 parent 7d1a594 commit cd2f178
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 12 deletions.
6 changes: 3 additions & 3 deletions partiql-ast/api/partiql-ast.api
Original file line number Diff line number Diff line change
Expand Up @@ -1819,10 +1819,10 @@ public abstract class org/partiql/ast/dml/UpdateTargetStep : org/partiql/ast/Ast
}

public final class org/partiql/ast/dml/UpdateTargetStep$Element : org/partiql/ast/dml/UpdateTargetStep {
public final field key Lorg/partiql/ast/expr/ExprLit;
public final field key Lorg/partiql/ast/Literal;
public fun <init> (I)V
public fun <init> (Ljava/lang/String;)V
public fun <init> (Lorg/partiql/ast/expr/ExprLit;)V
public fun <init> (Lorg/partiql/ast/Literal;)V
public fun accept (Lorg/partiql/ast/AstVisitor;Ljava/lang/Object;)Ljava/lang/Object;
public static fun builder ()Lorg/partiql/ast/dml/UpdateTargetStep$Element$Builder;
public fun children ()Ljava/util/Collection;
Expand All @@ -1832,7 +1832,7 @@ public final class org/partiql/ast/dml/UpdateTargetStep$Element : org/partiql/as

public class org/partiql/ast/dml/UpdateTargetStep$Element$Builder {
public fun build ()Lorg/partiql/ast/dml/UpdateTargetStep$Element;
public fun key (Lorg/partiql/ast/expr/ExprLit;)Lorg/partiql/ast/dml/UpdateTargetStep$Element$Builder;
public fun key (Lorg/partiql/ast/Literal;)Lorg/partiql/ast/dml/UpdateTargetStep$Element$Builder;
public fun toString ()Ljava/lang/String;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import org.partiql.ast.AstVisitor;
import org.partiql.ast.Identifier;
import org.partiql.ast.Literal;
import org.partiql.ast.expr.ExprLit;

import java.util.ArrayList;
import java.util.Collection;
Expand All @@ -34,15 +33,14 @@ public static final class Element extends UpdateTargetStep {
/**
* TODO
*/
// TODO: Change this to a literal, not an ExprLit
@NotNull
public final ExprLit key;
public final Literal key;

/**
* TODO
* @param key TODO
*/
public Element(@NotNull ExprLit key) {
public Element(@NotNull Literal key) {
this.key = key;
}

Expand All @@ -51,15 +49,15 @@ public Element(@NotNull ExprLit key) {
* @param key TODO
*/
public Element(int key) {
this.key = new ExprLit(Literal.intNum(key));
this.key = Literal.intNum(key);
}

/**
* TODO
* @param key TODO
*/
public Element(@NotNull String key) {
this.key = new ExprLit(Literal.string(key));
this.key = Literal.string(key);
}

@NotNull
Expand Down Expand Up @@ -87,7 +85,6 @@ public static final class Field extends UpdateTargetStep {
/**
* TODO
*/
// TODO: Change this to a literal, not an ExprLit
@NotNull
public final Identifier key;

Expand Down
2 changes: 1 addition & 1 deletion partiql-ast/src/main/kotlin/org/partiql/ast/AstRewriter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -909,7 +909,7 @@ public abstract class AstRewriter<C> : AstVisitor<AstNode, C>() {
}

override fun visitUpdateTargetStepElement(node: UpdateTargetStep.Element, ctx: C): AstNode {
val exprLit = visitExprLit(node.key, ctx) as ExprLit
val exprLit = visitLiteral(node.key, ctx) as Literal
if (exprLit !== node.key) {
return UpdateTargetStep.Element(exprLit)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,8 @@ internal class PartiQLParserDefault : PartiQLParser {
}

override fun visitUpdateTargetStepElement(ctx: GeneratedParser.UpdateTargetStepElementContext) = translate(ctx) {
val literal = visit(ctx.literal()) as ExprLit // TODO: Literals should have their own base in the G4 to allow for overriding the visitLiteral to get type safety.
val exprLit = visit(ctx.literal()) as ExprLit // TODO: Literals should have their own base in the G4 to allow for overriding the visitLiteral to get type safety.
val literal = exprLit.lit
UpdateTargetStep.Element(literal)
}

Expand Down

0 comments on commit cd2f178

Please sign in to comment.