diff options
| author | Michael Williamson <mike@zwobble.org> | 2026-11-01 22:08:45 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2026-11-01 22:08:45 +0000 |
| commit | 66855f114b4aff76634bf77ac6336d7d4b4fb2f3 (patch) | |
| tree | 6951c07c7fb93bfab294d8c4f7359e19be301139 /src | |
| parent | 16ff9ae1529ea492354b5144d3ddd41b695e3999 (diff) | |
Add simple SQL SELECTs to AST
Diffstat (limited to 'src')
10 files changed, 373 insertions, 1 deletions
diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/sql/SqlWriter.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/sql/SqlWriter.java index ef1562e..890fbba 100644 --- a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/sql/SqlWriter.java +++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/sql/SqlWriter.java @@ -68,6 +68,10 @@ public class SqlWriter { case SqlCreateTableStatement createTableStatement -> { writeCreateTableStatement(createTableStatement); } + + case SqlSelectStatement selectStatement -> { + writeSelectStatement(selectStatement); + } } } @@ -104,6 +108,31 @@ public class SqlWriter { this.writeIdentifier(column.typeName()); } + private void writeSelectStatement(SqlSelectStatement selectStatement) throws IOException { + this.writer.write("SELECT"); + this.writer.newLine(); + this.writer.indent(); + + writeWithSeparator( + selectStatement.columns(), + column -> { + this.writeExpression(column.expression()); + this.writer.write(" AS "); + this.writeIdentifier(column.alias()); + }, + () -> { + this.writer.write(","); + this.writer.newLine(); + } + ); + + this.writer.newLine(); + this.writer.dedent(); + this.writer.write("FROM "); + this.writeIdentifier(selectStatement.from()); + this.writer.write(";"); + } + // == Table constraints == void writeTableConstraint(SqlTableConstraint tableConstraint) throws IOException { @@ -124,6 +153,20 @@ public class SqlWriter { this.writer.write(")"); } + // == Expressions == + + void writeExpression(SqlExpression expression) throws IOException { + switch (expression) { + case SqlRef ref -> { + this.writeRef(ref); + } + } + } + + private void writeRef(SqlRef ref) throws IOException { + this.writeIdentifier(ref.name()); + } + // == Identifiers == private void writeIdentifier(SqlIdentifier name) throws IOException { diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/sql/ast/SqlExpression.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/sql/ast/SqlExpression.java new file mode 100644 index 0000000..37f5f93 --- /dev/null +++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/sql/ast/SqlExpression.java @@ -0,0 +1,18 @@ +// Generated by hobgoblin. + +package org.zwobble.hobgoblin.compiler.output.lang.sql.ast; + +// Custom area start: org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlExpression imports +// Custom area end: org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlExpression imports + +public sealed interface SqlExpression permits org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlRef { + public interface Builder { + public org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlExpression build(); + + // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlExpression.Builder body + // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlExpression.Builder body + } + + // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlExpression body + // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlExpression body +} diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/sql/ast/SqlRef.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/sql/ast/SqlRef.java new file mode 100644 index 0000000..156e6ab --- /dev/null +++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/sql/ast/SqlRef.java @@ -0,0 +1,36 @@ +// Generated by hobgoblin. + +package org.zwobble.hobgoblin.compiler.output.lang.sql.ast; + +// Custom area start: org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlRef imports +// Custom area end: org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlRef imports + +public record SqlRef( + org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlIdentifier name +) implements org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlExpression { + public static org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlRef.Builder arbitrary() { + return new org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlRef.Builder(org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlIdentifier.arbitrary().build()); + } + + public record Builder( + org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlIdentifier name + ) implements org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlExpression.Builder { + public org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlRef build() { + return new org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlRef(name); + } + + public org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlRef.Builder withName(org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlIdentifier name) { + return new org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlRef.Builder(name); + } + + public org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlRef.Builder withName(org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlIdentifier.Builder name) { + return new org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlRef.Builder(name.build()); + } + + // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlRef.Builder body + // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlRef.Builder body + } + + // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlRef body + // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlRef body +} diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/sql/ast/SqlResultColumn.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/sql/ast/SqlResultColumn.java new file mode 100644 index 0000000..1db29b1 --- /dev/null +++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/sql/ast/SqlResultColumn.java @@ -0,0 +1,46 @@ +// Generated by hobgoblin. + +package org.zwobble.hobgoblin.compiler.output.lang.sql.ast; + +// Custom area start: org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlResultColumn imports +// Custom area end: org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlResultColumn imports + +public record SqlResultColumn( + org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlExpression expression, + org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlIdentifier alias +) { + public static org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlResultColumn.Builder arbitrary() { + return new org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlResultColumn.Builder(org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlRef.arbitrary().build(), org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlIdentifier.arbitrary().build()); + } + + public record Builder( + org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlExpression expression, + org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlIdentifier alias + ) { + public org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlResultColumn build() { + return new org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlResultColumn(expression, alias); + } + + public org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlResultColumn.Builder withExpression(org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlExpression expression) { + return new org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlResultColumn.Builder(expression, alias); + } + + public org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlResultColumn.Builder withExpression(org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlExpression.Builder expression) { + return new org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlResultColumn.Builder(expression.build(), alias); + } + + public org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlResultColumn.Builder withAlias(org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlIdentifier alias) { + return new org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlResultColumn.Builder(expression, alias); + } + + public org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlResultColumn.Builder withAlias(org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlIdentifier.Builder alias) { + return new org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlResultColumn.Builder(expression, alias.build()); + } + + // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlResultColumn.Builder body + // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlResultColumn.Builder body + } + + // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlResultColumn body + // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlResultColumn body +} diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/sql/ast/SqlSelectStatement.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/sql/ast/SqlSelectStatement.java new file mode 100644 index 0000000..b5c889b --- /dev/null +++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/sql/ast/SqlSelectStatement.java @@ -0,0 +1,54 @@ +// Generated by hobgoblin. + +package org.zwobble.hobgoblin.compiler.output.lang.sql.ast; + +// Custom area start: org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlSelectStatement imports +// Custom area end: org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlSelectStatement imports + +public record SqlSelectStatement( + java.util.List<org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlResultColumn> columns, + org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlIdentifier from +) implements org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlStatement { + public static org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlSelectStatement.Builder arbitrary() { + return new org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlSelectStatement.Builder(java.util.List.of(), org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlIdentifier.arbitrary().build()); + } + + public record Builder( + java.util.List<org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlResultColumn> columns, + org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlIdentifier from + ) implements org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlStatement.Builder { + public org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlSelectStatement build() { + return new org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlSelectStatement(columns, from); + } + + public org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlSelectStatement.Builder withColumns(java.util.List<org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlResultColumn> columns) { + return new org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlSelectStatement.Builder(columns, from); + } + + public org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlSelectStatement.Builder addColumn(org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlResultColumn column) { + var columns = new java.util.ArrayList<org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlResultColumn>(this.columns); + columns.add(column); + return new org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlSelectStatement.Builder(columns, from); + } + + public org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlSelectStatement.Builder addColumn(org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlResultColumn.Builder column) { + var columns = new java.util.ArrayList<org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlResultColumn>(this.columns); + columns.add(column.build()); + return new org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlSelectStatement.Builder(columns, from); + } + + public org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlSelectStatement.Builder withFrom(org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlIdentifier from) { + return new org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlSelectStatement.Builder(columns, from); + } + + public org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlSelectStatement.Builder withFrom(org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlIdentifier.Builder from) { + return new org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlSelectStatement.Builder(columns, from.build()); + } + + // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlSelectStatement.Builder body + // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlSelectStatement.Builder body + } + + // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlSelectStatement body + // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlSelectStatement body +} diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/sql/ast/SqlStatement.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/sql/ast/SqlStatement.java index 0f90dc1..a6d4ab2 100644 --- a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/sql/ast/SqlStatement.java +++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/sql/ast/SqlStatement.java @@ -5,7 +5,7 @@ package org.zwobble.hobgoblin.compiler.output.lang.sql.ast; // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlStatement imports // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlStatement imports -public sealed interface SqlStatement permits org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlCreateTableStatement { +public sealed interface SqlStatement permits org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlCreateTableStatement, org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlSelectStatement { public interface Builder { public org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlStatement build(); diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/sql/SqlWriterTests.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/sql/SqlWriterTests.java index 42b075f..0b303f1 100644 --- a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/sql/SqlWriterTests.java +++ b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/sql/SqlWriterTests.java @@ -105,6 +105,32 @@ public class SqlWriterTests { )); } + // === Select statements === + + @Test + public void minimalSelectStatement() throws IOException { + var sql = SqlSelectStatement.arbitrary() + .addColumn(SqlResultColumn.arbitrary() + .withExpression(ref("a")) + .withAlias(id("x")) + ) + .addColumn(SqlResultColumn.arbitrary() + .withExpression(ref("b")) + .withAlias(id("y")) + ) + .withFrom(id("blah")) + .build(); + + var string = write(writer -> writer.writeStatement(sql)); + + assertThat(string, equalTo(""" + SELECT + a AS x, + b AS y + FROM blah;""" + )); + } + // == Table constraints == @Test @@ -130,6 +156,17 @@ public class SqlWriterTests { assertThat(string, equalTo("PRIMARY KEY (a, b)")); } + // === Expressions === + + @Test + public void ref() throws IOException { + var sql = ref("a"); + + var string = write(writer -> writer.writeExpression(sql)); + + assertThat(string, equalTo("a")); + } + // == Test utilities == private String write(SqlWriter.Write write) throws IOException { @@ -147,6 +184,9 @@ public class SqlWriterTests { private SqlIdentifier id(String value) { return new SqlIdentifier(value); + } + private SqlRef ref(String name) { + return new SqlRef(id(name)); } } diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/sql/ast/SqlRefMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/sql/ast/SqlRefMatcher.java new file mode 100644 index 0000000..c56f266 --- /dev/null +++ b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/sql/ast/SqlRefMatcher.java @@ -0,0 +1,41 @@ +// Generated by hobgoblin. + +package org.zwobble.hobgoblin.compiler.output.lang.sql.ast; + +// Custom area start: org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlRefMatcher imports +// Custom area end: org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlRefMatcher imports + +public final class SqlRefMatcher implements org.zwobble.precisely.Matcher<java.lang.Object> { + public static org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlRefMatcher isSqlRef() { + return new org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlRefMatcher(java.util.List.of()); + } + + private final java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlRef>> submatchers; + + private SqlRefMatcher( + java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlRef>> submatchers + ) { + this.submatchers = submatchers; + } + + public org.zwobble.precisely.MatchResult match(java.lang.Object actual) { + return this.toMatcher().match(actual); + } + + public org.zwobble.precisely.TextTree describe() { + return this.toMatcher().describe(); + } + + private org.zwobble.precisely.Matcher<java.lang.Object> toMatcher() { + return org.zwobble.precisely.Matchers.instanceOf(org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlRef.class, this.submatchers); + } + + public org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlRefMatcher withName(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlIdentifier> name) { + var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlRef>>(this.submatchers); + submatchers.add(org.zwobble.precisely.Matchers.has("name", org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlRef::name, (org.zwobble.precisely.Matcher) name)); + return new org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlRefMatcher(submatchers); + } + + // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlRefMatcher body + // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlRefMatcher body +} diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/sql/ast/SqlResultColumnMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/sql/ast/SqlResultColumnMatcher.java new file mode 100644 index 0000000..772b6c5 --- /dev/null +++ b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/sql/ast/SqlResultColumnMatcher.java @@ -0,0 +1,47 @@ +// Generated by hobgoblin. + +package org.zwobble.hobgoblin.compiler.output.lang.sql.ast; + +// Custom area start: org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlResultColumnMatcher imports +// Custom area end: org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlResultColumnMatcher imports + +public final class SqlResultColumnMatcher implements org.zwobble.precisely.Matcher<java.lang.Object> { + public static org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlResultColumnMatcher isSqlResultColumn() { + return new org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlResultColumnMatcher(java.util.List.of()); + } + + private final java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlResultColumn>> submatchers; + + private SqlResultColumnMatcher( + java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlResultColumn>> submatchers + ) { + this.submatchers = submatchers; + } + + public org.zwobble.precisely.MatchResult match(java.lang.Object actual) { + return this.toMatcher().match(actual); + } + + public org.zwobble.precisely.TextTree describe() { + return this.toMatcher().describe(); + } + + private org.zwobble.precisely.Matcher<java.lang.Object> toMatcher() { + return org.zwobble.precisely.Matchers.instanceOf(org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlResultColumn.class, this.submatchers); + } + + public org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlResultColumnMatcher withExpression(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlExpression> expression) { + var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlResultColumn>>(this.submatchers); + submatchers.add(org.zwobble.precisely.Matchers.has("expression", org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlResultColumn::expression, (org.zwobble.precisely.Matcher) expression)); + return new org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlResultColumnMatcher(submatchers); + } + + public org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlResultColumnMatcher withAlias(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlIdentifier> alias) { + var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlResultColumn>>(this.submatchers); + submatchers.add(org.zwobble.precisely.Matchers.has("alias", org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlResultColumn::alias, (org.zwobble.precisely.Matcher) alias)); + return new org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlResultColumnMatcher(submatchers); + } + + // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlResultColumnMatcher body + // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlResultColumnMatcher body +} diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/sql/ast/SqlSelectStatementMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/sql/ast/SqlSelectStatementMatcher.java new file mode 100644 index 0000000..ba99111 --- /dev/null +++ b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/sql/ast/SqlSelectStatementMatcher.java @@ -0,0 +1,47 @@ +// Generated by hobgoblin. + +package org.zwobble.hobgoblin.compiler.output.lang.sql.ast; + +// Custom area start: org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlSelectStatementMatcher imports +// Custom area end: org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlSelectStatementMatcher imports + +public final class SqlSelectStatementMatcher implements org.zwobble.precisely.Matcher<java.lang.Object> { + public static org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlSelectStatementMatcher isSqlSelectStatement() { + return new org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlSelectStatementMatcher(java.util.List.of()); + } + + private final java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlSelectStatement>> submatchers; + + private SqlSelectStatementMatcher( + java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlSelectStatement>> submatchers + ) { + this.submatchers = submatchers; + } + + public org.zwobble.precisely.MatchResult match(java.lang.Object actual) { + return this.toMatcher().match(actual); + } + + public org.zwobble.precisely.TextTree describe() { + return this.toMatcher().describe(); + } + + private org.zwobble.precisely.Matcher<java.lang.Object> toMatcher() { + return org.zwobble.precisely.Matchers.instanceOf(org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlSelectStatement.class, this.submatchers); + } + + public org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlSelectStatementMatcher withColumns(org.zwobble.precisely.Matcher<? super java.util.List<org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlResultColumn>> columns) { + var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlSelectStatement>>(this.submatchers); + submatchers.add(org.zwobble.precisely.Matchers.has("columns", org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlSelectStatement::columns, (org.zwobble.precisely.Matcher) columns)); + return new org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlSelectStatementMatcher(submatchers); + } + + public org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlSelectStatementMatcher withFrom(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlIdentifier> from) { + var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlSelectStatement>>(this.submatchers); + submatchers.add(org.zwobble.precisely.Matchers.has("from", org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlSelectStatement::from, (org.zwobble.precisely.Matcher) from)); + return new org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlSelectStatementMatcher(submatchers); + } + + // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlSelectStatementMatcher body + // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlSelectStatementMatcher body +} |
