diff options
| author | Michael Williamson <mike@zwobble.org> | 2026-07-12 11:15:26 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2026-07-12 11:15:26 +0100 |
| commit | c33905c4351a02327358284e6de4579a5e311326 (patch) | |
| tree | d7620deded05b4f00bb10a6fa54b380f409c0eb6 /src | |
| parent | eb4ce8b7ebceac4bbf68b779b9f6d6f4439ddbba (diff) | |
Support case constants in Java AST
Diffstat (limited to 'src')
9 files changed, 234 insertions, 30 deletions
diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/JavaWriter.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/JavaWriter.java index 893e30b..893b055 100644 --- a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/JavaWriter.java +++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/JavaWriter.java @@ -542,9 +542,16 @@ public class JavaWriter implements AutoCloseable { for (var rule : switchStatement.rules()) { this.writer.newLine(); this.writer.write("case "); - this.writeTypeRef(rule.type()); - this.writer.write(" "); - this.writeIdentifier(rule.variableName()); + switch (rule.label()) { + case JavaCaseConstant caseConstant -> { + this.writeTopLevelExpression(caseConstant.value()); + } + case JavaCasePattern casePattern -> { + this.writeTypeRef(casePattern.type()); + this.writer.write(" "); + this.writeIdentifier(casePattern.variableName()); + } + } this.writer.write(" -> {"); this.writer.indent(); this.writer.newLine(); diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaCaseConstant.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaCaseConstant.java new file mode 100644 index 0000000..8775fbb --- /dev/null +++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaCaseConstant.java @@ -0,0 +1,32 @@ +// Generated by hobgoblin. + +package org.zwobble.hobgoblin.compiler.output.lang.java.ast; + +// Custom area start: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCaseConstant imports +// Custom area end: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCaseConstant imports + +public record JavaCaseConstant(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaExpression value) implements org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaSwitchLabel { + public static org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCaseConstant.Builder arbitrary() { + return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCaseConstant.Builder(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaBooleanLiteral.arbitrary().build()); + } + + public record Builder(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaExpression value) implements org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaSwitchLabel.Builder { + public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCaseConstant build() { + return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCaseConstant(value); + } + + public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCaseConstant.Builder withValue(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaExpression value) { + return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCaseConstant.Builder(value); + } + + public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCaseConstant.Builder withValue(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaExpression.Builder value) { + return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCaseConstant.Builder(value.build()); + } + + // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCaseConstant.Builder body + // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCaseConstant.Builder body + } + + // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCaseConstant body + // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCaseConstant body +} diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaCasePattern.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaCasePattern.java new file mode 100644 index 0000000..11f2778 --- /dev/null +++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaCasePattern.java @@ -0,0 +1,36 @@ +// Generated by hobgoblin. + +package org.zwobble.hobgoblin.compiler.output.lang.java.ast; + +// Custom area start: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCasePattern imports +// Custom area end: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCasePattern imports + +public record JavaCasePattern(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaTypeRef type, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier variableName) implements org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaSwitchLabel { + public static org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCasePattern.Builder arbitrary() { + return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCasePattern.Builder(org.zwobble.hobgoblin.compiler.output.lang.java.ast.HobgoblinNativeAst.arbitraryJavaTypeRef(), org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier.arbitrary().build()); + } + + public record Builder(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaTypeRef type, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier variableName) implements org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaSwitchLabel.Builder { + public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCasePattern build() { + return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCasePattern(type, variableName); + } + + public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCasePattern.Builder withType(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaTypeRef type) { + return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCasePattern.Builder(type, variableName); + } + + public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCasePattern.Builder withVariableName(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier variableName) { + return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCasePattern.Builder(type, variableName); + } + + public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCasePattern.Builder withVariableName(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier.Builder variableName) { + return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCasePattern.Builder(type, variableName.build()); + } + + // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCasePattern.Builder body + // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCasePattern.Builder body + } + + // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCasePattern body + // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCasePattern body +} diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaSwitchLabel.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaSwitchLabel.java new file mode 100644 index 0000000..7978458 --- /dev/null +++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaSwitchLabel.java @@ -0,0 +1,18 @@ +// Generated by hobgoblin. + +package org.zwobble.hobgoblin.compiler.output.lang.java.ast; + +// Custom area start: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaSwitchLabel imports +// Custom area end: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaSwitchLabel imports + +public sealed interface JavaSwitchLabel permits org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCaseConstant, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCasePattern { + public interface Builder { + public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaSwitchLabel build(); + + // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaSwitchLabel.Builder body + // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaSwitchLabel.Builder body + } + + // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaSwitchLabel body + // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaSwitchLabel body +} diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaSwitchRule.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaSwitchRule.java index 7d4b3c2..9e791d5 100644 --- a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaSwitchRule.java +++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaSwitchRule.java @@ -5,34 +5,30 @@ package org.zwobble.hobgoblin.compiler.output.lang.java.ast; // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaSwitchRule imports // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaSwitchRule imports -public record JavaSwitchRule(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaTypeRef type, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier variableName, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaBlock body) { +public record JavaSwitchRule(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaSwitchLabel label, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaBlock body) { public static org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaSwitchRule.Builder arbitrary() { - return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaSwitchRule.Builder(org.zwobble.hobgoblin.compiler.output.lang.java.ast.HobgoblinNativeAst.arbitraryJavaTypeRef(), org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier.arbitrary().build(), org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaBlock.arbitrary().build()); + return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaSwitchRule.Builder(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCaseConstant.arbitrary().build(), org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaBlock.arbitrary().build()); } - public record Builder(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaTypeRef type, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier variableName, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaBlock body) { + public record Builder(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaSwitchLabel label, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaBlock body) { public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaSwitchRule build() { - return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaSwitchRule(type, variableName, body); + return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaSwitchRule(label, body); } - public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaSwitchRule.Builder withType(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaTypeRef type) { - return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaSwitchRule.Builder(type, variableName, body); + public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaSwitchRule.Builder withLabel(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaSwitchLabel label) { + return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaSwitchRule.Builder(label, body); } - public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaSwitchRule.Builder withVariableName(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier variableName) { - return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaSwitchRule.Builder(type, variableName, body); - } - - public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaSwitchRule.Builder withVariableName(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier.Builder variableName) { - return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaSwitchRule.Builder(type, variableName.build(), body); + public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaSwitchRule.Builder withLabel(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaSwitchLabel.Builder label) { + return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaSwitchRule.Builder(label.build(), body); } public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaSwitchRule.Builder withBody(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaBlock body) { - return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaSwitchRule.Builder(type, variableName, body); + return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaSwitchRule.Builder(label, body); } public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaSwitchRule.Builder withBody(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaBlock.Builder body) { - return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaSwitchRule.Builder(type, variableName, body.build()); + return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaSwitchRule.Builder(label, body.build()); } // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaSwitchRule.Builder body diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/JavaWriterTests.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/JavaWriterTests.java index eab48ae..b8bfe5c 100644 --- a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/JavaWriterTests.java +++ b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/JavaWriterTests.java @@ -1073,20 +1073,57 @@ public class JavaWriterTests { // === Switch statements === @Test - public void switchStatement() throws IOException { + public void switchStatementWithCaseConstants() throws IOException { var java = new JavaSwitchStatement( new JavaRef(JavaIdentifier.of("x")), List.of( new JavaSwitchRule( - JavaTypeRef.topLevel(JavaPackageName.of("org", "example"), JavaIdentifier.of("A")), - JavaIdentifier.of("a"), + new JavaCaseConstant(new JavaIntegerLiteral(0)), + new JavaBlock(List.of( + new JavaReturn(new JavaIntegerLiteral(10)) + )) + ), + new JavaSwitchRule( + new JavaCaseConstant(new JavaIntegerLiteral(1)), + new JavaBlock(List.of( + new JavaReturn(new JavaIntegerLiteral(11)) + )) + ) + ) + ); + + var string = write(writer -> writer.writeBlockStatement(java)); + + assertThat(string, equalTo(""" + switch (x) { + case 0 -> { + return 10; + } + case 1 -> { + return 11; + } + }""")); + } + + @Test + public void switchStatementWithCasePatterns() throws IOException { + var java = new JavaSwitchStatement( + new JavaRef(JavaIdentifier.of("x")), + List.of( + new JavaSwitchRule( + new JavaCasePattern( + JavaTypeRef.topLevel(JavaPackageName.of("org", "example"), JavaIdentifier.of("A")), + JavaIdentifier.of("a") + ), new JavaBlock(List.of( new JavaReturn(new JavaIntegerLiteral(0)) )) ), new JavaSwitchRule( - JavaTypeRef.topLevel(JavaPackageName.of("org", "example"), JavaIdentifier.of("B")), - JavaIdentifier.of("b"), + new JavaCasePattern( + JavaTypeRef.topLevel(JavaPackageName.of("org", "example"), JavaIdentifier.of("B")), + JavaIdentifier.of("b") + ), new JavaBlock(List.of( new JavaReturn(new JavaIntegerLiteral(1)) )) diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaCaseConstantMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaCaseConstantMatcher.java new file mode 100644 index 0000000..d6f2807 --- /dev/null +++ b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaCaseConstantMatcher.java @@ -0,0 +1,39 @@ +// Generated by hobgoblin. + +package org.zwobble.hobgoblin.compiler.output.lang.java.ast; + +// Custom area start: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCaseConstantMatcher imports +// Custom area end: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCaseConstantMatcher imports + +public class JavaCaseConstantMatcher implements org.zwobble.precisely.Matcher<java.lang.Object> { + public static org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCaseConstantMatcher isJavaCaseConstant() { + return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCaseConstantMatcher(java.util.List.of()); + } + + private final java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCaseConstant>> submatchers; + + private JavaCaseConstantMatcher(java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCaseConstant>> 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.java.ast.JavaCaseConstant.class, this.submatchers); + } + + public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCaseConstantMatcher withValue(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaExpression> value) { + var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCaseConstant>>(this.submatchers); + submatchers.add(org.zwobble.precisely.Matchers.has("value", org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCaseConstant::value, value)); + return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCaseConstantMatcher(submatchers); + } + + // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCaseConstantMatcher body + // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCaseConstantMatcher body +} diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaCasePatternMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaCasePatternMatcher.java new file mode 100644 index 0000000..b923926 --- /dev/null +++ b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaCasePatternMatcher.java @@ -0,0 +1,45 @@ +// Generated by hobgoblin. + +package org.zwobble.hobgoblin.compiler.output.lang.java.ast; + +// Custom area start: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCasePatternMatcher imports +// Custom area end: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCasePatternMatcher imports + +public class JavaCasePatternMatcher implements org.zwobble.precisely.Matcher<java.lang.Object> { + public static org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCasePatternMatcher isJavaCasePattern() { + return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCasePatternMatcher(java.util.List.of()); + } + + private final java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCasePattern>> submatchers; + + private JavaCasePatternMatcher(java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCasePattern>> 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.java.ast.JavaCasePattern.class, this.submatchers); + } + + public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCasePatternMatcher withType(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaTypeRef> type) { + var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCasePattern>>(this.submatchers); + submatchers.add(org.zwobble.precisely.Matchers.has("type", org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCasePattern::type, type)); + return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCasePatternMatcher(submatchers); + } + + public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCasePatternMatcher withVariableName(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier> variableName) { + var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCasePattern>>(this.submatchers); + submatchers.add(org.zwobble.precisely.Matchers.has("variableName", org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCasePattern::variableName, variableName)); + return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCasePatternMatcher(submatchers); + } + + // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCasePatternMatcher body + // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCasePatternMatcher body +} diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaSwitchRuleMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaSwitchRuleMatcher.java index fc6f33d..a505382 100644 --- a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaSwitchRuleMatcher.java +++ b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaSwitchRuleMatcher.java @@ -28,15 +28,9 @@ public class JavaSwitchRuleMatcher implements org.zwobble.precisely.Matcher<java return org.zwobble.precisely.Matchers.instanceOf(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaSwitchRule.class, this.submatchers); } - public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaSwitchRuleMatcher withType(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaTypeRef> type) { + public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaSwitchRuleMatcher withLabel(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaSwitchLabel> label) { var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaSwitchRule>>(this.submatchers); - submatchers.add(org.zwobble.precisely.Matchers.has("type", org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaSwitchRule::type, type)); - return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaSwitchRuleMatcher(submatchers); - } - - public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaSwitchRuleMatcher withVariableName(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier> variableName) { - var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaSwitchRule>>(this.submatchers); - submatchers.add(org.zwobble.precisely.Matchers.has("variableName", org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaSwitchRule::variableName, variableName)); + submatchers.add(org.zwobble.precisely.Matchers.has("label", org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaSwitchRule::label, label)); return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaSwitchRuleMatcher(submatchers); } |
