diff options
30 files changed, 337 insertions, 601 deletions
diff --git a/examples/02-sum/output/rust/src/shapes.rs b/examples/02-sum/output/rust/src/shapes.rs index f06dd2b..1d2d00f 100644 --- a/examples/02-sum/output/rust/src/shapes.rs +++ b/examples/02-sum/output/rust/src/shapes.rs @@ -7,13 +7,13 @@ pub enum Shape { Triangle(crate::shapes::Triangle), } -impl ::std::convert::From<crate::shapes::Rectangle> for crate::shapes::Shape { +impl ::std::convert::From::<crate::shapes::Rectangle> for crate::shapes::Shape { fn from(value: crate::shapes::Rectangle) -> Self { Self::Rectangle(value) } } -impl ::std::convert::From<crate::shapes::Triangle> for crate::shapes::Shape { +impl ::std::convert::From::<crate::shapes::Triangle> for crate::shapes::Shape { fn from(value: crate::shapes::Triangle) -> Self { Self::Triangle(value) } diff --git a/examples/03-inductive-data-types/output/rust/src/arithmetic.rs b/examples/03-inductive-data-types/output/rust/src/arithmetic.rs index c9ea28d..9461bc4 100644 --- a/examples/03-inductive-data-types/output/rust/src/arithmetic.rs +++ b/examples/03-inductive-data-types/output/rust/src/arithmetic.rs @@ -2,17 +2,17 @@ #[derive(Debug, PartialEq)] pub enum Expression { - Add(::std::boxed::Box<crate::arithmetic::Add>), + Add(::std::boxed::Box::<crate::arithmetic::Add>), Const(crate::arithmetic::Const), } -impl ::std::convert::From<crate::arithmetic::Add> for crate::arithmetic::Expression { +impl ::std::convert::From::<crate::arithmetic::Add> for crate::arithmetic::Expression { fn from(value: crate::arithmetic::Add) -> Self { Self::Add(::std::boxed::Box::new(value)) } } -impl ::std::convert::From<crate::arithmetic::Const> for crate::arithmetic::Expression { +impl ::std::convert::From::<crate::arithmetic::Const> for crate::arithmetic::Expression { fn from(value: crate::arithmetic::Const) -> Self { Self::Const(value) } diff --git a/examples/05-list/output/rust/src/point.rs b/examples/05-list/output/rust/src/point.rs index e7308db..d80a831 100644 --- a/examples/05-list/output/rust/src/point.rs +++ b/examples/05-list/output/rust/src/point.rs @@ -2,7 +2,7 @@ #[derive(Debug, PartialEq)] pub struct Path { - pub points: ::std::vec::Vec<crate::point::Point>, + pub points: ::std::vec::Vec::<crate::point::Point>, } #[derive(Debug, PartialEq)] diff --git a/examples/10-transient-0/output/rust/src/data.rs b/examples/10-transient-0/output/rust/src/data.rs index d4ddf02..814e4ca 100644 --- a/examples/10-transient-0/output/rust/src/data.rs +++ b/examples/10-transient-0/output/rust/src/data.rs @@ -38,14 +38,14 @@ pub struct InnerStruct { #[derive(Debug, PartialEq)] pub struct StructWithList { - pub a: ::std::vec::Vec<::core::primitive::i64>, - pub b: ::std::vec::Vec<crate::data::InnerStruct>, + pub a: ::std::vec::Vec::<::core::primitive::i64>, + pub b: ::std::vec::Vec::<crate::data::InnerStruct>, } #[derive(Debug, PartialEq)] pub struct StructWithOption { - pub a: ::std::option::Option<::core::primitive::i64>, - pub b: ::std::option::Option<crate::data::InnerStruct>, + pub a: ::std::option::Option::<::core::primitive::i64>, + pub b: ::std::option::Option::<crate::data::InnerStruct>, } #[derive(Debug, PartialEq)] @@ -61,13 +61,13 @@ pub enum SumWithVariants { VariantTwo(crate::data::VariantTwo), } -impl ::std::convert::From<crate::data::VariantOne> for crate::data::SumWithVariants { +impl ::std::convert::From::<crate::data::VariantOne> for crate::data::SumWithVariants { fn from(value: crate::data::VariantOne) -> Self { Self::VariantOne(value) } } -impl ::std::convert::From<crate::data::VariantTwo> for crate::data::SumWithVariants { +impl ::std::convert::From::<crate::data::VariantTwo> for crate::data::SumWithVariants { fn from(value: crate::data::VariantTwo) -> Self { Self::VariantTwo(value) } diff --git a/hobgoblin/src/output/lang/rust/ast.hob b/hobgoblin/src/output/lang/rust/ast.hob index 5f1d878..eb6df45 100644 --- a/hobgoblin/src/output/lang/rust/ast.hob +++ b/hobgoblin/src/output/lang/rust/ast.hob @@ -83,7 +83,7 @@ struct RustInherentImpl { } struct RustTraitImpl { - field implementedTrait: RustTypePath; + field implementedTrait: RustPath; field type: RustType; field items: List[RustAssociatedItem]; } @@ -97,7 +97,7 @@ sum RustAssociatedItem { // == Attributes == struct RustOuterAttribute { - field path: RustTypePath; + field path: RustPath; field input: Option[String]; } @@ -118,7 +118,7 @@ sum RustExpression { variant RustBoolLiteral; variant RustCallExpression; variant RustFieldExpression; - variant RustPathInExpression; + variant RustPath; variant RustStructExpression; } @@ -142,7 +142,7 @@ struct RustFieldExpression { } struct RustStructExpression { - field structPath: RustPathInExpression; + field structPath: RustPath; field fieldValues: List[RustStructExprField]; } @@ -155,29 +155,20 @@ struct RustStructExprField { sum RustType { variant RustImplTraitType; - variant RustTypePath; + variant RustPath; } struct RustImplTraitType { - field trait: RustTypePath; + field trait: RustPath; } // == Paths == -struct RustPathInExpression { - field segments: List[RustPathExprSegment]; +struct RustPath { + field segments: List[RustPathSegment]; } -struct RustPathExprSegment { - field pathIdentSegment: RustPathIdentSegment; - field args: Option[List[RustType]]; -} - -struct RustTypePath { - field segments: List[RustTypePathSegment]; -} - -struct RustTypePathSegment { +struct RustPathSegment { field pathIdentSegment: RustPathIdentSegment; field args: Option[List[RustType]]; } diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/rust/RustGenerator.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/rust/RustGenerator.java index 5ad86de..1b05b47 100644 --- a/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/rust/RustGenerator.java +++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/rust/RustGenerator.java @@ -36,7 +36,7 @@ public class RustGenerator { return switch (type) { case ConstructedNativeType constructedNativeType -> { // TODO: avoid cast - var rustType = (RustTypePath) generateRustTypeExpression( + var rustType = (RustPath) generateRustTypeExpression( constructedNativeType.constructor().genericType() ); var rustArgs = constructedNativeType.args().stream() @@ -83,13 +83,13 @@ public class RustGenerator { } private RustType generateTypePath(NamespaceName namespaceName, String typeName) { - var segments = new ArrayList<RustTypePathSegment>(); - segments.add(RustTypePathSegment.crate()); + var segments = new ArrayList<RustPathSegment>(); + segments.add(RustPathSegment.crate()); for (var moduleName : this.namespaceNameToRustCrateModulePath(namespaceName)) { - segments.add(RustTypePathSegment.of(moduleName)); + segments.add(RustPathSegment.of(moduleName)); } - segments.add(RustTypePathSegment.of(generateTypeName(typeName))); - return new RustTypePath(segments); + segments.add(RustPathSegment.of(generateTypeName(typeName))); + return new RustPath(segments); } public List<RustIdentifier> namespaceNameToRustCrateModulePath(NamespaceName namespaceName) { diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/rust/RustGeneratorConfig.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/rust/RustGeneratorConfig.java index d8851c4..7a6af2d 100644 --- a/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/rust/RustGeneratorConfig.java +++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/rust/RustGeneratorConfig.java @@ -1,7 +1,7 @@ package org.zwobble.hobgoblin.compiler.output.generators.rust; import org.zwobble.hobgoblin.compiler.builtins.NativeTypes; -import org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePath; +import org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPath; import org.zwobble.hobgoblin.compiler.parser.Parser; import org.zwobble.hobgoblin.compiler.types.SimpleNativeType; import org.zwobble.json5.reader.Json5ObjectReader; @@ -41,7 +41,7 @@ public record RustGeneratorConfig( // TODO: less hacky type representation var rustTypeString = nativeTypeJson.getString("rust").value(); - var rustType = RustTypePath.of(rustTypeString); + var rustType = RustPath.of(rustTypeString); nativeTypeConfigs.put(hobgoblinType, new RustNativeTypeConfig(rustType)); } @@ -51,12 +51,12 @@ public record RustGeneratorConfig( } private static final Map<SimpleNativeType, RustNativeTypeConfig> DEFAULT_NATIVE_TYPE_CONFIGS = Map.ofEntries( - Map.entry(NativeTypes.BOOL, new RustNativeTypeConfig(RustTypePath.primitive("bool"))), - Map.entry(NativeTypes.INT_32, new RustNativeTypeConfig(RustTypePath.primitive("i32"))), - Map.entry(NativeTypes.INT_64, new RustNativeTypeConfig(RustTypePath.primitive("i64"))), - Map.entry(NativeTypes.STRING, new RustNativeTypeConfig(RustTypePath.global("std", "string", "String"))), - Map.entry(NativeTypes.LIST_INNER, new RustNativeTypeConfig(RustTypePath.global("std", "vec", "Vec"))), - Map.entry(NativeTypes.OPTION_INNER, new RustNativeTypeConfig(RustTypePath.global("std", "option", "Option"))) + Map.entry(NativeTypes.BOOL, new RustNativeTypeConfig(RustPath.primitive("bool"))), + Map.entry(NativeTypes.INT_32, new RustNativeTypeConfig(RustPath.primitive("i32"))), + Map.entry(NativeTypes.INT_64, new RustNativeTypeConfig(RustPath.primitive("i64"))), + Map.entry(NativeTypes.STRING, new RustNativeTypeConfig(RustPath.global("std", "string", "String"))), + Map.entry(NativeTypes.LIST_INNER, new RustNativeTypeConfig(RustPath.global("std", "vec", "Vec"))), + Map.entry(NativeTypes.OPTION_INNER, new RustNativeTypeConfig(RustPath.global("std", "option", "Option"))) ); public Optional<RustNativeTypeConfig> nativeTypeConfig(SimpleNativeType type) { 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 7695bf4..279f944 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 @@ -114,7 +114,7 @@ public class RustTypesGenerator implements Generator { } private static final RustOuterAttribute DERIVE_ATTRIBUTE = new RustOuterAttribute( - RustTypePath.of("derive"), + RustPath.of("derive"), Optional.of("(Debug, PartialEq)") ); @@ -158,7 +158,7 @@ public class RustTypesGenerator implements Generator { var variantType = generateRustTypeExpression(variant.type(), context); if (variant.isBox()) { - variantType = RustTypePath.global("std", "boxed", "Box") + variantType = RustPath.global("std", "boxed", "Box") .withArgs(List.of(variantType)); } @@ -183,8 +183,8 @@ public class RustTypesGenerator implements Generator { var variantType = generateRustTypeExpression(variant.type(), context); var variantName = this.rustGenerator.generateVariantName(variant.type().value()); var innerValueName = new RustIdentifier("value"); - RustExpression innerValue = new RustPathInExpression(List.of( - new RustPathExprSegment( + RustExpression innerValue = new RustPath(List.of( + new RustPathSegment( new RustPathIdentSegmentIdentifier(innerValueName), Optional.empty() ) @@ -192,25 +192,25 @@ public class RustTypesGenerator implements Generator { if (variant.isBox()) { innerValue = new RustCallExpression( - RustPathInExpression.global("std", "boxed", "Box", "new"), + RustPath.global("std", "boxed", "Box", "new"), List.of(innerValue) ); } var fromImpl = new RustTraitImpl( - RustTypePath.global("std", "convert", "From") + RustPath.global("std", "convert", "From") .withArgs(List.of(variantType)), this.rustGenerator.generateRustTypeExpression(sumDefinition.type()), List.of( new RustFunction( new RustIdentifier("from"), List.of(new RustFunctionParam(innerValueName, variantType)), - Optional.of(RustTypePath.selfType()), + Optional.of(RustPath.selfType()), Optional.of(new RustBlockExpression( List.of(), Optional.of( new RustCallExpression( - RustPathInExpression.selfType(variantName), + RustPath.selfType(variantName), List.of(innerValue) ) ) diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/RustWriter.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/RustWriter.java index 26a2737..9d6e2e0 100644 --- a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/RustWriter.java +++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/RustWriter.java @@ -207,14 +207,14 @@ public class RustWriter implements AutoCloseable { } private void writeImpl( - Optional<RustTypePath> implementedTrait, + Optional<RustPath> implementedTrait, RustType type, List<RustAssociatedItem> items ) throws IOException { this.writer.write("impl "); if (implementedTrait.isPresent()) { - this.writeTypePath(implementedTrait.get()); + this.writePath(implementedTrait.get()); this.writer.write(" for "); } @@ -264,7 +264,7 @@ public class RustWriter implements AutoCloseable { private void writeOuterAttribute(RustOuterAttribute attribute) throws IOException { this.writer.write("#["); - this.writeTypePath(attribute.path()); + this.writePath(attribute.path()); if (attribute.input().isPresent()) { this.writer.write(attribute.input().get()); @@ -309,8 +309,8 @@ public class RustWriter implements AutoCloseable { this.writeFieldExpression(fieldExpression); } - case RustPathInExpression pathInExpression -> { - this.writePathInExpression(pathInExpression); + case RustPath path -> { + this.writePath(path); } case RustStructExpression structExpression -> { @@ -362,7 +362,7 @@ public class RustWriter implements AutoCloseable { } private void writeStructExpression(RustStructExpression structExpression) throws IOException { - this.writePathInExpression(structExpression.structPath()); + this.writePath(structExpression.structPath()); this.writer.write(" {"); if (!structExpression.fieldValues().isEmpty()) { @@ -392,28 +392,28 @@ public class RustWriter implements AutoCloseable { writeImplTraitType(implTraitType); } - case RustTypePath typePath -> { - writeTypePath(typePath); + case RustPath path -> { + writePath(path); } } } private void writeImplTraitType(RustImplTraitType implTraitType) throws IOException { this.writer.write("impl "); - this.writeTypePath(implTraitType.trait()); + this.writePath(implTraitType.trait()); } // == Paths == - private void writePathInExpression(RustPathInExpression pathInExpression) throws IOException { + private void writePath(RustPath path) throws IOException { writeWithSeparator( - pathInExpression.segments(), - this::writePathExprSegment, + path.segments(), + this::writePathSegment, () -> this.writer.write("::") ); } - private void writePathExprSegment(RustPathExprSegment segment) throws IOException { + private void writePathSegment(RustPathSegment segment) throws IOException { writePathIdentSegment(segment.pathIdentSegment()); if (segment.args().isPresent()) { @@ -428,28 +428,6 @@ public class RustWriter implements AutoCloseable { } } - private void writeTypePath(RustTypePath typePath) throws IOException { - writeWithSeparator( - typePath.segments(), - this::writeTypePathSegment, - () -> this.writer.write("::") - ); - } - - private void writeTypePathSegment(RustTypePathSegment segment) throws IOException { - writePathIdentSegment(segment.pathIdentSegment()); - - if (segment.args().isPresent()) { - this.writer.write("<"); - writeWithSeparator( - segment.args().get(), - this::writeType, - () -> this.writer.write(", ") - ); - this.writer.write(">"); - } - } - private void writePathIdentSegment(RustPathIdentSegment pathIdentSegment) throws IOException { switch (pathIdentSegment) { case RustPathIdentSegmentCrate _ -> { diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustExpression.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustExpression.java index 1918fab..3a14bec 100644 --- a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustExpression.java +++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustExpression.java @@ -5,7 +5,7 @@ package org.zwobble.hobgoblin.compiler.output.lang.rust.ast; // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustExpression imports // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustExpression imports -public sealed interface RustExpression permits org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustBlockExpression, org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustBoolLiteral, org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustCallExpression, org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustFieldExpression, org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathInExpression, org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustStructExpression { +public sealed interface RustExpression permits org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustBlockExpression, org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustBoolLiteral, org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustCallExpression, org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustFieldExpression, org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPath, org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustStructExpression { public interface Builder { public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustExpression build(); diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustImplTraitType.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustImplTraitType.java index 2adba8e..4cc0f4c 100644 --- a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustImplTraitType.java +++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustImplTraitType.java @@ -5,21 +5,21 @@ package org.zwobble.hobgoblin.compiler.output.lang.rust.ast; // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustImplTraitType imports // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustImplTraitType imports -public record RustImplTraitType(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePath trait) implements org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustType { +public record RustImplTraitType(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPath trait) implements org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustType { public static org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustImplTraitType.Builder arbitrary() { - return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustImplTraitType.Builder(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePath.arbitrary().build()); + return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustImplTraitType.Builder(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPath.arbitrary().build()); } - public record Builder(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePath trait) implements org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustType.Builder { + public record Builder(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPath trait) implements org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustType.Builder { public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustImplTraitType build() { return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustImplTraitType(trait); } - public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustImplTraitType.Builder withTrait(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePath trait) { + public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustImplTraitType.Builder withTrait(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPath trait) { return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustImplTraitType.Builder(trait); } - public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustImplTraitType.Builder withTrait(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePath.Builder trait) { + public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustImplTraitType.Builder withTrait(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPath.Builder trait) { return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustImplTraitType.Builder(trait.build()); } diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustOuterAttribute.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustOuterAttribute.java index 3c045e2..08e3564 100644 --- a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustOuterAttribute.java +++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustOuterAttribute.java @@ -5,21 +5,21 @@ package org.zwobble.hobgoblin.compiler.output.lang.rust.ast; // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustOuterAttribute imports // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustOuterAttribute imports -public record RustOuterAttribute(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePath path, java.util.Optional<String> input) { +public record RustOuterAttribute(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPath path, java.util.Optional<String> input) { public static org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustOuterAttribute.Builder arbitrary() { - return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustOuterAttribute.Builder(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePath.arbitrary().build(), java.util.Optional.empty()); + return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustOuterAttribute.Builder(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPath.arbitrary().build(), java.util.Optional.empty()); } - public record Builder(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePath path, java.util.Optional<String> input) { + public record Builder(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPath path, java.util.Optional<String> input) { public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustOuterAttribute build() { return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustOuterAttribute(path, input); } - public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustOuterAttribute.Builder withPath(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePath path) { + public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustOuterAttribute.Builder withPath(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPath path) { return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustOuterAttribute.Builder(path, input); } - public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustOuterAttribute.Builder withPath(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePath.Builder path) { + public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustOuterAttribute.Builder withPath(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPath.Builder path) { return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustOuterAttribute.Builder(path.build(), input); } diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustPath.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustPath.java new file mode 100644 index 0000000..895e194 --- /dev/null +++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustPath.java @@ -0,0 +1,121 @@ +// Generated by hobgoblin. + +package org.zwobble.hobgoblin.compiler.output.lang.rust.ast; + +// Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPath imports +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Optional; +import java.util.stream.Stream; +// Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPath imports + +public record RustPath(java.util.List<org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathSegment> segments) implements org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustExpression, org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustType { + public static org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPath.Builder arbitrary() { + return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPath.Builder(java.util.List.of()); + } + + public record Builder(java.util.List<org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathSegment> segments) implements org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustExpression.Builder, org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustType.Builder { + public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPath build() { + return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPath(segments); + } + + public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPath.Builder withSegments(java.util.List<org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathSegment> segments) { + return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPath.Builder(segments); + } + + public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPath.Builder addSegment(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathSegment segment) { + var segments = new java.util.ArrayList<org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathSegment>(this.segments); + segments.add(segment); + return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPath.Builder(segments); + } + + public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPath.Builder addSegment(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathSegment.Builder segment) { + var segments = new java.util.ArrayList<org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathSegment>(this.segments); + segments.add(segment.build()); + return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPath.Builder(segments); + } + + // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPath.Builder body + // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPath.Builder body + } + + // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPath body + public static RustPath primitive(String name) { + return global("core", "primitive", name); + } + + public static RustPath of(String... names) { + var segments = Arrays.stream(names) + .map(name -> new RustPathSegment( + new RustPathIdentSegmentIdentifier(new RustIdentifier(name)), + Optional.empty() + )) + .toList(); + return new RustPath(segments); + } + + public static RustType of(RustIdentifier... names) { + var segments = Arrays.stream(names) + .map(name -> new RustPathSegment( + new RustPathIdentSegmentIdentifier(name), + Optional.empty() + )) + .toList(); + return new RustPath(segments); + } + + public static RustType crate(String... names) { + return qualified(RustPathSegment.crate(), names); + } + + public static RustPath global(String... names) { + return qualified(RustPathSegment.global(), names); + } + + public static RustPath selfType() { + return qualified(RustPathSegment.selfType(), new String[0]); + } + + public static RustPath selfType(String... names) { + return qualified(RustPathSegment.selfType(), names); + } + + public static RustPath selfType(RustIdentifier... names) { + return qualified(RustPathSegment.selfType(), names); + } + + private static RustPath qualified(RustPathSegment qualifier, String... names) { + var segments = Stream.concat( + Stream.of(qualifier), + Arrays.stream(names) + .map(name -> new RustPathSegment( + new RustPathIdentSegmentIdentifier(new RustIdentifier(name)), + Optional.empty() + )) + ) + .toList(); + return new RustPath(segments); + } + + private static RustPath qualified(RustPathSegment qualifier, RustIdentifier... names) { + var segments = Stream.concat( + Stream.of(qualifier), + Arrays.stream(names) + .map(name -> new RustPathSegment( + new RustPathIdentSegmentIdentifier(name), + Optional.empty() + )) + ) + .toList(); + return new RustPath(segments); + } + + public RustPath withArgs(List<RustType> args) { + var segments = new ArrayList<>(this.segments); + var lastSegment = segments.removeLast().withArgs(args); + segments.add(lastSegment); + return new RustPath(segments); + } + // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPath body +} diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustPathExprSegment.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustPathExprSegment.java deleted file mode 100644 index 7246ac0..0000000 --- a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustPathExprSegment.java +++ /dev/null @@ -1,57 +0,0 @@ -// Generated by hobgoblin. - -package org.zwobble.hobgoblin.compiler.output.lang.rust.ast; - -// Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathExprSegment imports -import java.util.List; -import java.util.Optional; -// Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathExprSegment imports - -public record RustPathExprSegment(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathIdentSegment pathIdentSegment, java.util.Optional<java.util.List<org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustType>> args) { - public static org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathExprSegment.Builder arbitrary() { - return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathExprSegment.Builder(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathIdentSegmentCrate.arbitrary().build(), java.util.Optional.empty()); - } - - public record Builder(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathIdentSegment pathIdentSegment, java.util.Optional<java.util.List<org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustType>> args) { - public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathExprSegment build() { - return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathExprSegment(pathIdentSegment, args); - } - - public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathExprSegment.Builder withPathIdentSegment(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathIdentSegment pathIdentSegment) { - return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathExprSegment.Builder(pathIdentSegment, args); - } - - public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathExprSegment.Builder withPathIdentSegment(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathIdentSegment.Builder pathIdentSegment) { - return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathExprSegment.Builder(pathIdentSegment.build(), args); - } - - public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathExprSegment.Builder withArgs(java.util.Optional<java.util.List<org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustType>> args) { - return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathExprSegment.Builder(pathIdentSegment, args); - } - - public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathExprSegment.Builder withArgs(java.util.List<org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustType> args) { - return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathExprSegment.Builder(pathIdentSegment, java.util.Optional.of(args)); - } - - // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathExprSegment.Builder body - // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathExprSegment.Builder body - } - - // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathExprSegment body - public static RustPathExprSegment global() { - return new RustPathExprSegment(new RustPathIdentSegmentGlobal(), Optional.empty()); - } - - public static RustPathExprSegment selfType() { - return new RustPathExprSegment(new RustPathIdentSegmentSelfType(), Optional.empty()); - } - - public RustPathExprSegment withArgs(List<RustType> args) { - if (this.args.isPresent()) { - throw new IllegalArgumentException("Expression path segment already has args"); - } - - return new RustPathExprSegment(this.pathIdentSegment, Optional.of(args)); - } - // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathExprSegment body -} diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustPathInExpression.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustPathInExpression.java deleted file mode 100644 index 78baabc..0000000 --- a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustPathInExpression.java +++ /dev/null @@ -1,95 +0,0 @@ -// Generated by hobgoblin. - -package org.zwobble.hobgoblin.compiler.output.lang.rust.ast; - -// Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathInExpression imports -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Optional; -import java.util.stream.Stream; -// Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathInExpression imports - -public record RustPathInExpression(java.util.List<org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathExprSegment> segments) implements org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustExpression { - public static org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathInExpression.Builder arbitrary() { - return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathInExpression.Builder(java.util.List.of()); - } - - public record Builder(java.util.List<org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathExprSegment> segments) implements org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustExpression.Builder { - public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathInExpression build() { - return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathInExpression(segments); - } - - public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathInExpression.Builder withSegments(java.util.List<org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathExprSegment> segments) { - return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathInExpression.Builder(segments); - } - - public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathInExpression.Builder addSegment(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathExprSegment segment) { - var segments = new java.util.ArrayList<org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathExprSegment>(this.segments); - segments.add(segment); - return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathInExpression.Builder(segments); - } - - public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathInExpression.Builder addSegment(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathExprSegment.Builder segment) { - var segments = new java.util.ArrayList<org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathExprSegment>(this.segments); - segments.add(segment.build()); - return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathInExpression.Builder(segments); - } - - // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathInExpression.Builder body - // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathInExpression.Builder body - } - - // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathInExpression body - public static RustPathInExpression of(String... names) { - var segments = Arrays.stream(names) - .map(name -> new RustPathExprSegment( - new RustPathIdentSegmentIdentifier(new RustIdentifier(name)), - Optional.empty() - )) - .toList(); - return new RustPathInExpression(segments); - } - - public static RustExpression global(String... names) { - return qualified(RustPathExprSegment.global(), names); - } - - public static RustPathInExpression selfType(RustIdentifier... names) { - return qualified(RustPathExprSegment.selfType(), names); - } - - private static RustPathInExpression qualified(RustPathExprSegment qualifier, RustIdentifier... names) { - var segments = Stream.concat( - Stream.of(qualifier), - Arrays.stream(names) - .map(name -> new RustPathExprSegment( - new RustPathIdentSegmentIdentifier(name), - Optional.empty() - )) - ) - .toList(); - return new RustPathInExpression(segments); - } - - private static RustPathInExpression qualified(RustPathExprSegment qualifier, String... names) { - var segments = Stream.concat( - Stream.of(qualifier), - Arrays.stream(names) - .map(name -> new RustPathExprSegment( - new RustPathIdentSegmentIdentifier(new RustIdentifier(name)), - Optional.empty() - )) - ) - .toList(); - return new RustPathInExpression(segments); - } - - public RustPathInExpression withArgs(List<RustType> args) { - var segments = new ArrayList<>(this.segments); - var lastSegment = segments.removeLast().withArgs(args); - segments.add(lastSegment); - return new RustPathInExpression(segments); - } - // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathInExpression body -} diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustPathSegment.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustPathSegment.java new file mode 100644 index 0000000..c2c57d6 --- /dev/null +++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustPathSegment.java @@ -0,0 +1,66 @@ +// Generated by hobgoblin. + +package org.zwobble.hobgoblin.compiler.output.lang.rust.ast; + +// Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathSegment imports +import java.util.List; +import java.util.Optional; +// Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathSegment imports + +public record RustPathSegment(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathIdentSegment pathIdentSegment, java.util.Optional<java.util.List<org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustType>> args) { + public static org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathSegment.Builder arbitrary() { + return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathSegment.Builder(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathIdentSegmentCrate.arbitrary().build(), java.util.Optional.empty()); + } + + public record Builder(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathIdentSegment pathIdentSegment, java.util.Optional<java.util.List<org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustType>> args) { + public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathSegment build() { + return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathSegment(pathIdentSegment, args); + } + + public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathSegment.Builder withPathIdentSegment(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathIdentSegment pathIdentSegment) { + return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathSegment.Builder(pathIdentSegment, args); + } + + public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathSegment.Builder withPathIdentSegment(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathIdentSegment.Builder pathIdentSegment) { + return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathSegment.Builder(pathIdentSegment.build(), args); + } + + public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathSegment.Builder withArgs(java.util.Optional<java.util.List<org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustType>> args) { + return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathSegment.Builder(pathIdentSegment, args); + } + + public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathSegment.Builder withArgs(java.util.List<org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustType> args) { + return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathSegment.Builder(pathIdentSegment, java.util.Optional.of(args)); + } + + // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathSegment.Builder body + // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathSegment.Builder body + } + + // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathSegment body + public static RustPathSegment of(RustIdentifier name) { + return new RustPathSegment(new RustPathIdentSegmentIdentifier(name), Optional.empty()); + } + + public static RustPathSegment crate() { + return new RustPathSegment(new RustPathIdentSegmentCrate(), Optional.empty()); + } + + public static RustPathSegment global() { + return new RustPathSegment(new RustPathIdentSegmentGlobal(), Optional.empty()); + } + + public static RustPathSegment selfType() { + return new RustPathSegment(new RustPathIdentSegmentSelfType(), Optional.empty()); + } + + public RustPathSegment withArgs(List<RustType> args) { + if (this.args.isPresent()) { + throw new IllegalArgumentException("Type path segment already has args"); + } + + return new RustPathSegment(this.pathIdentSegment, Optional.of(args)); + } + + // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathSegment body +} diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustStructExpression.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustStructExpression.java index 370e17c..817610c 100644 --- a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustStructExpression.java +++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustStructExpression.java @@ -5,21 +5,21 @@ package org.zwobble.hobgoblin.compiler.output.lang.rust.ast; // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustStructExpression imports // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustStructExpression imports -public record RustStructExpression(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathInExpression structPath, java.util.List<org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustStructExprField> fieldValues) implements org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustExpression { +public record RustStructExpression(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPath structPath, java.util.List<org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustStructExprField> fieldValues) implements org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustExpression { public static org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustStructExpression.Builder arbitrary() { - return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustStructExpression.Builder(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathInExpression.arbitrary().build(), java.util.List.of()); + return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustStructExpression.Builder(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPath.arbitrary().build(), java.util.List.of()); } - public record Builder(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathInExpression structPath, java.util.List<org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustStructExprField> fieldValues) implements org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustExpression.Builder { + public record Builder(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPath structPath, java.util.List<org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustStructExprField> fieldValues) implements org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustExpression.Builder { public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustStructExpression build() { return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustStructExpression(structPath, fieldValues); } - public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustStructExpression.Builder withStructPath(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathInExpression structPath) { + public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustStructExpression.Builder withStructPath(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPath structPath) { return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustStructExpression.Builder(structPath, fieldValues); } - public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustStructExpression.Builder withStructPath(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathInExpression.Builder structPath) { + public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustStructExpression.Builder withStructPath(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPath.Builder structPath) { return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustStructExpression.Builder(structPath.build(), fieldValues); } diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustTraitImpl.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustTraitImpl.java index ba729ab..f039453 100644 --- a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustTraitImpl.java +++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustTraitImpl.java @@ -5,21 +5,21 @@ package org.zwobble.hobgoblin.compiler.output.lang.rust.ast; // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTraitImpl imports // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTraitImpl imports -public record RustTraitImpl(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePath implementedTrait, org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustType type, java.util.List<org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustAssociatedItem> items) implements org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustItem { +public record RustTraitImpl(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPath implementedTrait, org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustType type, java.util.List<org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustAssociatedItem> items) implements org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustItem { public static org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTraitImpl.Builder arbitrary() { - return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTraitImpl.Builder(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePath.arbitrary().build(), org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustImplTraitType.arbitrary().build(), java.util.List.of()); + return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTraitImpl.Builder(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPath.arbitrary().build(), org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustImplTraitType.arbitrary().build(), java.util.List.of()); } - public record Builder(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePath implementedTrait, org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustType type, java.util.List<org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustAssociatedItem> items) implements org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustItem.Builder { + public record Builder(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPath implementedTrait, org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustType type, java.util.List<org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustAssociatedItem> items) implements org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustItem.Builder { public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTraitImpl build() { return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTraitImpl(implementedTrait, type, items); } - public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTraitImpl.Builder withImplementedTrait(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePath implementedTrait) { + public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTraitImpl.Builder withImplementedTrait(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPath implementedTrait) { return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTraitImpl.Builder(implementedTrait, type, items); } - public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTraitImpl.Builder withImplementedTrait(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePath.Builder implementedTrait) { + public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTraitImpl.Builder withImplementedTrait(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPath.Builder implementedTrait) { return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTraitImpl.Builder(implementedTrait.build(), type, items); } diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustType.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustType.java index 0886074..41f1777 100644 --- a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustType.java +++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustType.java @@ -5,7 +5,7 @@ package org.zwobble.hobgoblin.compiler.output.lang.rust.ast; // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustType imports // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustType imports -public sealed interface RustType permits org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustImplTraitType, org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePath { +public sealed interface RustType permits org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustImplTraitType, org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPath { public interface Builder { public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustType build(); diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustTypePath.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustTypePath.java deleted file mode 100644 index 6ce5f7f..0000000 --- a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustTypePath.java +++ /dev/null @@ -1,100 +0,0 @@ -// Generated by hobgoblin. - -package org.zwobble.hobgoblin.compiler.output.lang.rust.ast; - -// Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePath imports -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Optional; -import java.util.stream.Stream; -// Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePath imports - -public record RustTypePath(java.util.List<org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathSegment> segments) implements org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustType { - public static org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePath.Builder arbitrary() { - return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePath.Builder(java.util.List.of()); - } - - public record Builder(java.util.List<org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathSegment> segments) implements org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustType.Builder { - public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePath build() { - return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePath(segments); - } - - public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePath.Builder withSegments(java.util.List<org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathSegment> segments) { - return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePath.Builder(segments); - } - - public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePath.Builder addSegment(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathSegment segment) { - var segments = new java.util.ArrayList<org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathSegment>(this.segments); - segments.add(segment); - return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePath.Builder(segments); - } - - public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePath.Builder addSegment(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathSegment.Builder segment) { - var segments = new java.util.ArrayList<org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathSegment>(this.segments); - segments.add(segment.build()); - return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePath.Builder(segments); - } - - // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePath.Builder body - // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePath.Builder body - } - - // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePath body - public static RustTypePath primitive(String name) { - return global("core", "primitive", name); - } - - public static RustTypePath of(String... names) { - var segments = Arrays.stream(names) - .map(name -> new RustTypePathSegment( - new RustPathIdentSegmentIdentifier(new RustIdentifier(name)), - Optional.empty() - )) - .toList(); - return new RustTypePath(segments); - } - - public static RustType of(RustIdentifier... names) { - var segments = Arrays.stream(names) - .map(name -> new RustTypePathSegment( - new RustPathIdentSegmentIdentifier(name), - Optional.empty() - )) - .toList(); - return new RustTypePath(segments); - } - - public static RustType crate(String... names) { - return qualified(RustTypePathSegment.crate(), names); - } - - public static RustTypePath global(String... names) { - return qualified(RustTypePathSegment.global(), names); - } - - public static RustTypePath selfType(String... names) { - return qualified(RustTypePathSegment.selfType(), names); - } - - private static RustTypePath qualified(RustTypePathSegment qualifier, String... names) { - var segments = Stream.concat( - Stream.of(qualifier), - Arrays.stream(names) - .map(name -> new RustTypePathSegment( - new RustPathIdentSegmentIdentifier(new RustIdentifier(name)), - Optional.empty() - )) - ) - .toList(); - return new RustTypePath(segments); - } - - public RustTypePath withArgs(List<RustType> args) { - var segments = new ArrayList<>(this.segments); - var lastSegment = segments.removeLast().withArgs(args); - segments.add(lastSegment); - return new RustTypePath(segments); - } - // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePath body -} diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustTypePathSegment.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustTypePathSegment.java deleted file mode 100644 index 6531925..0000000 --- a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustTypePathSegment.java +++ /dev/null @@ -1,65 +0,0 @@ -// Generated by hobgoblin. - -package org.zwobble.hobgoblin.compiler.output.lang.rust.ast; - -// Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathSegment imports -import java.util.List; -import java.util.Optional; -// Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathSegment imports - -public record RustTypePathSegment(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathIdentSegment pathIdentSegment, java.util.Optional<java.util.List<org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustType>> args) { - public static org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathSegment.Builder arbitrary() { - return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathSegment.Builder(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathIdentSegmentCrate.arbitrary().build(), java.util.Optional.empty()); - } - - public record Builder(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathIdentSegment pathIdentSegment, java.util.Optional<java.util.List<org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustType>> args) { - public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathSegment build() { - return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathSegment(pathIdentSegment, args); - } - - public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathSegment.Builder withPathIdentSegment(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathIdentSegment pathIdentSegment) { - return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathSegment.Builder(pathIdentSegment, args); - } - - public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathSegment.Builder withPathIdentSegment(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathIdentSegment.Builder pathIdentSegment) { - return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathSegment.Builder(pathIdentSegment.build(), args); - } - - public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathSegment.Builder withArgs(java.util.Optional<java.util.List<org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustType>> args) { - return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathSegment.Builder(pathIdentSegment, args); - } - - public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathSegment.Builder withArgs(java.util.List<org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustType> args) { - return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathSegment.Builder(pathIdentSegment, java.util.Optional.of(args)); - } - - // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathSegment.Builder body - // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathSegment.Builder body - } - - // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathSegment body - public static RustTypePathSegment of(RustIdentifier name) { - return new RustTypePathSegment(new RustPathIdentSegmentIdentifier(name), Optional.empty()); - } - - public static RustTypePathSegment crate() { - return new RustTypePathSegment(new RustPathIdentSegmentCrate(), Optional.empty()); - } - - public static RustTypePathSegment global() { - return new RustTypePathSegment(new RustPathIdentSegmentGlobal(), Optional.empty()); - } - - public static RustTypePathSegment selfType() { - return new RustTypePathSegment(new RustPathIdentSegmentSelfType(), Optional.empty()); - } - - public RustTypePathSegment withArgs(List<RustType> args) { - if (this.args.isPresent()) { - throw new IllegalArgumentException("Type path segment already has args"); - } - - return new RustTypePathSegment(this.pathIdentSegment, Optional.of(args)); - } - // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathSegment body -} diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/RustWriterTests.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/RustWriterTests.java index 67d0a42..358d99d 100644 --- a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/RustWriterTests.java +++ b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/RustWriterTests.java @@ -56,8 +56,8 @@ public class RustWriterTests { public void functionWithParams() throws IOException { var rust = RustFunction.arbitrary() .withName(new RustIdentifier("area")) - .addParam(new RustFunctionParam(new RustIdentifier("width"), RustTypePath.of("i32"))) - .addParam(new RustFunctionParam(new RustIdentifier("height"), RustTypePath.of("u64"))) + .addParam(new RustFunctionParam(new RustIdentifier("width"), RustPath.of("i32"))) + .addParam(new RustFunctionParam(new RustIdentifier("height"), RustPath.of("u64"))) .build(); var string = write(writer -> writer.writeAssociatedItem(rust)); @@ -70,7 +70,7 @@ public class RustWriterTests { public void functionWithReturnType() throws IOException { var rust = RustFunction.arbitrary() .withName(new RustIdentifier("area")) - .withReturnType(Optional.of(RustTypePath.of("i32"))) + .withReturnType(Optional.of(RustPath.of("i32"))) .build(); var string = write(writer -> writer.writeAssociatedItem(rust)); @@ -114,8 +114,8 @@ public class RustWriterTests { var rust = RustStructStruct.arbitrary() .withName(new RustIdentifier("Rectangle")) .withAttributes(List.of( - new RustOuterAttribute(RustTypePath.of("a", "b", "C"), Optional.empty()), - new RustOuterAttribute(RustTypePath.of("derive"), Optional.of("(Debug)")) + new RustOuterAttribute(RustPath.of("a", "b", "C"), Optional.empty()), + new RustOuterAttribute(RustPath.of("derive"), Optional.of("(Debug)")) )) .build(); @@ -133,8 +133,8 @@ public class RustWriterTests { var rust = RustStructStruct.arbitrary() .withName(new RustIdentifier("Rectangle")) .withFields(List.of( - new RustStructField(new RustIdentifier("width"), RustTypePath.of("i32")), - new RustStructField(new RustIdentifier("height"), RustTypePath.of("i32")) + new RustStructField(new RustIdentifier("width"), RustPath.of("i32")), + new RustStructField(new RustIdentifier("height"), RustPath.of("i32")) )) .build(); @@ -180,8 +180,8 @@ public class RustWriterTests { var rust = RustEnum.arbitrary() .withName(new RustIdentifier("Shape")) .withAttributes(List.of( - new RustOuterAttribute(RustTypePath.of("a", "b", "C"), Optional.empty()), - new RustOuterAttribute(RustTypePath.of("derive"), Optional.of("(Debug)")) + new RustOuterAttribute(RustPath.of("a", "b", "C"), Optional.empty()), + new RustOuterAttribute(RustPath.of("derive"), Optional.of("(Debug)")) )) .build(); @@ -229,8 +229,8 @@ public class RustWriterTests { .withFields( RustEnumVariantTuple.arbitrary() .withFields(List.of( - RustTupleField.arbitrary().withType(RustTypePath.of("i32")).build(), - RustTupleField.arbitrary().withType(RustTypePath.of("i32")).build() + RustTupleField.arbitrary().withType(RustPath.of("i32")).build(), + RustTupleField.arbitrary().withType(RustPath.of("i32")).build() )) .build() ) @@ -240,7 +240,7 @@ public class RustWriterTests { .withFields( RustEnumVariantTuple.arbitrary() .withFields(List.of( - RustTupleField.arbitrary().withType(RustTypePath.of("u64")).build() + RustTupleField.arbitrary().withType(RustPath.of("u64")).build() )) .build() ) @@ -276,7 +276,7 @@ public class RustWriterTests { @Test public void emptyInherentImpl() throws IOException { - var rust = RustInherentImpl.arbitrary().withType(RustTypePath.of("Square")).build(); + var rust = RustInherentImpl.arbitrary().withType(RustPath.of("Square")).build(); var string = write(writer -> writer.writeItem(rust)); @@ -288,7 +288,7 @@ public class RustWriterTests { @Test public void inherentImplWithAssociatedItems() throws IOException { var rust = RustInherentImpl.arbitrary() - .withType(RustTypePath.of("Square")) + .withType(RustPath.of("Square")) .addItem(RustFunction.arbitrary().withName(new RustIdentifier("width"))) .addItem(RustFunction.arbitrary().withName(new RustIdentifier("height"))) .build(); @@ -306,8 +306,8 @@ public class RustWriterTests { @Test public void emptyTraitImpl() throws IOException { var rust = RustTraitImpl.arbitrary() - .withImplementedTrait(RustTypePath.of("Shape")) - .withType(RustTypePath.of("Square")) + .withImplementedTrait(RustPath.of("Shape")) + .withType(RustPath.of("Square")) .build(); var string = write(writer -> writer.writeItem(rust)); @@ -320,8 +320,8 @@ public class RustWriterTests { @Test public void traitImplWithAssociatedItems() throws IOException { var rust = RustTraitImpl.arbitrary() - .withImplementedTrait(RustTypePath.of("Shape")) - .withType(RustTypePath.of("Square")) + .withImplementedTrait(RustPath.of("Shape")) + .withType(RustPath.of("Square")) .addItem(RustFunction.arbitrary().withName(new RustIdentifier("width"))) .addItem(RustFunction.arbitrary().withName(new RustIdentifier("height"))) .build(); @@ -445,7 +445,7 @@ public class RustWriterTests { @Test public void callExpressionWithNoArgs() throws IOException { var rust = RustCallExpression.arbitrary() - .withFunction(RustPathInExpression.of("f")) + .withFunction(RustPath.of("f")) .build(); var string = write(writer -> writer.writeExpression(rust)); @@ -456,9 +456,9 @@ public class RustWriterTests { @Test public void callExpressionWithArgs() throws IOException { var rust = RustCallExpression.arbitrary() - .withFunction(RustPathInExpression.of("f")) - .addArg(RustPathInExpression.of("x")) - .addArg(RustPathInExpression.of("y")) + .withFunction(RustPath.of("f")) + .addArg(RustPath.of("x")) + .addArg(RustPath.of("y")) .build(); var string = write(writer -> writer.writeExpression(rust)); @@ -471,7 +471,7 @@ public class RustWriterTests { @Test public void fieldExpression() throws IOException { var rust = RustFieldExpression.arbitrary() - .withContainerOperand(RustPathInExpression.of("x")) + .withContainerOperand(RustPath.of("x")) .withFieldName(RustIdentifier.of("y")) .build(); @@ -485,7 +485,7 @@ public class RustWriterTests { @Test public void structExpressionWithNoFields() throws IOException { var rust = RustStructExpression.arbitrary() - .withStructPath(RustPathInExpression.of("A")) + .withStructPath(RustPath.of("A")) .build(); var string = write(writer -> writer.writeExpression(rust)); @@ -496,16 +496,16 @@ public class RustWriterTests { @Test public void structExpressionWithFields() throws IOException { var rust = RustStructExpression.arbitrary() - .withStructPath(RustPathInExpression.of("X")) + .withStructPath(RustPath.of("X")) .addFieldValue( RustStructExprField.arbitrary() .withName(RustIdentifier.of("a")) - .withValue(RustPathInExpression.of("b")) + .withValue(RustPath.of("b")) ) .addFieldValue( RustStructExprField.arbitrary() .withName(RustIdentifier.of("c")) - .withValue(RustPathInExpression.of("d")) + .withValue(RustPath.of("d")) ) .build(); @@ -519,7 +519,7 @@ public class RustWriterTests { @Test public void implTraitType() throws IOException { var rust = RustImplTraitType.arbitrary() - .withTrait(RustTypePath.of("std", "io", "Read")) + .withTrait(RustPath.of("std", "io", "Read")) .build(); var string = write(writer -> writer.writeType(rust)); @@ -530,8 +530,8 @@ public class RustWriterTests { // == Paths == @Test - public void pathExprSegmentsAreSeparatedByDoubleColons() throws IOException { - var rust = RustPathInExpression.of("std", "string", "String"); + public void pathSegmentsAreSeparatedByDoubleColons() throws IOException { + var rust = RustPath.of("std", "string", "String"); var string = write(writer -> writer.writeExpression(rust)); @@ -539,9 +539,9 @@ public class RustWriterTests { } @Test - public void pathExprSegmentGenericArgsAreWritten() throws IOException { - var rust = RustPathInExpression.of("std", "collections", "HashMap") - .withArgs(List.of(RustTypePath.of("i32"), RustTypePath.of("f64"))); + public void pathSegmentGenericArgsAreWritten() throws IOException { + var rust = RustPath.of("std", "collections", "HashMap") + .withArgs(List.of(RustPath.of("i32"), RustPath.of("f64"))); var string = write(writer -> writer.writeExpression(rust)); @@ -549,27 +549,8 @@ public class RustWriterTests { } @Test - public void typePathSegmentsAreSeparatedByDoubleColons() throws IOException { - var rust = RustTypePath.of("std", "string", "String"); - - var string = write(writer -> writer.writeType(rust)); - - assertThat(string, equalTo("std::string::String")); - } - - @Test - public void typePathSegmentGenericArgsAreWritten() throws IOException { - var rust = RustTypePath.of("std", "collections", "HashMap") - .withArgs(List.of(RustTypePath.of("i32"), RustTypePath.of("f64"))); - - var string = write(writer -> writer.writeType(rust)); - - assertThat(string, equalTo("std::collections::HashMap<i32, f64>")); - } - - @Test public void crateSegmentIsWritten() throws IOException { - var rust = RustTypePath.crate("a", "b"); + var rust = RustPath.crate("a", "b"); var string = write(writer -> writer.writeType(rust)); @@ -578,7 +559,7 @@ public class RustWriterTests { @Test public void globalSegmentIsWritten() throws IOException { - var rust = RustTypePath.global("a", "b"); + var rust = RustPath.global("a", "b"); var string = write(writer -> writer.writeType(rust)); @@ -587,7 +568,7 @@ public class RustWriterTests { @Test public void selfTypeSegmentIsWritten() throws IOException { - var rust = RustTypePath.selfType(); + var rust = RustPath.selfType(); var string = write(writer -> writer.writeType(rust)); diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustImplTraitTypeMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustImplTraitTypeMatcher.java index 02afb08..0ad0925 100644 --- a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustImplTraitTypeMatcher.java +++ b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustImplTraitTypeMatcher.java @@ -28,7 +28,7 @@ public class RustImplTraitTypeMatcher implements org.zwobble.precisely.Matcher<j return org.zwobble.precisely.Matchers.instanceOf(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustImplTraitType.class, this.submatchers); } - public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustImplTraitTypeMatcher withTrait(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePath> trait) { + public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustImplTraitTypeMatcher withTrait(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPath> trait) { var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustImplTraitType>>(this.submatchers); submatchers.add(org.zwobble.precisely.Matchers.has("trait", org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustImplTraitType::trait, trait)); return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustImplTraitTypeMatcher(submatchers); diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustOuterAttributeMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustOuterAttributeMatcher.java index 7aceb9e..03707bc 100644 --- a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustOuterAttributeMatcher.java +++ b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustOuterAttributeMatcher.java @@ -28,7 +28,7 @@ public class RustOuterAttributeMatcher implements org.zwobble.precisely.Matcher< return org.zwobble.precisely.Matchers.instanceOf(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustOuterAttribute.class, this.submatchers); } - public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustOuterAttributeMatcher withPath(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePath> path) { + public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustOuterAttributeMatcher withPath(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPath> path) { var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustOuterAttribute>>(this.submatchers); submatchers.add(org.zwobble.precisely.Matchers.has("path", org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustOuterAttribute::path, path)); return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustOuterAttributeMatcher(submatchers); diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustPathInExpressionMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustPathMatcher.java index 4fad401..eb382d0 100644 --- a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustPathInExpressionMatcher.java +++ b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustPathMatcher.java @@ -2,17 +2,17 @@ package org.zwobble.hobgoblin.compiler.output.lang.rust.ast; -// Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathInExpressionMatcher imports -// Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathInExpressionMatcher imports +// Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathMatcher imports +// Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathMatcher imports -public class RustPathInExpressionMatcher implements org.zwobble.precisely.Matcher<java.lang.Object> { - public static org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathInExpressionMatcher isRustPathInExpression() { - return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathInExpressionMatcher(java.util.List.of()); +public class RustPathMatcher implements org.zwobble.precisely.Matcher<java.lang.Object> { + public static org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathMatcher isRustPath() { + return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathMatcher(java.util.List.of()); } - private final java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathInExpression>> submatchers; + private final java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPath>> submatchers; - private RustPathInExpressionMatcher(java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathInExpression>> submatchers) { + private RustPathMatcher(java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPath>> submatchers) { this.submatchers = submatchers; } @@ -25,15 +25,15 @@ public class RustPathInExpressionMatcher implements org.zwobble.precisely.Matche } private org.zwobble.precisely.Matcher<java.lang.Object> toMatcher() { - return org.zwobble.precisely.Matchers.instanceOf(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathInExpression.class, this.submatchers); + return org.zwobble.precisely.Matchers.instanceOf(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPath.class, this.submatchers); } - public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathInExpressionMatcher withSegments(org.zwobble.precisely.Matcher<? super java.util.List<org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathExprSegment>> segments) { - var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathInExpression>>(this.submatchers); - submatchers.add(org.zwobble.precisely.Matchers.has("segments", org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathInExpression::segments, segments)); - return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathInExpressionMatcher(submatchers); + public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathMatcher withSegments(org.zwobble.precisely.Matcher<? super java.util.List<org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathSegment>> segments) { + var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPath>>(this.submatchers); + submatchers.add(org.zwobble.precisely.Matchers.has("segments", org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPath::segments, segments)); + return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathMatcher(submatchers); } - // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathInExpressionMatcher body - // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathInExpressionMatcher body + // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathMatcher body + // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathMatcher body } diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustPathExprSegmentMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustPathSegmentMatcher.java index 04fbe5b..7db3593 100644 --- a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustPathExprSegmentMatcher.java +++ b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustPathSegmentMatcher.java @@ -2,17 +2,17 @@ package org.zwobble.hobgoblin.compiler.output.lang.rust.ast; -// Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathExprSegmentMatcher imports -// Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathExprSegmentMatcher imports +// Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathSegmentMatcher imports +// Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathSegmentMatcher imports -public class RustPathExprSegmentMatcher implements org.zwobble.precisely.Matcher<java.lang.Object> { - public static org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathExprSegmentMatcher isRustPathExprSegment() { - return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathExprSegmentMatcher(java.util.List.of()); +public class RustPathSegmentMatcher implements org.zwobble.precisely.Matcher<java.lang.Object> { + public static org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathSegmentMatcher isRustPathSegment() { + return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathSegmentMatcher(java.util.List.of()); } - private final java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathExprSegment>> submatchers; + private final java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathSegment>> submatchers; - private RustPathExprSegmentMatcher(java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathExprSegment>> submatchers) { + private RustPathSegmentMatcher(java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathSegment>> submatchers) { this.submatchers = submatchers; } @@ -25,21 +25,21 @@ public class RustPathExprSegmentMatcher implements org.zwobble.precisely.Matcher } private org.zwobble.precisely.Matcher<java.lang.Object> toMatcher() { - return org.zwobble.precisely.Matchers.instanceOf(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathExprSegment.class, this.submatchers); + return org.zwobble.precisely.Matchers.instanceOf(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathSegment.class, this.submatchers); } - public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathExprSegmentMatcher withPathIdentSegment(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathIdentSegment> pathIdentSegment) { - var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathExprSegment>>(this.submatchers); - submatchers.add(org.zwobble.precisely.Matchers.has("pathIdentSegment", org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathExprSegment::pathIdentSegment, pathIdentSegment)); - return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathExprSegmentMatcher(submatchers); + public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathSegmentMatcher withPathIdentSegment(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathIdentSegment> pathIdentSegment) { + var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathSegment>>(this.submatchers); + submatchers.add(org.zwobble.precisely.Matchers.has("pathIdentSegment", org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathSegment::pathIdentSegment, pathIdentSegment)); + return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathSegmentMatcher(submatchers); } - public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathExprSegmentMatcher withArgs(org.zwobble.precisely.Matcher<? super java.util.Optional<java.util.List<org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustType>>> args) { - var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathExprSegment>>(this.submatchers); - submatchers.add(org.zwobble.precisely.Matchers.has("args", org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathExprSegment::args, args)); - return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathExprSegmentMatcher(submatchers); + public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathSegmentMatcher withArgs(org.zwobble.precisely.Matcher<? super java.util.Optional<java.util.List<org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustType>>> args) { + var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathSegment>>(this.submatchers); + submatchers.add(org.zwobble.precisely.Matchers.has("args", org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathSegment::args, args)); + return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathSegmentMatcher(submatchers); } - // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathExprSegmentMatcher body - // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathExprSegmentMatcher body + // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathSegmentMatcher body + // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathSegmentMatcher body } diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustStructExpressionMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustStructExpressionMatcher.java index 5597d00..20f8ec7 100644 --- a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustStructExpressionMatcher.java +++ b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustStructExpressionMatcher.java @@ -28,7 +28,7 @@ public class RustStructExpressionMatcher implements org.zwobble.precisely.Matche return org.zwobble.precisely.Matchers.instanceOf(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustStructExpression.class, this.submatchers); } - public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustStructExpressionMatcher withStructPath(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathInExpression> structPath) { + public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustStructExpressionMatcher withStructPath(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPath> structPath) { var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustStructExpression>>(this.submatchers); submatchers.add(org.zwobble.precisely.Matchers.has("structPath", org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustStructExpression::structPath, structPath)); return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustStructExpressionMatcher(submatchers); diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustTraitImplMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustTraitImplMatcher.java index a31ac13..9d31b3f 100644 --- a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustTraitImplMatcher.java +++ b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustTraitImplMatcher.java @@ -28,7 +28,7 @@ public class RustTraitImplMatcher implements org.zwobble.precisely.Matcher<java. return org.zwobble.precisely.Matchers.instanceOf(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTraitImpl.class, this.submatchers); } - public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTraitImplMatcher withImplementedTrait(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePath> implementedTrait) { + public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTraitImplMatcher withImplementedTrait(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPath> implementedTrait) { var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTraitImpl>>(this.submatchers); submatchers.add(org.zwobble.precisely.Matchers.has("implementedTrait", org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTraitImpl::implementedTrait, implementedTrait)); return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTraitImplMatcher(submatchers); diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustTypePathMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustTypePathMatcher.java deleted file mode 100644 index 4a12993..0000000 --- a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustTypePathMatcher.java +++ /dev/null @@ -1,39 +0,0 @@ -// Generated by hobgoblin. - -package org.zwobble.hobgoblin.compiler.output.lang.rust.ast; - -// Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathMatcher imports -// Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathMatcher imports - -public class RustTypePathMatcher implements org.zwobble.precisely.Matcher<java.lang.Object> { - public static org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathMatcher isRustTypePath() { - return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathMatcher(java.util.List.of()); - } - - private final java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePath>> submatchers; - - private RustTypePathMatcher(java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePath>> submatchers) { - this.submatchers = submatchers; - } - - public org.zwobble.precisely.MatchResult match(java.lang.Object actual) { - return this.toMatcher().match(actual); - } - - public org.zwobble.precisely.TextTree describe() { - return this.toMatcher().describe(); - } - - private org.zwobble.precisely.Matcher<java.lang.Object> toMatcher() { - return org.zwobble.precisely.Matchers.instanceOf(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePath.class, this.submatchers); - } - - public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathMatcher withSegments(org.zwobble.precisely.Matcher<? super java.util.List<org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathSegment>> segments) { - var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePath>>(this.submatchers); - submatchers.add(org.zwobble.precisely.Matchers.has("segments", org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePath::segments, segments)); - return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathMatcher(submatchers); - } - - // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathMatcher body - // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathMatcher body -} diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustTypePathSegmentMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustTypePathSegmentMatcher.java deleted file mode 100644 index d3ccd10..0000000 --- a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustTypePathSegmentMatcher.java +++ /dev/null @@ -1,45 +0,0 @@ -// Generated by hobgoblin. - -package org.zwobble.hobgoblin.compiler.output.lang.rust.ast; - -// Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathSegmentMatcher imports -// Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathSegmentMatcher imports - -public class RustTypePathSegmentMatcher implements org.zwobble.precisely.Matcher<java.lang.Object> { - public static org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathSegmentMatcher isRustTypePathSegment() { - return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathSegmentMatcher(java.util.List.of()); - } - - private final java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathSegment>> submatchers; - - private RustTypePathSegmentMatcher(java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathSegment>> submatchers) { - this.submatchers = submatchers; - } - - public org.zwobble.precisely.MatchResult match(java.lang.Object actual) { - return this.toMatcher().match(actual); - } - - public org.zwobble.precisely.TextTree describe() { - return this.toMatcher().describe(); - } - - private org.zwobble.precisely.Matcher<java.lang.Object> toMatcher() { - return org.zwobble.precisely.Matchers.instanceOf(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathSegment.class, this.submatchers); - } - - public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathSegmentMatcher withPathIdentSegment(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathIdentSegment> pathIdentSegment) { - var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathSegment>>(this.submatchers); - submatchers.add(org.zwobble.precisely.Matchers.has("pathIdentSegment", org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathSegment::pathIdentSegment, pathIdentSegment)); - return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathSegmentMatcher(submatchers); - } - - public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathSegmentMatcher withArgs(org.zwobble.precisely.Matcher<? super java.util.Optional<java.util.List<org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustType>>> args) { - var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathSegment>>(this.submatchers); - submatchers.add(org.zwobble.precisely.Matchers.has("args", org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathSegment::args, args)); - return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathSegmentMatcher(submatchers); - } - - // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathSegmentMatcher body - // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathSegmentMatcher body -} |
