From 139dc93bb10daea87eba99e8f28d8a668c94e13b Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Fri, 3 Jul 2026 14:57:30 +0100 Subject: Add self type path segment --- .../compiler/output/lang/rust/RustWriterTests.java | 9 ++++++ .../ast/RustPathIdentSegmentSelfTypeMatcher.java | 33 ++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustPathIdentSegmentSelfTypeMatcher.java (limited to 'src/test/java/org') 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 d139a3b..4c337d5 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 @@ -439,6 +439,15 @@ public class RustWriterTests { assertThat(string, equalTo("::a::b")); } + @Test + public void selfTypeSegmentIsWritten() throws IOException { + var rust = RustTypePath.selfType(); + + var string = write(writer -> writer.writeType(rust)); + + assertThat(string, equalTo("Self")); + } + // == Identifiers == @Test diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustPathIdentSegmentSelfTypeMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustPathIdentSegmentSelfTypeMatcher.java new file mode 100644 index 0000000..18ab20a --- /dev/null +++ b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustPathIdentSegmentSelfTypeMatcher.java @@ -0,0 +1,33 @@ +// Generated by hobgoblin. + +package org.zwobble.hobgoblin.compiler.output.lang.rust.ast; + +// Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathIdentSegmentSelfTypeMatcher imports +// Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathIdentSegmentSelfTypeMatcher imports + +public class RustPathIdentSegmentSelfTypeMatcher implements org.zwobble.precisely.Matcher { + public static org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathIdentSegmentSelfTypeMatcher isRustPathIdentSegmentSelfType() { + return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathIdentSegmentSelfTypeMatcher(java.util.List.of()); + } + + private final java.util.List> submatchers; + + private RustPathIdentSegmentSelfTypeMatcher(java.util.List> 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 toMatcher() { + return org.zwobble.precisely.Matchers.instanceOf(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathIdentSegmentSelfType.class, this.submatchers); + } + + // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathIdentSegmentSelfTypeMatcher body + // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustPathIdentSegmentSelfTypeMatcher body +} -- cgit v1.2.3