diff options
29 files changed, 969 insertions, 141 deletions
diff --git a/hobgoblin/src/ast/typed.hob b/hobgoblin/src/ast/typed.hob new file mode 100644 index 0000000..e7dd72d --- /dev/null +++ b/hobgoblin/src/ast/typed.hob @@ -0,0 +1,68 @@ +import {DocComment} from ast; +import {Source} from sources; +import { + EnumType, + NamespaceName, + SimpleNativeType, + SimpleStructType, + SumType, + Type, + TypeOrConstructor, +} from types; + +struct TypedNamespaceNode { + field namespaceName: NamespaceName; + field body: List[TypedNamespaceStatementNode]; + field source: Source; +} + +sum TypedNamespaceStatementNode { + variant TypedEnumDefinitionNode; + variant TypedNativeTypeDefinitionNode; + variant TypedStructDefinitionNode; + variant TypedSumDefinitionNode; +} + +struct TypedEnumDefinitionNode { + field type: EnumType; + field variants: List[TypedEnumVariantDefinitionNode]; + field docComment: DocComment; + field source: Source; +} + +struct TypedEnumVariantDefinitionNode { + field name: String; + field source: Source; +} + +struct TypedNativeTypeDefinitionNode { + field typeOrConstructor: TypeOrConstructor[SimpleNativeType]; + field docComment: DocComment; + field source: Source; +} + +struct TypedStructDefinitionNode { + field typeOrConstructor: TypeOrConstructor[SimpleStructType]; + field fields: Option[List[TypedStructFieldDefinitionNode]]; + field docComment: DocComment; + field source: Source; +} + +struct TypedStructFieldDefinitionNode { + field name: String; + field type: Type; + field source: Source; +} + +struct TypedSumDefinitionNode { + field type: SumType; + field variants: List[TypedSumVariantDefinitionNode]; + field fields: List[TypedStructFieldDefinitionNode]; + field docComment: DocComment; + field source: Source; +} + +struct TypedSumVariantDefinitionNode { + field type: Type; + field source: Source; +} diff --git a/hobgoblin/src/types.hob b/hobgoblin/src/types.hob index e1646a0..4e3a971 100644 --- a/hobgoblin/src/types.hob +++ b/hobgoblin/src/types.hob @@ -1,2 +1,20 @@ native NamespaceName { } + +native Type { +} + +native EnumType { +} + +native SimpleNativeType { +} + +native SimpleStructType { +} + +native SumType { +} + +native TypeOrConstructor[T] { +} diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedEnumDefinitionNode.java b/src/main/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedEnumDefinitionNode.java index a307a67..c9b5f5b 100644 --- a/src/main/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedEnumDefinitionNode.java +++ b/src/main/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedEnumDefinitionNode.java @@ -1,18 +1,65 @@ -package org.zwobble.hobgoblin.compiler.ast.typed; +// Generated by hobgoblin. -import org.zwobble.hobgoblin.compiler.ast.DocComment; -import org.zwobble.hobgoblin.compiler.sources.Source; -import org.zwobble.hobgoblin.compiler.types.EnumType; +package org.zwobble.hobgoblin.compiler.ast.typed; -import java.util.List; +// Custom area start: org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumDefinitionNode imports +// Custom area end: org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumDefinitionNode imports public record TypedEnumDefinitionNode( - EnumType type, - List<TypedEnumVariantDefinitionNode> variants, - DocComment docComment, - Source source -) implements TypedNamespaceStatementNode { + org.zwobble.hobgoblin.compiler.types.EnumType type, + java.util.List<org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumVariantDefinitionNode> variants, + 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.TypedEnumDefinitionNode.Builder arbitrary() { + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumDefinitionNode.Builder(org.zwobble.hobgoblin.compiler.types.HobgoblinNativeTypes.arbitraryEnumType(), java.util.List.of(), org.zwobble.hobgoblin.compiler.ast.HobgoblinNativeAst.arbitraryDocComment(), org.zwobble.hobgoblin.compiler.sources.HobgoblinNativeSources.arbitrarySource()); + } + + public record Builder( + org.zwobble.hobgoblin.compiler.types.EnumType type, + java.util.List<org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumVariantDefinitionNode> variants, + 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.TypedEnumDefinitionNode build() { + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumDefinitionNode(type, variants, docComment, source); + } + + public org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumDefinitionNode.Builder withType(org.zwobble.hobgoblin.compiler.types.EnumType type) { + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumDefinitionNode.Builder(type, variants, docComment, source); + } + + public org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumDefinitionNode.Builder withVariants(java.util.List<org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumVariantDefinitionNode> variants) { + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumDefinitionNode.Builder(type, variants, docComment, source); + } + + public org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumDefinitionNode.Builder addVariant(org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumVariantDefinitionNode variant) { + var variants = new java.util.ArrayList<org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumVariantDefinitionNode>(this.variants); + variants.add(variant); + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumDefinitionNode.Builder(type, variants, docComment, source); + } + + public org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumDefinitionNode.Builder addVariant(org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumVariantDefinitionNode.Builder variant) { + var variants = new java.util.ArrayList<org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumVariantDefinitionNode>(this.variants); + variants.add(variant.build()); + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumDefinitionNode.Builder(type, variants, docComment, source); + } + + public org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumDefinitionNode.Builder withDocComment(org.zwobble.hobgoblin.compiler.ast.DocComment docComment) { + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumDefinitionNode.Builder(type, variants, docComment, source); + } + + public org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumDefinitionNode.Builder withSource(org.zwobble.hobgoblin.compiler.sources.Source source) { + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumDefinitionNode.Builder(type, variants, docComment, source); + } + + // Custom area start: org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumDefinitionNode.Builder body + // Custom area end: org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumDefinitionNode.Builder body + } + + // Custom area start: org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumDefinitionNode body public String name() { return this.type.name(); } + // Custom area end: org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumDefinitionNode body } diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedEnumVariantDefinitionNode.java b/src/main/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedEnumVariantDefinitionNode.java index 7036136..da735e1 100644 --- a/src/main/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedEnumVariantDefinitionNode.java +++ b/src/main/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedEnumVariantDefinitionNode.java @@ -1,6 +1,38 @@ +// Generated by hobgoblin. + package org.zwobble.hobgoblin.compiler.ast.typed; -import org.zwobble.hobgoblin.compiler.sources.Source; +// Custom area start: org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumVariantDefinitionNode imports +// Custom area end: org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumVariantDefinitionNode imports + +public record TypedEnumVariantDefinitionNode( + String name, + org.zwobble.hobgoblin.compiler.sources.Source source +) { + public static org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumVariantDefinitionNode.Builder arbitrary() { + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumVariantDefinitionNode.Builder("", org.zwobble.hobgoblin.compiler.sources.HobgoblinNativeSources.arbitrarySource()); + } + + public record Builder( + String name, + org.zwobble.hobgoblin.compiler.sources.Source source + ) { + public org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumVariantDefinitionNode build() { + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumVariantDefinitionNode(name, source); + } + + public org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumVariantDefinitionNode.Builder withName(String name) { + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumVariantDefinitionNode.Builder(name, source); + } + + public org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumVariantDefinitionNode.Builder withSource(org.zwobble.hobgoblin.compiler.sources.Source source) { + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumVariantDefinitionNode.Builder(name, source); + } + + // Custom area start: org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumVariantDefinitionNode.Builder body + // Custom area end: org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumVariantDefinitionNode.Builder body + } -public record TypedEnumVariantDefinitionNode(String name, Source source) { + // Custom area start: org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumVariantDefinitionNode body + // Custom area end: org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumVariantDefinitionNode body } diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedNamespaceNode.java b/src/main/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedNamespaceNode.java index 805498f..fcb2fe9 100644 --- a/src/main/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedNamespaceNode.java +++ b/src/main/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedNamespaceNode.java @@ -1,13 +1,56 @@ -package org.zwobble.hobgoblin.compiler.ast.typed; +// Generated by hobgoblin. -import org.zwobble.hobgoblin.compiler.sources.Source; -import org.zwobble.hobgoblin.compiler.types.NamespaceName; +package org.zwobble.hobgoblin.compiler.ast.typed; -import java.util.List; +// Custom area start: org.zwobble.hobgoblin.compiler.ast.typed.TypedNamespaceNode imports +// Custom area end: org.zwobble.hobgoblin.compiler.ast.typed.TypedNamespaceNode imports public record TypedNamespaceNode( - NamespaceName namespaceName, - List<TypedNamespaceStatementNode> body, - Source source -) implements TypedNode { + org.zwobble.hobgoblin.compiler.types.NamespaceName namespaceName, + java.util.List<org.zwobble.hobgoblin.compiler.ast.typed.TypedNamespaceStatementNode> body, + org.zwobble.hobgoblin.compiler.sources.Source source +) { + public static org.zwobble.hobgoblin.compiler.ast.typed.TypedNamespaceNode.Builder arbitrary() { + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedNamespaceNode.Builder(org.zwobble.hobgoblin.compiler.types.HobgoblinNativeTypes.arbitraryNamespaceName(), java.util.List.of(), org.zwobble.hobgoblin.compiler.sources.HobgoblinNativeSources.arbitrarySource()); + } + + public record Builder( + org.zwobble.hobgoblin.compiler.types.NamespaceName namespaceName, + java.util.List<org.zwobble.hobgoblin.compiler.ast.typed.TypedNamespaceStatementNode> body, + org.zwobble.hobgoblin.compiler.sources.Source source + ) { + public org.zwobble.hobgoblin.compiler.ast.typed.TypedNamespaceNode build() { + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedNamespaceNode(namespaceName, body, source); + } + + public org.zwobble.hobgoblin.compiler.ast.typed.TypedNamespaceNode.Builder withNamespaceName(org.zwobble.hobgoblin.compiler.types.NamespaceName namespaceName) { + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedNamespaceNode.Builder(namespaceName, body, source); + } + + public org.zwobble.hobgoblin.compiler.ast.typed.TypedNamespaceNode.Builder withBody(java.util.List<org.zwobble.hobgoblin.compiler.ast.typed.TypedNamespaceStatementNode> body) { + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedNamespaceNode.Builder(namespaceName, body, source); + } + + public org.zwobble.hobgoblin.compiler.ast.typed.TypedNamespaceNode.Builder addBodyElement(org.zwobble.hobgoblin.compiler.ast.typed.TypedNamespaceStatementNode bodyElement) { + var body = new java.util.ArrayList<org.zwobble.hobgoblin.compiler.ast.typed.TypedNamespaceStatementNode>(this.body); + body.add(bodyElement); + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedNamespaceNode.Builder(namespaceName, body, source); + } + + public org.zwobble.hobgoblin.compiler.ast.typed.TypedNamespaceNode.Builder addBodyElement(org.zwobble.hobgoblin.compiler.ast.typed.TypedNamespaceStatementNode.Builder bodyElement) { + var body = new java.util.ArrayList<org.zwobble.hobgoblin.compiler.ast.typed.TypedNamespaceStatementNode>(this.body); + body.add(bodyElement.build()); + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedNamespaceNode.Builder(namespaceName, body, source); + } + + public org.zwobble.hobgoblin.compiler.ast.typed.TypedNamespaceNode.Builder withSource(org.zwobble.hobgoblin.compiler.sources.Source source) { + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedNamespaceNode.Builder(namespaceName, body, source); + } + + // Custom area start: org.zwobble.hobgoblin.compiler.ast.typed.TypedNamespaceNode.Builder body + // Custom area end: org.zwobble.hobgoblin.compiler.ast.typed.TypedNamespaceNode.Builder body + } + + // Custom area start: org.zwobble.hobgoblin.compiler.ast.typed.TypedNamespaceNode body + // Custom area end: org.zwobble.hobgoblin.compiler.ast.typed.TypedNamespaceNode body } diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedNamespaceStatementNode.java b/src/main/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedNamespaceStatementNode.java index fdd45b7..ac01a37 100644 --- a/src/main/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedNamespaceStatementNode.java +++ b/src/main/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedNamespaceStatementNode.java @@ -1,4 +1,18 @@ +// Generated by hobgoblin. + package org.zwobble.hobgoblin.compiler.ast.typed; -public sealed interface TypedNamespaceStatementNode extends TypedNode permits TypedEnumDefinitionNode, TypedNativeTypeDefinitionNode, TypedStructDefinitionNode, TypedSumDefinitionNode { +// Custom area start: org.zwobble.hobgoblin.compiler.ast.typed.TypedNamespaceStatementNode imports +// Custom area end: org.zwobble.hobgoblin.compiler.ast.typed.TypedNamespaceStatementNode imports + +public sealed interface TypedNamespaceStatementNode permits org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumDefinitionNode, org.zwobble.hobgoblin.compiler.ast.typed.TypedNativeTypeDefinitionNode, org.zwobble.hobgoblin.compiler.ast.typed.TypedStructDefinitionNode, org.zwobble.hobgoblin.compiler.ast.typed.TypedSumDefinitionNode { + public interface Builder { + public org.zwobble.hobgoblin.compiler.ast.typed.TypedNamespaceStatementNode build(); + + // Custom area start: org.zwobble.hobgoblin.compiler.ast.typed.TypedNamespaceStatementNode.Builder body + // Custom area end: org.zwobble.hobgoblin.compiler.ast.typed.TypedNamespaceStatementNode.Builder body + } + + // Custom area start: org.zwobble.hobgoblin.compiler.ast.typed.TypedNamespaceStatementNode body + // Custom area end: org.zwobble.hobgoblin.compiler.ast.typed.TypedNamespaceStatementNode body } diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedNativeTypeDefinitionNode.java b/src/main/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedNativeTypeDefinitionNode.java index 487a80b..933660a 100644 --- a/src/main/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedNativeTypeDefinitionNode.java +++ b/src/main/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedNativeTypeDefinitionNode.java @@ -1,16 +1,46 @@ +// Generated by hobgoblin. + package org.zwobble.hobgoblin.compiler.ast.typed; -import org.zwobble.hobgoblin.compiler.ast.DocComment; -import org.zwobble.hobgoblin.compiler.sources.Source; -import org.zwobble.hobgoblin.compiler.types.SimpleNativeType; -import org.zwobble.hobgoblin.compiler.types.TypeOrConstructor; +// Custom area start: org.zwobble.hobgoblin.compiler.ast.typed.TypedNativeTypeDefinitionNode imports +// Custom area end: org.zwobble.hobgoblin.compiler.ast.typed.TypedNativeTypeDefinitionNode imports public record TypedNativeTypeDefinitionNode( - TypeOrConstructor<SimpleNativeType> typeOrConstructor, - DocComment docComment, - Source source -) implements TypedNamespaceStatementNode { - public String name() { - return this.typeOrConstructor.name(); + org.zwobble.hobgoblin.compiler.types.TypeOrConstructor<org.zwobble.hobgoblin.compiler.types.SimpleNativeType> typeOrConstructor, + 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.TypedNativeTypeDefinitionNode.Builder arbitrary() { + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedNativeTypeDefinitionNode.Builder(org.zwobble.hobgoblin.compiler.types.HobgoblinNativeTypes.arbitraryTypeOrConstructor(() -> { + return org.zwobble.hobgoblin.compiler.types.HobgoblinNativeTypes.arbitrarySimpleNativeType(); + }), org.zwobble.hobgoblin.compiler.ast.HobgoblinNativeAst.arbitraryDocComment(), org.zwobble.hobgoblin.compiler.sources.HobgoblinNativeSources.arbitrarySource()); + } + + public record Builder( + org.zwobble.hobgoblin.compiler.types.TypeOrConstructor<org.zwobble.hobgoblin.compiler.types.SimpleNativeType> typeOrConstructor, + 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.TypedNativeTypeDefinitionNode build() { + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedNativeTypeDefinitionNode(typeOrConstructor, docComment, source); + } + + public org.zwobble.hobgoblin.compiler.ast.typed.TypedNativeTypeDefinitionNode.Builder withTypeOrConstructor(org.zwobble.hobgoblin.compiler.types.TypeOrConstructor<org.zwobble.hobgoblin.compiler.types.SimpleNativeType> typeOrConstructor) { + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedNativeTypeDefinitionNode.Builder(typeOrConstructor, docComment, source); + } + + public org.zwobble.hobgoblin.compiler.ast.typed.TypedNativeTypeDefinitionNode.Builder withDocComment(org.zwobble.hobgoblin.compiler.ast.DocComment docComment) { + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedNativeTypeDefinitionNode.Builder(typeOrConstructor, docComment, source); + } + + public org.zwobble.hobgoblin.compiler.ast.typed.TypedNativeTypeDefinitionNode.Builder withSource(org.zwobble.hobgoblin.compiler.sources.Source source) { + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedNativeTypeDefinitionNode.Builder(typeOrConstructor, docComment, source); + } + + // Custom area start: org.zwobble.hobgoblin.compiler.ast.typed.TypedNativeTypeDefinitionNode.Builder body + // Custom area end: org.zwobble.hobgoblin.compiler.ast.typed.TypedNativeTypeDefinitionNode.Builder body } + + // Custom area start: org.zwobble.hobgoblin.compiler.ast.typed.TypedNativeTypeDefinitionNode body + // Custom area end: org.zwobble.hobgoblin.compiler.ast.typed.TypedNativeTypeDefinitionNode body } diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedStructDefinitionNode.java b/src/main/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedStructDefinitionNode.java index f747e44..c88c3dc 100644 --- a/src/main/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedStructDefinitionNode.java +++ b/src/main/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedStructDefinitionNode.java @@ -1,20 +1,59 @@ -package org.zwobble.hobgoblin.compiler.ast.typed; +// Generated by hobgoblin. -import org.zwobble.hobgoblin.compiler.ast.DocComment; -import org.zwobble.hobgoblin.compiler.sources.Source; -import org.zwobble.hobgoblin.compiler.types.SimpleStructType; -import org.zwobble.hobgoblin.compiler.types.TypeOrConstructor; +package org.zwobble.hobgoblin.compiler.ast.typed; -import java.util.List; -import java.util.Optional; +// Custom area start: org.zwobble.hobgoblin.compiler.ast.typed.TypedStructDefinitionNode imports +// Custom area end: org.zwobble.hobgoblin.compiler.ast.typed.TypedStructDefinitionNode imports public record TypedStructDefinitionNode( - TypeOrConstructor<SimpleStructType> typeOrConstructor, - Optional<List<TypedStructFieldDefinitionNode>> fields, - DocComment docComment, - Source source -) implements TypedNamespaceStatementNode { + org.zwobble.hobgoblin.compiler.types.TypeOrConstructor<org.zwobble.hobgoblin.compiler.types.SimpleStructType> typeOrConstructor, + java.util.Optional<java.util.List<org.zwobble.hobgoblin.compiler.ast.typed.TypedStructFieldDefinitionNode>> fields, + 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.TypedStructDefinitionNode.Builder arbitrary() { + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedStructDefinitionNode.Builder(org.zwobble.hobgoblin.compiler.types.HobgoblinNativeTypes.arbitraryTypeOrConstructor(() -> { + return org.zwobble.hobgoblin.compiler.types.HobgoblinNativeTypes.arbitrarySimpleStructType(); + }), java.util.Optional.empty(), org.zwobble.hobgoblin.compiler.ast.HobgoblinNativeAst.arbitraryDocComment(), org.zwobble.hobgoblin.compiler.sources.HobgoblinNativeSources.arbitrarySource()); + } + + public record Builder( + org.zwobble.hobgoblin.compiler.types.TypeOrConstructor<org.zwobble.hobgoblin.compiler.types.SimpleStructType> typeOrConstructor, + java.util.Optional<java.util.List<org.zwobble.hobgoblin.compiler.ast.typed.TypedStructFieldDefinitionNode>> fields, + 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.TypedStructDefinitionNode build() { + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedStructDefinitionNode(typeOrConstructor, fields, docComment, source); + } + + public org.zwobble.hobgoblin.compiler.ast.typed.TypedStructDefinitionNode.Builder withTypeOrConstructor(org.zwobble.hobgoblin.compiler.types.TypeOrConstructor<org.zwobble.hobgoblin.compiler.types.SimpleStructType> typeOrConstructor) { + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedStructDefinitionNode.Builder(typeOrConstructor, fields, docComment, source); + } + + public org.zwobble.hobgoblin.compiler.ast.typed.TypedStructDefinitionNode.Builder withFields(java.util.Optional<java.util.List<org.zwobble.hobgoblin.compiler.ast.typed.TypedStructFieldDefinitionNode>> fields) { + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedStructDefinitionNode.Builder(typeOrConstructor, fields, docComment, source); + } + + public org.zwobble.hobgoblin.compiler.ast.typed.TypedStructDefinitionNode.Builder withFields(java.util.List<org.zwobble.hobgoblin.compiler.ast.typed.TypedStructFieldDefinitionNode> fields) { + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedStructDefinitionNode.Builder(typeOrConstructor, java.util.Optional.of(fields), docComment, source); + } + + public org.zwobble.hobgoblin.compiler.ast.typed.TypedStructDefinitionNode.Builder withDocComment(org.zwobble.hobgoblin.compiler.ast.DocComment docComment) { + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedStructDefinitionNode.Builder(typeOrConstructor, fields, docComment, source); + } + + public org.zwobble.hobgoblin.compiler.ast.typed.TypedStructDefinitionNode.Builder withSource(org.zwobble.hobgoblin.compiler.sources.Source source) { + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedStructDefinitionNode.Builder(typeOrConstructor, fields, docComment, source); + } + + // Custom area start: org.zwobble.hobgoblin.compiler.ast.typed.TypedStructDefinitionNode.Builder body + // Custom area end: org.zwobble.hobgoblin.compiler.ast.typed.TypedStructDefinitionNode.Builder body + } + + // Custom area start: org.zwobble.hobgoblin.compiler.ast.typed.TypedStructDefinitionNode body public String name() { return this.typeOrConstructor.name(); } + // Custom area end: org.zwobble.hobgoblin.compiler.ast.typed.TypedStructDefinitionNode body } diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedStructFieldDefinitionNode.java b/src/main/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedStructFieldDefinitionNode.java index 739ea63..8824ffe 100644 --- a/src/main/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedStructFieldDefinitionNode.java +++ b/src/main/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedStructFieldDefinitionNode.java @@ -1,11 +1,44 @@ +// Generated by hobgoblin. + package org.zwobble.hobgoblin.compiler.ast.typed; -import org.zwobble.hobgoblin.compiler.sources.Source; -import org.zwobble.hobgoblin.compiler.types.Type; +// Custom area start: org.zwobble.hobgoblin.compiler.ast.typed.TypedStructFieldDefinitionNode imports +// Custom area end: org.zwobble.hobgoblin.compiler.ast.typed.TypedStructFieldDefinitionNode imports public record TypedStructFieldDefinitionNode( String name, - TypedTypeLevelExpressionNode<Type> type, - Source source -) implements TypedNode { + org.zwobble.hobgoblin.compiler.types.Type type, + org.zwobble.hobgoblin.compiler.sources.Source source +) { + public static org.zwobble.hobgoblin.compiler.ast.typed.TypedStructFieldDefinitionNode.Builder arbitrary() { + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedStructFieldDefinitionNode.Builder("", org.zwobble.hobgoblin.compiler.types.HobgoblinNativeTypes.arbitraryType(), org.zwobble.hobgoblin.compiler.sources.HobgoblinNativeSources.arbitrarySource()); + } + + public record Builder( + String name, + org.zwobble.hobgoblin.compiler.types.Type type, + org.zwobble.hobgoblin.compiler.sources.Source source + ) { + public org.zwobble.hobgoblin.compiler.ast.typed.TypedStructFieldDefinitionNode build() { + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedStructFieldDefinitionNode(name, type, source); + } + + public org.zwobble.hobgoblin.compiler.ast.typed.TypedStructFieldDefinitionNode.Builder withName(String name) { + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedStructFieldDefinitionNode.Builder(name, type, source); + } + + public org.zwobble.hobgoblin.compiler.ast.typed.TypedStructFieldDefinitionNode.Builder withType(org.zwobble.hobgoblin.compiler.types.Type type) { + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedStructFieldDefinitionNode.Builder(name, type, source); + } + + public org.zwobble.hobgoblin.compiler.ast.typed.TypedStructFieldDefinitionNode.Builder withSource(org.zwobble.hobgoblin.compiler.sources.Source source) { + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedStructFieldDefinitionNode.Builder(name, type, source); + } + + // Custom area start: org.zwobble.hobgoblin.compiler.ast.typed.TypedStructFieldDefinitionNode.Builder body + // Custom area end: org.zwobble.hobgoblin.compiler.ast.typed.TypedStructFieldDefinitionNode.Builder body + } + + // Custom area start: org.zwobble.hobgoblin.compiler.ast.typed.TypedStructFieldDefinitionNode body + // Custom area end: org.zwobble.hobgoblin.compiler.ast.typed.TypedStructFieldDefinitionNode body } diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedSumDefinitionNode.java b/src/main/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedSumDefinitionNode.java index 374befe..b5702ab 100644 --- a/src/main/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedSumDefinitionNode.java +++ b/src/main/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedSumDefinitionNode.java @@ -1,19 +1,83 @@ -package org.zwobble.hobgoblin.compiler.ast.typed; +// Generated by hobgoblin. -import org.zwobble.hobgoblin.compiler.ast.DocComment; -import org.zwobble.hobgoblin.compiler.sources.Source; -import org.zwobble.hobgoblin.compiler.types.SumType; +package org.zwobble.hobgoblin.compiler.ast.typed; -import java.util.List; +// Custom area start: org.zwobble.hobgoblin.compiler.ast.typed.TypedSumDefinitionNode imports +// Custom area end: org.zwobble.hobgoblin.compiler.ast.typed.TypedSumDefinitionNode imports public record TypedSumDefinitionNode( - SumType type, - List<TypedSumVariantDefinitionNode> variants, - List<TypedStructFieldDefinitionNode> fields, - DocComment docComment, - Source source -) implements TypedNamespaceStatementNode { + org.zwobble.hobgoblin.compiler.types.SumType type, + java.util.List<org.zwobble.hobgoblin.compiler.ast.typed.TypedSumVariantDefinitionNode> variants, + java.util.List<org.zwobble.hobgoblin.compiler.ast.typed.TypedStructFieldDefinitionNode> fields, + 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.TypedSumDefinitionNode.Builder arbitrary() { + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedSumDefinitionNode.Builder(org.zwobble.hobgoblin.compiler.types.HobgoblinNativeTypes.arbitrarySumType(), java.util.List.of(), java.util.List.of(), org.zwobble.hobgoblin.compiler.ast.HobgoblinNativeAst.arbitraryDocComment(), org.zwobble.hobgoblin.compiler.sources.HobgoblinNativeSources.arbitrarySource()); + } + + public record Builder( + org.zwobble.hobgoblin.compiler.types.SumType type, + java.util.List<org.zwobble.hobgoblin.compiler.ast.typed.TypedSumVariantDefinitionNode> variants, + java.util.List<org.zwobble.hobgoblin.compiler.ast.typed.TypedStructFieldDefinitionNode> fields, + 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.TypedSumDefinitionNode build() { + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedSumDefinitionNode(type, variants, fields, docComment, source); + } + + public org.zwobble.hobgoblin.compiler.ast.typed.TypedSumDefinitionNode.Builder withType(org.zwobble.hobgoblin.compiler.types.SumType type) { + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedSumDefinitionNode.Builder(type, variants, fields, docComment, source); + } + + public org.zwobble.hobgoblin.compiler.ast.typed.TypedSumDefinitionNode.Builder withVariants(java.util.List<org.zwobble.hobgoblin.compiler.ast.typed.TypedSumVariantDefinitionNode> variants) { + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedSumDefinitionNode.Builder(type, variants, fields, docComment, source); + } + + public org.zwobble.hobgoblin.compiler.ast.typed.TypedSumDefinitionNode.Builder addVariant(org.zwobble.hobgoblin.compiler.ast.typed.TypedSumVariantDefinitionNode variant) { + var variants = new java.util.ArrayList<org.zwobble.hobgoblin.compiler.ast.typed.TypedSumVariantDefinitionNode>(this.variants); + variants.add(variant); + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedSumDefinitionNode.Builder(type, variants, fields, docComment, source); + } + + public org.zwobble.hobgoblin.compiler.ast.typed.TypedSumDefinitionNode.Builder addVariant(org.zwobble.hobgoblin.compiler.ast.typed.TypedSumVariantDefinitionNode.Builder variant) { + var variants = new java.util.ArrayList<org.zwobble.hobgoblin.compiler.ast.typed.TypedSumVariantDefinitionNode>(this.variants); + variants.add(variant.build()); + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedSumDefinitionNode.Builder(type, variants, fields, docComment, source); + } + + public org.zwobble.hobgoblin.compiler.ast.typed.TypedSumDefinitionNode.Builder withFields(java.util.List<org.zwobble.hobgoblin.compiler.ast.typed.TypedStructFieldDefinitionNode> fields) { + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedSumDefinitionNode.Builder(type, variants, fields, docComment, source); + } + + public org.zwobble.hobgoblin.compiler.ast.typed.TypedSumDefinitionNode.Builder addField(org.zwobble.hobgoblin.compiler.ast.typed.TypedStructFieldDefinitionNode field) { + var fields = new java.util.ArrayList<org.zwobble.hobgoblin.compiler.ast.typed.TypedStructFieldDefinitionNode>(this.fields); + fields.add(field); + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedSumDefinitionNode.Builder(type, variants, fields, docComment, source); + } + + public org.zwobble.hobgoblin.compiler.ast.typed.TypedSumDefinitionNode.Builder addField(org.zwobble.hobgoblin.compiler.ast.typed.TypedStructFieldDefinitionNode.Builder field) { + var fields = new java.util.ArrayList<org.zwobble.hobgoblin.compiler.ast.typed.TypedStructFieldDefinitionNode>(this.fields); + fields.add(field.build()); + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedSumDefinitionNode.Builder(type, variants, fields, docComment, source); + } + + public org.zwobble.hobgoblin.compiler.ast.typed.TypedSumDefinitionNode.Builder withDocComment(org.zwobble.hobgoblin.compiler.ast.DocComment docComment) { + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedSumDefinitionNode.Builder(type, variants, fields, docComment, source); + } + + public org.zwobble.hobgoblin.compiler.ast.typed.TypedSumDefinitionNode.Builder withSource(org.zwobble.hobgoblin.compiler.sources.Source source) { + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedSumDefinitionNode.Builder(type, variants, fields, docComment, source); + } + + // Custom area start: org.zwobble.hobgoblin.compiler.ast.typed.TypedSumDefinitionNode.Builder body + // Custom area end: org.zwobble.hobgoblin.compiler.ast.typed.TypedSumDefinitionNode.Builder body + } + + // Custom area start: org.zwobble.hobgoblin.compiler.ast.typed.TypedSumDefinitionNode body public String name() { return this.type.name(); } + // Custom area end: org.zwobble.hobgoblin.compiler.ast.typed.TypedSumDefinitionNode body } diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedSumVariantDefinitionNode.java b/src/main/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedSumVariantDefinitionNode.java index 5c2dd6c..12235ad 100644 --- a/src/main/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedSumVariantDefinitionNode.java +++ b/src/main/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedSumVariantDefinitionNode.java @@ -1,10 +1,38 @@ +// Generated by hobgoblin. + package org.zwobble.hobgoblin.compiler.ast.typed; -import org.zwobble.hobgoblin.compiler.sources.Source; -import org.zwobble.hobgoblin.compiler.types.Type; +// Custom area start: org.zwobble.hobgoblin.compiler.ast.typed.TypedSumVariantDefinitionNode imports +// Custom area end: org.zwobble.hobgoblin.compiler.ast.typed.TypedSumVariantDefinitionNode imports public record TypedSumVariantDefinitionNode( - TypedTypeLevelExpressionNode<Type> type, - Source source -) implements TypedNode { + org.zwobble.hobgoblin.compiler.types.Type type, + org.zwobble.hobgoblin.compiler.sources.Source source +) { + public static org.zwobble.hobgoblin.compiler.ast.typed.TypedSumVariantDefinitionNode.Builder arbitrary() { + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedSumVariantDefinitionNode.Builder(org.zwobble.hobgoblin.compiler.types.HobgoblinNativeTypes.arbitraryType(), org.zwobble.hobgoblin.compiler.sources.HobgoblinNativeSources.arbitrarySource()); + } + + public record Builder( + org.zwobble.hobgoblin.compiler.types.Type type, + org.zwobble.hobgoblin.compiler.sources.Source source + ) { + public org.zwobble.hobgoblin.compiler.ast.typed.TypedSumVariantDefinitionNode build() { + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedSumVariantDefinitionNode(type, source); + } + + public org.zwobble.hobgoblin.compiler.ast.typed.TypedSumVariantDefinitionNode.Builder withType(org.zwobble.hobgoblin.compiler.types.Type type) { + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedSumVariantDefinitionNode.Builder(type, source); + } + + public org.zwobble.hobgoblin.compiler.ast.typed.TypedSumVariantDefinitionNode.Builder withSource(org.zwobble.hobgoblin.compiler.sources.Source source) { + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedSumVariantDefinitionNode.Builder(type, source); + } + + // Custom area start: org.zwobble.hobgoblin.compiler.ast.typed.TypedSumVariantDefinitionNode.Builder body + // Custom area end: org.zwobble.hobgoblin.compiler.ast.typed.TypedSumVariantDefinitionNode.Builder body + } + + // Custom area start: org.zwobble.hobgoblin.compiler.ast.typed.TypedSumVariantDefinitionNode body + // Custom area end: org.zwobble.hobgoblin.compiler.ast.typed.TypedSumVariantDefinitionNode body } diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/javapreciselymatchers/JavaPreciselyMatchersGenerator.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/javapreciselymatchers/JavaPreciselyMatchersGenerator.java index 6155a81..6eb3ac1 100644 --- a/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/javapreciselymatchers/JavaPreciselyMatchersGenerator.java +++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/javapreciselymatchers/JavaPreciselyMatchersGenerator.java @@ -246,7 +246,7 @@ public class JavaPreciselyMatchersGenerator implements Generator { )); for (var field : structDefinition.fields().orElse(List.of())) { - var fieldType = field.type().value(); + var fieldType = field.type(); var typeParams = switch (structDefinition.typeOrConstructor()) { case TypeOrConstructor.Constructor<SimpleStructType> constructor -> Set.copyOf(constructor.value().params()); diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/javatransient0/JavaTransient0Generator.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/javatransient0/JavaTransient0Generator.java index 8d6b2b6..40bfbdf 100644 --- a/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/javatransient0/JavaTransient0Generator.java +++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/javatransient0/JavaTransient0Generator.java @@ -761,7 +761,7 @@ public class JavaTransient0Generator implements Generator { this.javaGenerator.generateFieldName(field.name()), List.of() ), - field.type().value(), + field.type(), context ).stream()) .toList() @@ -790,7 +790,7 @@ public class JavaTransient0Generator implements Generator { structDefinition.fields().get().stream() .flatMap(field -> generateDecode( this.javaGenerator.generateFieldName(field.name()), - field.type().value(), + field.type(), context ).stream()), Stream.of(new JavaReturn(new JavaNewExpression( diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/javatypes/JavaTypesGenerator.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/javatypes/JavaTypesGenerator.java index 1112b67..01a05d0 100644 --- a/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/javatypes/JavaTypesGenerator.java +++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/javatypes/JavaTypesGenerator.java @@ -211,7 +211,7 @@ public class JavaTypesGenerator implements Generator { structDefinition.fields().orElse(List.of()).stream() .map(field -> { var arbitraryValue = ArbitraryValueAnalysis.arbitraryValue( - field.type().value(), + field.type(), context.typesInfo ); @@ -365,7 +365,7 @@ public class JavaTypesGenerator implements Generator { var javaFieldName = generateFieldName(field.name()); var withMethodName = generateFieldName("with" + lowerCamelCaseToUpperCamelCase(field.name())); - var fieldType = this.javaGenerator.collapseType(field.type().value()); + var fieldType = this.javaGenerator.collapseType(field.type()); methods.add(new JavaMethodDeclaration( withMethodName, @@ -581,7 +581,7 @@ public class JavaTypesGenerator implements Generator { JavaVisibility.PUBLIC, JavaMemberKind.INSTANCE, List.of(), - generateTypeRef(field.type().value(), context), + generateTypeRef(field.type(), context), List.of(), List.of(), Optional.empty() diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/rusttransient0/RustTransient0Generator.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/rusttransient0/RustTransient0Generator.java index 10b5c0a..6f6740c 100644 --- a/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/rusttransient0/RustTransient0Generator.java +++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/rusttransient0/RustTransient0Generator.java @@ -506,7 +506,7 @@ public class RustTransient0Generator implements Generator { this.rustGenerator.generateFieldName(field.name()) ) ), - field.type().value() + field.type() )) .toList(); @@ -533,7 +533,7 @@ public class RustTransient0Generator implements Generator { .<RustStatement>map(field -> new RustLetStatement( this.rustGenerator.generateFieldName(field.name()), false, - generateDecode(field.type().value()) + generateDecode(field.type()) )) .toList(), Optional.of(new RustStructExpression( diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/rusttypes/RustTypesGenerator.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/rusttypes/RustTypesGenerator.java index 0a62c64..634dbff 100644 --- a/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/rusttypes/RustTypesGenerator.java +++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/rusttypes/RustTypesGenerator.java @@ -264,8 +264,8 @@ public class RustTypesGenerator implements Generator { } private RustType generateRustTypeExpression( - TypedTypeLevelExpressionNode<Type> type + Type type ) { - return this.rustGenerator.generateRustTypeExpression(type.value()); + return this.rustGenerator.generateRustTypeExpression(type); } } diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/typescripttypes/TypescriptTypesGenerator.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/typescripttypes/TypescriptTypesGenerator.java index 508de55..10217fb 100644 --- a/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/typescripttypes/TypescriptTypesGenerator.java +++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/typescripttypes/TypescriptTypesGenerator.java @@ -278,7 +278,7 @@ public class TypescriptTypesGenerator implements Generator { false, true, Optional.of(this.typescriptGenerator.generateTypeExpression( - field.type().value(), + field.type(), context )), Optional.empty() @@ -309,7 +309,7 @@ public class TypescriptTypesGenerator implements Generator { .map(field -> new TypescriptParam( this.typescriptGenerator.generateFieldName(field.name()), Optional.of(this.typescriptGenerator.generateTypeExpression( - field.type().value(), + field.type(), context )) )) @@ -351,7 +351,7 @@ public class TypescriptTypesGenerator implements Generator { new TypescriptTypeUnion( sumDefinition.variants().stream() .map(variant -> this.typescriptGenerator.generateTypeExpression( - variant.type().value(), + variant.type(), context )) .toList() 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 b991a1c..2a09a7e 100644 --- a/src/main/java/org/zwobble/hobgoblin/compiler/typechecker/TypeChecker.java +++ b/src/main/java/org/zwobble/hobgoblin/compiler/typechecker/TypeChecker.java @@ -304,7 +304,7 @@ public class TypeChecker { var fieldType = typeCheckMetaType(untypedField.type(), context); var typedField = new TypedStructFieldDefinitionNode( untypedField.name(), - fieldType, + fieldType.value(), untypedField.source() ); typedFields.add(typedField); @@ -334,7 +334,7 @@ public class TypeChecker { for (var untypedVariant : untyped.variants()) { var variantType = typeCheckMetaType(untypedVariant.type(), context); var typedVariant = new TypedSumVariantDefinitionNode( - variantType, + variantType.value(), untyped.source() ); typedVariants.add(typedVariant); diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/types/HobgoblinNativeTypes.java b/src/main/java/org/zwobble/hobgoblin/compiler/types/HobgoblinNativeTypes.java index c08157d..14294f9 100644 --- a/src/main/java/org/zwobble/hobgoblin/compiler/types/HobgoblinNativeTypes.java +++ b/src/main/java/org/zwobble/hobgoblin/compiler/types/HobgoblinNativeTypes.java @@ -1,7 +1,33 @@ package org.zwobble.hobgoblin.compiler.types; +import java.util.function.Supplier; + public class HobgoblinNativeTypes { public static NamespaceName arbitraryNamespaceName() { return NamespaceName.of(); } + + public static Type arbitraryType() { + return arbitraryEnumType(); + } + + public static EnumType arbitraryEnumType() { + return new EnumType(arbitraryNamespaceName(), ""); + } + + public static SimpleNativeType arbitrarySimpleNativeType() { + return new SimpleNativeType(arbitraryNamespaceName(), ""); + } + + public static SimpleStructType arbitrarySimpleStructType() { + return new SimpleStructType(arbitraryNamespaceName(), ""); + } + + public static SumType arbitrarySumType() { + return new SumType(arbitraryNamespaceName(), ""); + } + + public static <T extends ConstructibleType> TypeOrConstructor<T> arbitraryTypeOrConstructor(Supplier<T> type) { + return TypeOrConstructor.type(type.get()); + } } diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedEnumDefinitionNodeMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedEnumDefinitionNodeMatcher.java new file mode 100644 index 0000000..3839c4a --- /dev/null +++ b/src/test/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedEnumDefinitionNodeMatcher.java @@ -0,0 +1,59 @@ +// Generated by hobgoblin. + +package org.zwobble.hobgoblin.compiler.ast.typed; + +// Custom area start: org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumDefinitionNodeMatcher imports +// Custom area end: org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumDefinitionNodeMatcher imports + +public final class TypedEnumDefinitionNodeMatcher implements org.zwobble.precisely.Matcher<java.lang.Object> { + public static org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumDefinitionNodeMatcher isTypedEnumDefinitionNode() { + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumDefinitionNodeMatcher(java.util.List.of()); + } + + private final java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumDefinitionNode>> submatchers; + + private TypedEnumDefinitionNodeMatcher( + java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumDefinitionNode>> 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.TypedEnumDefinitionNode.class, this.submatchers); + } + + public org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumDefinitionNodeMatcher withType(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.types.EnumType> type) { + var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumDefinitionNode>>(this.submatchers); + submatchers.add(org.zwobble.precisely.Matchers.has("type", org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumDefinitionNode::type, (org.zwobble.precisely.Matcher) type)); + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumDefinitionNodeMatcher(submatchers); + } + + public org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumDefinitionNodeMatcher withVariants(org.zwobble.precisely.Matcher<? super java.util.List<org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumVariantDefinitionNode>> variants) { + var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumDefinitionNode>>(this.submatchers); + submatchers.add(org.zwobble.precisely.Matchers.has("variants", org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumDefinitionNode::variants, (org.zwobble.precisely.Matcher) variants)); + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumDefinitionNodeMatcher(submatchers); + } + + public org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumDefinitionNodeMatcher withDocComment(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.ast.DocComment> docComment) { + var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumDefinitionNode>>(this.submatchers); + submatchers.add(org.zwobble.precisely.Matchers.has("docComment", org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumDefinitionNode::docComment, (org.zwobble.precisely.Matcher) docComment)); + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumDefinitionNodeMatcher(submatchers); + } + + public org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumDefinitionNodeMatcher withSource(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.sources.Source> source) { + var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumDefinitionNode>>(this.submatchers); + submatchers.add(org.zwobble.precisely.Matchers.has("source", org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumDefinitionNode::source, (org.zwobble.precisely.Matcher) source)); + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumDefinitionNodeMatcher(submatchers); + } + + // Custom area start: org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumDefinitionNodeMatcher body + // Custom area end: org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumDefinitionNodeMatcher body +} diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedEnumVariantDefinitionNodeMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedEnumVariantDefinitionNodeMatcher.java new file mode 100644 index 0000000..5d3822d --- /dev/null +++ b/src/test/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedEnumVariantDefinitionNodeMatcher.java @@ -0,0 +1,47 @@ +// Generated by hobgoblin. + +package org.zwobble.hobgoblin.compiler.ast.typed; + +// Custom area start: org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumVariantDefinitionNodeMatcher imports +// Custom area end: org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumVariantDefinitionNodeMatcher imports + +public final class TypedEnumVariantDefinitionNodeMatcher implements org.zwobble.precisely.Matcher<java.lang.Object> { + public static org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumVariantDefinitionNodeMatcher isTypedEnumVariantDefinitionNode() { + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumVariantDefinitionNodeMatcher(java.util.List.of()); + } + + private final java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumVariantDefinitionNode>> submatchers; + + private TypedEnumVariantDefinitionNodeMatcher( + java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumVariantDefinitionNode>> 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.TypedEnumVariantDefinitionNode.class, this.submatchers); + } + + public org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumVariantDefinitionNodeMatcher withName(org.zwobble.precisely.Matcher<? super String> name) { + var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumVariantDefinitionNode>>(this.submatchers); + submatchers.add(org.zwobble.precisely.Matchers.has("name", org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumVariantDefinitionNode::name, (org.zwobble.precisely.Matcher) name)); + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumVariantDefinitionNodeMatcher(submatchers); + } + + public org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumVariantDefinitionNodeMatcher withSource(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.sources.Source> source) { + var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumVariantDefinitionNode>>(this.submatchers); + submatchers.add(org.zwobble.precisely.Matchers.has("source", org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumVariantDefinitionNode::source, (org.zwobble.precisely.Matcher) source)); + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumVariantDefinitionNodeMatcher(submatchers); + } + + // Custom area start: org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumVariantDefinitionNodeMatcher body + // Custom area end: org.zwobble.hobgoblin.compiler.ast.typed.TypedEnumVariantDefinitionNodeMatcher body +} diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedNamespaceNodeMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedNamespaceNodeMatcher.java new file mode 100644 index 0000000..2b19bd0 --- /dev/null +++ b/src/test/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedNamespaceNodeMatcher.java @@ -0,0 +1,53 @@ +// Generated by hobgoblin. + +package org.zwobble.hobgoblin.compiler.ast.typed; + +// Custom area start: org.zwobble.hobgoblin.compiler.ast.typed.TypedNamespaceNodeMatcher imports +// Custom area end: org.zwobble.hobgoblin.compiler.ast.typed.TypedNamespaceNodeMatcher imports + +public final class TypedNamespaceNodeMatcher implements org.zwobble.precisely.Matcher<java.lang.Object> { + public static org.zwobble.hobgoblin.compiler.ast.typed.TypedNamespaceNodeMatcher isTypedNamespaceNode() { + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedNamespaceNodeMatcher(java.util.List.of()); + } + + private final java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.ast.typed.TypedNamespaceNode>> submatchers; + + private TypedNamespaceNodeMatcher( + java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.ast.typed.TypedNamespaceNode>> 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.TypedNamespaceNode.class, this.submatchers); + } + + public org.zwobble.hobgoblin.compiler.ast.typed.TypedNamespaceNodeMatcher withNamespaceName(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.types.NamespaceName> namespaceName) { + var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.ast.typed.TypedNamespaceNode>>(this.submatchers); + submatchers.add(org.zwobble.precisely.Matchers.has("namespaceName", org.zwobble.hobgoblin.compiler.ast.typed.TypedNamespaceNode::namespaceName, (org.zwobble.precisely.Matcher) namespaceName)); + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedNamespaceNodeMatcher(submatchers); + } + + public org.zwobble.hobgoblin.compiler.ast.typed.TypedNamespaceNodeMatcher withBody(org.zwobble.precisely.Matcher<? super java.util.List<org.zwobble.hobgoblin.compiler.ast.typed.TypedNamespaceStatementNode>> body) { + var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.ast.typed.TypedNamespaceNode>>(this.submatchers); + submatchers.add(org.zwobble.precisely.Matchers.has("body", org.zwobble.hobgoblin.compiler.ast.typed.TypedNamespaceNode::body, (org.zwobble.precisely.Matcher) body)); + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedNamespaceNodeMatcher(submatchers); + } + + public org.zwobble.hobgoblin.compiler.ast.typed.TypedNamespaceNodeMatcher withSource(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.sources.Source> source) { + var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.ast.typed.TypedNamespaceNode>>(this.submatchers); + submatchers.add(org.zwobble.precisely.Matchers.has("source", org.zwobble.hobgoblin.compiler.ast.typed.TypedNamespaceNode::source, (org.zwobble.precisely.Matcher) source)); + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedNamespaceNodeMatcher(submatchers); + } + + // Custom area start: org.zwobble.hobgoblin.compiler.ast.typed.TypedNamespaceNodeMatcher body + // Custom area end: org.zwobble.hobgoblin.compiler.ast.typed.TypedNamespaceNodeMatcher body +} diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedNativeTypeDefinitionNodeMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedNativeTypeDefinitionNodeMatcher.java new file mode 100644 index 0000000..c9c96ff --- /dev/null +++ b/src/test/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedNativeTypeDefinitionNodeMatcher.java @@ -0,0 +1,53 @@ +// Generated by hobgoblin. + +package org.zwobble.hobgoblin.compiler.ast.typed; + +// Custom area start: org.zwobble.hobgoblin.compiler.ast.typed.TypedNativeTypeDefinitionNodeMatcher imports +// Custom area end: org.zwobble.hobgoblin.compiler.ast.typed.TypedNativeTypeDefinitionNodeMatcher imports + +public final class TypedNativeTypeDefinitionNodeMatcher implements org.zwobble.precisely.Matcher<java.lang.Object> { + public static org.zwobble.hobgoblin.compiler.ast.typed.TypedNativeTypeDefinitionNodeMatcher isTypedNativeTypeDefinitionNode() { + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedNativeTypeDefinitionNodeMatcher(java.util.List.of()); + } + + private final java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.ast.typed.TypedNativeTypeDefinitionNode>> submatchers; + + private TypedNativeTypeDefinitionNodeMatcher( + java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.ast.typed.TypedNativeTypeDefinitionNode>> 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.TypedNativeTypeDefinitionNode.class, this.submatchers); + } + + public org.zwobble.hobgoblin.compiler.ast.typed.TypedNativeTypeDefinitionNodeMatcher withTypeOrConstructor(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.types.TypeOrConstructor<org.zwobble.hobgoblin.compiler.types.SimpleNativeType>> typeOrConstructor) { + var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.ast.typed.TypedNativeTypeDefinitionNode>>(this.submatchers); + submatchers.add(org.zwobble.precisely.Matchers.has("typeOrConstructor", org.zwobble.hobgoblin.compiler.ast.typed.TypedNativeTypeDefinitionNode::typeOrConstructor, (org.zwobble.precisely.Matcher) typeOrConstructor)); + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedNativeTypeDefinitionNodeMatcher(submatchers); + } + + public org.zwobble.hobgoblin.compiler.ast.typed.TypedNativeTypeDefinitionNodeMatcher withDocComment(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.ast.DocComment> docComment) { + var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.ast.typed.TypedNativeTypeDefinitionNode>>(this.submatchers); + submatchers.add(org.zwobble.precisely.Matchers.has("docComment", org.zwobble.hobgoblin.compiler.ast.typed.TypedNativeTypeDefinitionNode::docComment, (org.zwobble.precisely.Matcher) docComment)); + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedNativeTypeDefinitionNodeMatcher(submatchers); + } + + public org.zwobble.hobgoblin.compiler.ast.typed.TypedNativeTypeDefinitionNodeMatcher withSource(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.sources.Source> source) { + var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.ast.typed.TypedNativeTypeDefinitionNode>>(this.submatchers); + submatchers.add(org.zwobble.precisely.Matchers.has("source", org.zwobble.hobgoblin.compiler.ast.typed.TypedNativeTypeDefinitionNode::source, (org.zwobble.precisely.Matcher) source)); + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedNativeTypeDefinitionNodeMatcher(submatchers); + } + + // Custom area start: org.zwobble.hobgoblin.compiler.ast.typed.TypedNativeTypeDefinitionNodeMatcher body + // Custom area end: org.zwobble.hobgoblin.compiler.ast.typed.TypedNativeTypeDefinitionNodeMatcher body +} diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedStructDefinitionNodeMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedStructDefinitionNodeMatcher.java new file mode 100644 index 0000000..e9f44bd --- /dev/null +++ b/src/test/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedStructDefinitionNodeMatcher.java @@ -0,0 +1,59 @@ +// Generated by hobgoblin. + +package org.zwobble.hobgoblin.compiler.ast.typed; + +// Custom area start: org.zwobble.hobgoblin.compiler.ast.typed.TypedStructDefinitionNodeMatcher imports +// Custom area end: org.zwobble.hobgoblin.compiler.ast.typed.TypedStructDefinitionNodeMatcher imports + +public final class TypedStructDefinitionNodeMatcher implements org.zwobble.precisely.Matcher<java.lang.Object> { + public static org.zwobble.hobgoblin.compiler.ast.typed.TypedStructDefinitionNodeMatcher isTypedStructDefinitionNode() { + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedStructDefinitionNodeMatcher(java.util.List.of()); + } + + private final java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.ast.typed.TypedStructDefinitionNode>> submatchers; + + private TypedStructDefinitionNodeMatcher( + java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.ast.typed.TypedStructDefinitionNode>> 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.TypedStructDefinitionNode.class, this.submatchers); + } + + public org.zwobble.hobgoblin.compiler.ast.typed.TypedStructDefinitionNodeMatcher withTypeOrConstructor(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.types.TypeOrConstructor<org.zwobble.hobgoblin.compiler.types.SimpleStructType>> typeOrConstructor) { + var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.ast.typed.TypedStructDefinitionNode>>(this.submatchers); + submatchers.add(org.zwobble.precisely.Matchers.has("typeOrConstructor", org.zwobble.hobgoblin.compiler.ast.typed.TypedStructDefinitionNode::typeOrConstructor, (org.zwobble.precisely.Matcher) typeOrConstructor)); + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedStructDefinitionNodeMatcher(submatchers); + } + + public org.zwobble.hobgoblin.compiler.ast.typed.TypedStructDefinitionNodeMatcher withFields(org.zwobble.precisely.Matcher<? super java.util.Optional<java.util.List<org.zwobble.hobgoblin.compiler.ast.typed.TypedStructFieldDefinitionNode>>> fields) { + var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.ast.typed.TypedStructDefinitionNode>>(this.submatchers); + submatchers.add(org.zwobble.precisely.Matchers.has("fields", org.zwobble.hobgoblin.compiler.ast.typed.TypedStructDefinitionNode::fields, (org.zwobble.precisely.Matcher) fields)); + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedStructDefinitionNodeMatcher(submatchers); + } + + public org.zwobble.hobgoblin.compiler.ast.typed.TypedStructDefinitionNodeMatcher withDocComment(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.ast.DocComment> docComment) { + var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.ast.typed.TypedStructDefinitionNode>>(this.submatchers); + submatchers.add(org.zwobble.precisely.Matchers.has("docComment", org.zwobble.hobgoblin.compiler.ast.typed.TypedStructDefinitionNode::docComment, (org.zwobble.precisely.Matcher) docComment)); + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedStructDefinitionNodeMatcher(submatchers); + } + + public org.zwobble.hobgoblin.compiler.ast.typed.TypedStructDefinitionNodeMatcher withSource(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.sources.Source> source) { + var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.ast.typed.TypedStructDefinitionNode>>(this.submatchers); + submatchers.add(org.zwobble.precisely.Matchers.has("source", org.zwobble.hobgoblin.compiler.ast.typed.TypedStructDefinitionNode::source, (org.zwobble.precisely.Matcher) source)); + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedStructDefinitionNodeMatcher(submatchers); + } + + // Custom area start: org.zwobble.hobgoblin.compiler.ast.typed.TypedStructDefinitionNodeMatcher body + // Custom area end: org.zwobble.hobgoblin.compiler.ast.typed.TypedStructDefinitionNodeMatcher body +} diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedStructFieldDefinitionNodeMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedStructFieldDefinitionNodeMatcher.java new file mode 100644 index 0000000..11760f9 --- /dev/null +++ b/src/test/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedStructFieldDefinitionNodeMatcher.java @@ -0,0 +1,53 @@ +// Generated by hobgoblin. + +package org.zwobble.hobgoblin.compiler.ast.typed; + +// Custom area start: org.zwobble.hobgoblin.compiler.ast.typed.TypedStructFieldDefinitionNodeMatcher imports +// Custom area end: org.zwobble.hobgoblin.compiler.ast.typed.TypedStructFieldDefinitionNodeMatcher imports + +public final class TypedStructFieldDefinitionNodeMatcher implements org.zwobble.precisely.Matcher<java.lang.Object> { + public static org.zwobble.hobgoblin.compiler.ast.typed.TypedStructFieldDefinitionNodeMatcher isTypedStructFieldDefinitionNode() { + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedStructFieldDefinitionNodeMatcher(java.util.List.of()); + } + + private final java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.ast.typed.TypedStructFieldDefinitionNode>> submatchers; + + private TypedStructFieldDefinitionNodeMatcher( + java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.ast.typed.TypedStructFieldDefinitionNode>> 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.TypedStructFieldDefinitionNode.class, this.submatchers); + } + + public org.zwobble.hobgoblin.compiler.ast.typed.TypedStructFieldDefinitionNodeMatcher withName(org.zwobble.precisely.Matcher<? super String> name) { + var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.ast.typed.TypedStructFieldDefinitionNode>>(this.submatchers); + submatchers.add(org.zwobble.precisely.Matchers.has("name", org.zwobble.hobgoblin.compiler.ast.typed.TypedStructFieldDefinitionNode::name, (org.zwobble.precisely.Matcher) name)); + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedStructFieldDefinitionNodeMatcher(submatchers); + } + + public org.zwobble.hobgoblin.compiler.ast.typed.TypedStructFieldDefinitionNodeMatcher withType(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.types.Type> type) { + var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.ast.typed.TypedStructFieldDefinitionNode>>(this.submatchers); + submatchers.add(org.zwobble.precisely.Matchers.has("type", org.zwobble.hobgoblin.compiler.ast.typed.TypedStructFieldDefinitionNode::type, (org.zwobble.precisely.Matcher) type)); + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedStructFieldDefinitionNodeMatcher(submatchers); + } + + public org.zwobble.hobgoblin.compiler.ast.typed.TypedStructFieldDefinitionNodeMatcher withSource(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.sources.Source> source) { + var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.ast.typed.TypedStructFieldDefinitionNode>>(this.submatchers); + submatchers.add(org.zwobble.precisely.Matchers.has("source", org.zwobble.hobgoblin.compiler.ast.typed.TypedStructFieldDefinitionNode::source, (org.zwobble.precisely.Matcher) source)); + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedStructFieldDefinitionNodeMatcher(submatchers); + } + + // Custom area start: org.zwobble.hobgoblin.compiler.ast.typed.TypedStructFieldDefinitionNodeMatcher body + // Custom area end: org.zwobble.hobgoblin.compiler.ast.typed.TypedStructFieldDefinitionNodeMatcher body +} diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedSumDefinitionNodeMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedSumDefinitionNodeMatcher.java new file mode 100644 index 0000000..d52472a --- /dev/null +++ b/src/test/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedSumDefinitionNodeMatcher.java @@ -0,0 +1,65 @@ +// Generated by hobgoblin. + +package org.zwobble.hobgoblin.compiler.ast.typed; + +// Custom area start: org.zwobble.hobgoblin.compiler.ast.typed.TypedSumDefinitionNodeMatcher imports +// Custom area end: org.zwobble.hobgoblin.compiler.ast.typed.TypedSumDefinitionNodeMatcher imports + +public final class TypedSumDefinitionNodeMatcher implements org.zwobble.precisely.Matcher<java.lang.Object> { + public static org.zwobble.hobgoblin.compiler.ast.typed.TypedSumDefinitionNodeMatcher isTypedSumDefinitionNode() { + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedSumDefinitionNodeMatcher(java.util.List.of()); + } + + private final java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.ast.typed.TypedSumDefinitionNode>> submatchers; + + private TypedSumDefinitionNodeMatcher( + java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.ast.typed.TypedSumDefinitionNode>> 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.TypedSumDefinitionNode.class, this.submatchers); + } + + public org.zwobble.hobgoblin.compiler.ast.typed.TypedSumDefinitionNodeMatcher withType(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.types.SumType> type) { + var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.ast.typed.TypedSumDefinitionNode>>(this.submatchers); + submatchers.add(org.zwobble.precisely.Matchers.has("type", org.zwobble.hobgoblin.compiler.ast.typed.TypedSumDefinitionNode::type, (org.zwobble.precisely.Matcher) type)); + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedSumDefinitionNodeMatcher(submatchers); + } + + public org.zwobble.hobgoblin.compiler.ast.typed.TypedSumDefinitionNodeMatcher withVariants(org.zwobble.precisely.Matcher<? super java.util.List<org.zwobble.hobgoblin.compiler.ast.typed.TypedSumVariantDefinitionNode>> variants) { + var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.ast.typed.TypedSumDefinitionNode>>(this.submatchers); + submatchers.add(org.zwobble.precisely.Matchers.has("variants", org.zwobble.hobgoblin.compiler.ast.typed.TypedSumDefinitionNode::variants, (org.zwobble.precisely.Matcher) variants)); + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedSumDefinitionNodeMatcher(submatchers); + } + + public org.zwobble.hobgoblin.compiler.ast.typed.TypedSumDefinitionNodeMatcher withFields(org.zwobble.precisely.Matcher<? super java.util.List<org.zwobble.hobgoblin.compiler.ast.typed.TypedStructFieldDefinitionNode>> fields) { + var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.ast.typed.TypedSumDefinitionNode>>(this.submatchers); + submatchers.add(org.zwobble.precisely.Matchers.has("fields", org.zwobble.hobgoblin.compiler.ast.typed.TypedSumDefinitionNode::fields, (org.zwobble.precisely.Matcher) fields)); + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedSumDefinitionNodeMatcher(submatchers); + } + + public org.zwobble.hobgoblin.compiler.ast.typed.TypedSumDefinitionNodeMatcher withDocComment(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.ast.DocComment> docComment) { + var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.ast.typed.TypedSumDefinitionNode>>(this.submatchers); + submatchers.add(org.zwobble.precisely.Matchers.has("docComment", org.zwobble.hobgoblin.compiler.ast.typed.TypedSumDefinitionNode::docComment, (org.zwobble.precisely.Matcher) docComment)); + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedSumDefinitionNodeMatcher(submatchers); + } + + public org.zwobble.hobgoblin.compiler.ast.typed.TypedSumDefinitionNodeMatcher withSource(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.sources.Source> source) { + var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.ast.typed.TypedSumDefinitionNode>>(this.submatchers); + submatchers.add(org.zwobble.precisely.Matchers.has("source", org.zwobble.hobgoblin.compiler.ast.typed.TypedSumDefinitionNode::source, (org.zwobble.precisely.Matcher) source)); + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedSumDefinitionNodeMatcher(submatchers); + } + + // Custom area start: org.zwobble.hobgoblin.compiler.ast.typed.TypedSumDefinitionNodeMatcher body + // Custom area end: org.zwobble.hobgoblin.compiler.ast.typed.TypedSumDefinitionNodeMatcher body +} diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedSumVariantDefinitionNodeMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedSumVariantDefinitionNodeMatcher.java new file mode 100644 index 0000000..25d2051 --- /dev/null +++ b/src/test/java/org/zwobble/hobgoblin/compiler/ast/typed/TypedSumVariantDefinitionNodeMatcher.java @@ -0,0 +1,47 @@ +// Generated by hobgoblin. + +package org.zwobble.hobgoblin.compiler.ast.typed; + +// Custom area start: org.zwobble.hobgoblin.compiler.ast.typed.TypedSumVariantDefinitionNodeMatcher imports +// Custom area end: org.zwobble.hobgoblin.compiler.ast.typed.TypedSumVariantDefinitionNodeMatcher imports + +public final class TypedSumVariantDefinitionNodeMatcher implements org.zwobble.precisely.Matcher<java.lang.Object> { + public static org.zwobble.hobgoblin.compiler.ast.typed.TypedSumVariantDefinitionNodeMatcher isTypedSumVariantDefinitionNode() { + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedSumVariantDefinitionNodeMatcher(java.util.List.of()); + } + + private final java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.ast.typed.TypedSumVariantDefinitionNode>> submatchers; + + private TypedSumVariantDefinitionNodeMatcher( + java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.ast.typed.TypedSumVariantDefinitionNode>> 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.TypedSumVariantDefinitionNode.class, this.submatchers); + } + + public org.zwobble.hobgoblin.compiler.ast.typed.TypedSumVariantDefinitionNodeMatcher withType(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.types.Type> type) { + var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.ast.typed.TypedSumVariantDefinitionNode>>(this.submatchers); + submatchers.add(org.zwobble.precisely.Matchers.has("type", org.zwobble.hobgoblin.compiler.ast.typed.TypedSumVariantDefinitionNode::type, (org.zwobble.precisely.Matcher) type)); + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedSumVariantDefinitionNodeMatcher(submatchers); + } + + public org.zwobble.hobgoblin.compiler.ast.typed.TypedSumVariantDefinitionNodeMatcher withSource(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.sources.Source> source) { + var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.ast.typed.TypedSumVariantDefinitionNode>>(this.submatchers); + submatchers.add(org.zwobble.precisely.Matchers.has("source", org.zwobble.hobgoblin.compiler.ast.typed.TypedSumVariantDefinitionNode::source, (org.zwobble.precisely.Matcher) source)); + return new org.zwobble.hobgoblin.compiler.ast.typed.TypedSumVariantDefinitionNodeMatcher(submatchers); + } + + // Custom area start: org.zwobble.hobgoblin.compiler.ast.typed.TypedSumVariantDefinitionNodeMatcher body + // Custom area end: org.zwobble.hobgoblin.compiler.ast.typed.TypedSumVariantDefinitionNodeMatcher body +} diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/typechecker/TypeCheckerStructDefinitionTests.java b/src/test/java/org/zwobble/hobgoblin/compiler/typechecker/TypeCheckerStructDefinitionTests.java index fa913fa..f25a600 100644 --- a/src/test/java/org/zwobble/hobgoblin/compiler/typechecker/TypeCheckerStructDefinitionTests.java +++ b/src/test/java/org/zwobble/hobgoblin/compiler/typechecker/TypeCheckerStructDefinitionTests.java @@ -4,7 +4,6 @@ import org.junit.jupiter.api.Test; import org.zwobble.hobgoblin.compiler.ast.typed.TypedNamespaceNode; import org.zwobble.hobgoblin.compiler.ast.typed.TypedStructDefinitionNode; import org.zwobble.hobgoblin.compiler.ast.typed.TypedStructFieldDefinitionNode; -import org.zwobble.hobgoblin.compiler.ast.typed.TypedTypeLevelExpressionNode; import org.zwobble.hobgoblin.compiler.ast.untyped.*; import org.zwobble.hobgoblin.compiler.typechecker.errors.SingletonStructCannotHaveTypeParamsError; import org.zwobble.hobgoblin.compiler.types.*; @@ -104,19 +103,11 @@ public class TypeCheckerStructDefinitionTests { isOptionalOf(isSequence( allOf( has("name", TypedStructFieldDefinitionNode::name, equalTo("a")), - has("type", TypedStructFieldDefinitionNode::type, has( - "value", - TypedTypeLevelExpressionNode::value, - equalTo(int32Type) - )) + has("type", TypedStructFieldDefinitionNode::type, equalTo(int32Type)) ), allOf( has("name", TypedStructFieldDefinitionNode::name, equalTo("b")), - has("type", TypedStructFieldDefinitionNode::type, has( - "value", - TypedTypeLevelExpressionNode::value, - equalTo(int64Type) - )) + has("type", TypedStructFieldDefinitionNode::type, equalTo(int64Type)) ) )) ) @@ -209,19 +200,11 @@ public class TypeCheckerStructDefinitionTests { isOptionalOf(isSequence( allOf( has("name", TypedStructFieldDefinitionNode::name, equalTo("a")), - has("type", TypedStructFieldDefinitionNode::type, has( - "value", - TypedTypeLevelExpressionNode::value, - equalTo(new TypeParam(expectedInnerType, "A")) - )) + has("type", TypedStructFieldDefinitionNode::type, equalTo(new TypeParam(expectedInnerType, "A"))) ), allOf( has("name", TypedStructFieldDefinitionNode::name, equalTo("b")), - has("type", TypedStructFieldDefinitionNode::type, has( - "value", - TypedTypeLevelExpressionNode::value, - equalTo(new TypeParam(expectedInnerType, "B")) - )) + has("type", TypedStructFieldDefinitionNode::type, equalTo(new TypeParam(expectedInnerType, "B"))) ) )) ) @@ -275,11 +258,7 @@ public class TypeCheckerStructDefinitionTests { isOptionalOf(isSequence( allOf( has("name", TypedStructFieldDefinitionNode::name, equalTo("value")), - has("type", TypedStructFieldDefinitionNode::type, has( - "value", - TypedTypeLevelExpressionNode::value, - equalTo(new SimpleStructType(namespaceName, "Y")) - )) + has("type", TypedStructFieldDefinitionNode::type, equalTo(new SimpleStructType(namespaceName, "Y"))) ) )) ) @@ -293,11 +272,7 @@ public class TypeCheckerStructDefinitionTests { isOptionalOf(isSequence( allOf( has("name", TypedStructFieldDefinitionNode::name, equalTo("value")), - has("type", TypedStructFieldDefinitionNode::type, has( - "value", - TypedTypeLevelExpressionNode::value, - equalTo(int32Type) - )) + has("type", TypedStructFieldDefinitionNode::type, equalTo(int32Type)) ) )) ) diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/typechecker/TypeCheckerSumDefinitionTests.java b/src/test/java/org/zwobble/hobgoblin/compiler/typechecker/TypeCheckerSumDefinitionTests.java index 693f2fa..a1cb5a9 100644 --- a/src/test/java/org/zwobble/hobgoblin/compiler/typechecker/TypeCheckerSumDefinitionTests.java +++ b/src/test/java/org/zwobble/hobgoblin/compiler/typechecker/TypeCheckerSumDefinitionTests.java @@ -4,7 +4,6 @@ import org.junit.jupiter.api.Test; import org.zwobble.hobgoblin.compiler.ast.typed.TypedStructFieldDefinitionNode; import org.zwobble.hobgoblin.compiler.ast.typed.TypedSumDefinitionNode; import org.zwobble.hobgoblin.compiler.ast.typed.TypedSumVariantDefinitionNode; -import org.zwobble.hobgoblin.compiler.ast.typed.TypedTypeLevelExpressionNode; import org.zwobble.hobgoblin.compiler.ast.untyped.*; import org.zwobble.hobgoblin.compiler.builtins.NativeTypes; import org.zwobble.hobgoblin.compiler.sources.NullSource; @@ -67,16 +66,8 @@ public class TypeCheckerSumDefinitionTests { "variants", TypedSumDefinitionNode::variants, isSequence( - has("type", TypedSumVariantDefinitionNode::type, has( - "value", - TypedTypeLevelExpressionNode::value, - equalTo(rectangleType) - )), - has("type", TypedSumVariantDefinitionNode::type, has( - "value", - TypedTypeLevelExpressionNode::value, - equalTo(triangleType) - )) + has("type", TypedSumVariantDefinitionNode::type, equalTo(rectangleType)), + has("type", TypedSumVariantDefinitionNode::type, equalTo(triangleType)) ) ) )); @@ -124,16 +115,8 @@ public class TypeCheckerSumDefinitionTests { "variants", TypedSumDefinitionNode::variants, isSequence( - has("type", TypedSumVariantDefinitionNode::type, has( - "value", - TypedTypeLevelExpressionNode::value, - equalTo(NativeTypes.box(rectangleType)) - )), - has("type", TypedSumVariantDefinitionNode::type, has( - "value", - TypedTypeLevelExpressionNode::value, - equalTo(triangleType) - )) + has("type", TypedSumVariantDefinitionNode::type, equalTo(NativeTypes.box(rectangleType))), + has("type", TypedSumVariantDefinitionNode::type, equalTo(triangleType)) ) ) )); @@ -232,19 +215,11 @@ public class TypeCheckerSumDefinitionTests { isSequence( allOf( has("name", TypedStructFieldDefinitionNode::name, equalTo("x")), - has("type", TypedStructFieldDefinitionNode::type, has( - "value", - TypedTypeLevelExpressionNode::value, - equalTo(int32Type) - )) + has("type", TypedStructFieldDefinitionNode::type, equalTo(int32Type)) ), allOf( has("name", TypedStructFieldDefinitionNode::name, equalTo("y")), - has("type", TypedStructFieldDefinitionNode::type, has( - "value", - TypedTypeLevelExpressionNode::value, - equalTo(int64Type) - )) + has("type", TypedStructFieldDefinitionNode::type, equalTo(int64Type)) ) ) ) |
