summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2026-11-01 21:09:24 +0000
committerMichael Williamson <mike@zwobble.org>2026-11-01 21:09:24 +0000
commit83cd529c660872f4e3a502cace62cd72a739ff05 (patch)
treebb233ffff4c4ecb8e8e0f4fab07d391cb956c8ab /src
parentda5f2e83708371b1497665c7d0ee8f382898247c (diff)
Extract Relation type
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/zwobble/hobgoblin/compiler/ast/typed/Relation.java18
-rw-r--r--src/main/java/org/zwobble/hobgoblin/compiler/ast/typed/RelationTable.java32
-rw-r--r--src/main/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedQueryDefinitionNode.java22
-rw-r--r--src/main/java/org/zwobble/hobgoblin/compiler/typechecker/TypeChecker.java2
-rw-r--r--src/test/java/org/zwobble/hobgoblin/compiler/ast/typed/RelationTableMatcher.java41
-rw-r--r--src/test/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedQueryDefinitionNodeMatcher.java4
-rw-r--r--src/test/java/org/zwobble/hobgoblin/compiler/typechecker/TypeCheckerQueryDefinitionTests.java3
7 files changed, 109 insertions, 13 deletions
diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/ast/typed/Relation.java b/src/main/java/org/zwobble/hobgoblin/compiler/ast/typed/Relation.java
new file mode 100644
index 0000000..7f08714
--- /dev/null
+++ b/src/main/java/org/zwobble/hobgoblin/compiler/ast/typed/Relation.java
@@ -0,0 +1,18 @@
+// Generated by hobgoblin.
+
+package org.zwobble.hobgoblin.compiler.ast.typed;
+
+// Custom area start: org.zwobble.hobgoblin.compiler.ast.typed.Relation imports
+// Custom area end: org.zwobble.hobgoblin.compiler.ast.typed.Relation imports
+
+public sealed interface Relation permits org.zwobble.hobgoblin.compiler.ast.typed.RelationTable {
+ public interface Builder {
+ public org.zwobble.hobgoblin.compiler.ast.typed.Relation build();
+
+ // Custom area start: org.zwobble.hobgoblin.compiler.ast.typed.Relation.Builder body
+ // Custom area end: org.zwobble.hobgoblin.compiler.ast.typed.Relation.Builder body
+ }
+
+ // Custom area start: org.zwobble.hobgoblin.compiler.ast.typed.Relation body
+ // Custom area end: org.zwobble.hobgoblin.compiler.ast.typed.Relation body
+}
diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/ast/typed/RelationTable.java b/src/main/java/org/zwobble/hobgoblin/compiler/ast/typed/RelationTable.java
new file mode 100644
index 0000000..d62753e
--- /dev/null
+++ b/src/main/java/org/zwobble/hobgoblin/compiler/ast/typed/RelationTable.java
@@ -0,0 +1,32 @@
+// Generated by hobgoblin.
+
+package org.zwobble.hobgoblin.compiler.ast.typed;
+
+// Custom area start: org.zwobble.hobgoblin.compiler.ast.typed.RelationTable imports
+// Custom area end: org.zwobble.hobgoblin.compiler.ast.typed.RelationTable imports
+
+public record RelationTable(
+ org.zwobble.hobgoblin.compiler.types.Table table
+) implements org.zwobble.hobgoblin.compiler.ast.typed.Relation {
+ public static org.zwobble.hobgoblin.compiler.ast.typed.RelationTable.Builder arbitrary() {
+ return new org.zwobble.hobgoblin.compiler.ast.typed.RelationTable.Builder(org.zwobble.hobgoblin.compiler.types.HobgoblinNativeTypes.arbitraryTable());
+ }
+
+ public record Builder(
+ org.zwobble.hobgoblin.compiler.types.Table table
+ ) implements org.zwobble.hobgoblin.compiler.ast.typed.Relation.Builder {
+ public org.zwobble.hobgoblin.compiler.ast.typed.RelationTable build() {
+ return new org.zwobble.hobgoblin.compiler.ast.typed.RelationTable(table);
+ }
+
+ public org.zwobble.hobgoblin.compiler.ast.typed.RelationTable.Builder withTable(org.zwobble.hobgoblin.compiler.types.Table table) {
+ return new org.zwobble.hobgoblin.compiler.ast.typed.RelationTable.Builder(table);
+ }
+
+ // Custom area start: org.zwobble.hobgoblin.compiler.ast.typed.RelationTable.Builder body
+ // Custom area end: org.zwobble.hobgoblin.compiler.ast.typed.RelationTable.Builder body
+ }
+
+ // Custom area start: org.zwobble.hobgoblin.compiler.ast.typed.RelationTable body
+ // Custom area end: org.zwobble.hobgoblin.compiler.ast.typed.RelationTable body
+}
diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedQueryDefinitionNode.java b/src/main/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedQueryDefinitionNode.java
index 2c3f518..dc61d28 100644
--- a/src/main/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedQueryDefinitionNode.java
+++ b/src/main/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedQueryDefinitionNode.java
@@ -7,38 +7,42 @@ package org.zwobble.hobgoblin.compiler.ast.typed;
public record TypedQueryDefinitionNode(
String name,
- org.zwobble.hobgoblin.compiler.types.Table table,
+ org.zwobble.hobgoblin.compiler.ast.typed.Relation relation,
org.zwobble.hobgoblin.compiler.ast.DocComment docComment,
org.zwobble.hobgoblin.compiler.sources.Source source
) implements org.zwobble.hobgoblin.compiler.ast.typed.TypedNamespaceStatementNode {
public static org.zwobble.hobgoblin.compiler.ast.typed.TypedQueryDefinitionNode.Builder arbitrary() {
- return new org.zwobble.hobgoblin.compiler.ast.typed.TypedQueryDefinitionNode.Builder("", org.zwobble.hobgoblin.compiler.types.HobgoblinNativeTypes.arbitraryTable(), org.zwobble.hobgoblin.compiler.ast.HobgoblinNativeAst.arbitraryDocComment(), org.zwobble.hobgoblin.compiler.sources.HobgoblinNativeSources.arbitrarySource());
+ return new org.zwobble.hobgoblin.compiler.ast.typed.TypedQueryDefinitionNode.Builder("", org.zwobble.hobgoblin.compiler.ast.typed.RelationTable.arbitrary().build(), org.zwobble.hobgoblin.compiler.ast.HobgoblinNativeAst.arbitraryDocComment(), org.zwobble.hobgoblin.compiler.sources.HobgoblinNativeSources.arbitrarySource());
}
public record Builder(
String name,
- org.zwobble.hobgoblin.compiler.types.Table table,
+ org.zwobble.hobgoblin.compiler.ast.typed.Relation relation,
org.zwobble.hobgoblin.compiler.ast.DocComment docComment,
org.zwobble.hobgoblin.compiler.sources.Source source
) implements org.zwobble.hobgoblin.compiler.ast.typed.TypedNamespaceStatementNode.Builder {
public org.zwobble.hobgoblin.compiler.ast.typed.TypedQueryDefinitionNode build() {
- return new org.zwobble.hobgoblin.compiler.ast.typed.TypedQueryDefinitionNode(name, table, docComment, source);
+ return new org.zwobble.hobgoblin.compiler.ast.typed.TypedQueryDefinitionNode(name, relation, docComment, source);
}
public org.zwobble.hobgoblin.compiler.ast.typed.TypedQueryDefinitionNode.Builder withName(String name) {
- return new org.zwobble.hobgoblin.compiler.ast.typed.TypedQueryDefinitionNode.Builder(name, table, docComment, source);
+ return new org.zwobble.hobgoblin.compiler.ast.typed.TypedQueryDefinitionNode.Builder(name, relation, docComment, source);
}
- public org.zwobble.hobgoblin.compiler.ast.typed.TypedQueryDefinitionNode.Builder withTable(org.zwobble.hobgoblin.compiler.types.Table table) {
- return new org.zwobble.hobgoblin.compiler.ast.typed.TypedQueryDefinitionNode.Builder(name, table, docComment, source);
+ public org.zwobble.hobgoblin.compiler.ast.typed.TypedQueryDefinitionNode.Builder withRelation(org.zwobble.hobgoblin.compiler.ast.typed.Relation relation) {
+ return new org.zwobble.hobgoblin.compiler.ast.typed.TypedQueryDefinitionNode.Builder(name, relation, docComment, source);
+ }
+
+ public org.zwobble.hobgoblin.compiler.ast.typed.TypedQueryDefinitionNode.Builder withRelation(org.zwobble.hobgoblin.compiler.ast.typed.Relation.Builder relation) {
+ return new org.zwobble.hobgoblin.compiler.ast.typed.TypedQueryDefinitionNode.Builder(name, relation.build(), docComment, source);
}
public org.zwobble.hobgoblin.compiler.ast.typed.TypedQueryDefinitionNode.Builder withDocComment(org.zwobble.hobgoblin.compiler.ast.DocComment docComment) {
- return new org.zwobble.hobgoblin.compiler.ast.typed.TypedQueryDefinitionNode.Builder(name, table, docComment, source);
+ return new org.zwobble.hobgoblin.compiler.ast.typed.TypedQueryDefinitionNode.Builder(name, relation, docComment, source);
}
public org.zwobble.hobgoblin.compiler.ast.typed.TypedQueryDefinitionNode.Builder withSource(org.zwobble.hobgoblin.compiler.sources.Source source) {
- return new org.zwobble.hobgoblin.compiler.ast.typed.TypedQueryDefinitionNode.Builder(name, table, docComment, source);
+ return new org.zwobble.hobgoblin.compiler.ast.typed.TypedQueryDefinitionNode.Builder(name, relation, docComment, source);
}
// Custom area start: org.zwobble.hobgoblin.compiler.ast.typed.TypedQueryDefinitionNode.Builder body
diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/typechecker/TypeChecker.java b/src/main/java/org/zwobble/hobgoblin/compiler/typechecker/TypeChecker.java
index 32acc82..840010f 100644
--- a/src/main/java/org/zwobble/hobgoblin/compiler/typechecker/TypeChecker.java
+++ b/src/main/java/org/zwobble/hobgoblin/compiler/typechecker/TypeChecker.java
@@ -291,7 +291,7 @@ public class TypeChecker {
return new TypedQueryDefinitionNode(
untyped.name(),
- table,
+ new RelationTable(table),
untyped.docComment(),
untyped.source()
);
diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/ast/typed/RelationTableMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/ast/typed/RelationTableMatcher.java
new file mode 100644
index 0000000..3aff4dc
--- /dev/null
+++ b/src/test/java/org/zwobble/hobgoblin/compiler/ast/typed/RelationTableMatcher.java
@@ -0,0 +1,41 @@
+// Generated by hobgoblin.
+
+package org.zwobble.hobgoblin.compiler.ast.typed;
+
+// Custom area start: org.zwobble.hobgoblin.compiler.ast.typed.RelationTableMatcher imports
+// Custom area end: org.zwobble.hobgoblin.compiler.ast.typed.RelationTableMatcher imports
+
+public final class RelationTableMatcher implements org.zwobble.precisely.Matcher<java.lang.Object> {
+ public static org.zwobble.hobgoblin.compiler.ast.typed.RelationTableMatcher isRelationTable() {
+ return new org.zwobble.hobgoblin.compiler.ast.typed.RelationTableMatcher(java.util.List.of());
+ }
+
+ private final java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.ast.typed.RelationTable>> submatchers;
+
+ private RelationTableMatcher(
+ java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.ast.typed.RelationTable>> 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.ast.typed.RelationTable.class, this.submatchers);
+ }
+
+ public org.zwobble.hobgoblin.compiler.ast.typed.RelationTableMatcher withTable(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.types.Table> table) {
+ var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.ast.typed.RelationTable>>(this.submatchers);
+ submatchers.add(org.zwobble.precisely.Matchers.has("table", org.zwobble.hobgoblin.compiler.ast.typed.RelationTable::table, (org.zwobble.precisely.Matcher) table));
+ return new org.zwobble.hobgoblin.compiler.ast.typed.RelationTableMatcher(submatchers);
+ }
+
+ // Custom area start: org.zwobble.hobgoblin.compiler.ast.typed.RelationTableMatcher body
+ // Custom area end: org.zwobble.hobgoblin.compiler.ast.typed.RelationTableMatcher body
+}
diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedQueryDefinitionNodeMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedQueryDefinitionNodeMatcher.java
index 651ede0..d9a6bc5 100644
--- a/src/test/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedQueryDefinitionNodeMatcher.java
+++ b/src/test/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedQueryDefinitionNodeMatcher.java
@@ -36,9 +36,9 @@ public final class TypedQueryDefinitionNodeMatcher implements org.zwobble.precis
return new org.zwobble.hobgoblin.compiler.ast.typed.TypedQueryDefinitionNodeMatcher(submatchers);
}
- public org.zwobble.hobgoblin.compiler.ast.typed.TypedQueryDefinitionNodeMatcher withTable(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.types.Table> table) {
+ public org.zwobble.hobgoblin.compiler.ast.typed.TypedQueryDefinitionNodeMatcher withRelation(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.ast.typed.Relation> relation) {
var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.ast.typed.TypedQueryDefinitionNode>>(this.submatchers);
- submatchers.add(org.zwobble.precisely.Matchers.has("table", org.zwobble.hobgoblin.compiler.ast.typed.TypedQueryDefinitionNode::table, (org.zwobble.precisely.Matcher) table));
+ submatchers.add(org.zwobble.precisely.Matchers.has("relation", org.zwobble.hobgoblin.compiler.ast.typed.TypedQueryDefinitionNode::relation, (org.zwobble.precisely.Matcher) relation));
return new org.zwobble.hobgoblin.compiler.ast.typed.TypedQueryDefinitionNodeMatcher(submatchers);
}
diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/typechecker/TypeCheckerQueryDefinitionTests.java b/src/test/java/org/zwobble/hobgoblin/compiler/typechecker/TypeCheckerQueryDefinitionTests.java
index 4ecc1c6..66be9a7 100644
--- a/src/test/java/org/zwobble/hobgoblin/compiler/typechecker/TypeCheckerQueryDefinitionTests.java
+++ b/src/test/java/org/zwobble/hobgoblin/compiler/typechecker/TypeCheckerQueryDefinitionTests.java
@@ -8,6 +8,7 @@ import org.zwobble.hobgoblin.compiler.ast.untyped.UntypedTypeLevelReferenceNode;
import org.zwobble.hobgoblin.compiler.sources.NullSource;
import org.zwobble.hobgoblin.compiler.types.*;
+import static org.zwobble.hobgoblin.compiler.ast.typed.RelationTableMatcher.isRelationTable;
import static org.zwobble.hobgoblin.compiler.ast.typed.TypedQueryDefinitionNodeMatcher.isTypedQueryDefinitionNode;
import static org.zwobble.hobgoblin.compiler.typechecker.TypeCheckerTesting.typeCheckNamespaceStatement;
import static org.zwobble.precisely.AssertThat.assertThat;
@@ -34,7 +35,7 @@ public class TypeCheckerQueryDefinitionTests {
assertThat(typed, isTypedQueryDefinitionNode()
.withName(equalTo("allAuthors"))
- .withTable(equalTo(table))
+ .withRelation(isRelationTable().withTable(equalTo(table)))
);
}
}