From 94ca8de6bc11f194bdf3a0415aad2eb66e222c45 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Fri, 4 Sep 2026 15:22:06 +0100 Subject: Add custom code to TypeScript output --- .../lang/typescript/TypescriptWriterTests.java | 24 +++++++++++++ .../ast/TypescriptCustomAreaMatcher.java | 41 ++++++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 src/test/java/org/zwobble/hobgoblin/compiler/output/lang/typescript/ast/TypescriptCustomAreaMatcher.java (limited to 'src/test/java') diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/typescript/TypescriptWriterTests.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/typescript/TypescriptWriterTests.java index a5081d0..56c51f5 100644 --- a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/typescript/TypescriptWriterTests.java +++ b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/typescript/TypescriptWriterTests.java @@ -25,6 +25,11 @@ public class TypescriptWriterTests { assertThat(string, equalTo(""" // Generated by hobgoblin. + // Custom area start: imports + // Custom area end: imports + + // Custom area start: body + // Custom area end: body """ )); } @@ -45,11 +50,21 @@ public class TypescriptWriterTests { assertThat(string, equalTo(""" // Generated by hobgoblin. + // Custom area start: imports + // Custom area end: imports + class X { + // Custom area start: X, body + // Custom area end: X, body } class Y { + // Custom area start: Y, body + // Custom area end: Y, body } + + // Custom area start: body + // Custom area end: body """ )); } @@ -68,6 +83,8 @@ public class TypescriptWriterTests { assertThat(string, equalTo(""" class X { + // Custom area start: X, body + // Custom area end: X, body }""" )); } @@ -84,6 +101,8 @@ public class TypescriptWriterTests { assertThat(string, equalTo(""" class X { + // Custom area start: X, body + // Custom area end: X, body }""" )); } @@ -110,6 +129,9 @@ public class TypescriptWriterTests { public a; public b; + + // Custom area start: X, body + // Custom area end: X, body }""" )); } @@ -129,6 +151,8 @@ public class TypescriptWriterTests { * def */ class X { + // Custom area start: X, body + // Custom area end: X, body }""" )); } diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/typescript/ast/TypescriptCustomAreaMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/typescript/ast/TypescriptCustomAreaMatcher.java new file mode 100644 index 0000000..8d8a077 --- /dev/null +++ b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/typescript/ast/TypescriptCustomAreaMatcher.java @@ -0,0 +1,41 @@ +// Generated by hobgoblin. + +package org.zwobble.hobgoblin.compiler.output.lang.typescript.ast; + +// Custom area start: org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptCustomAreaMatcher imports +// Custom area end: org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptCustomAreaMatcher imports + +public final class TypescriptCustomAreaMatcher implements org.zwobble.precisely.Matcher { + public static org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptCustomAreaMatcher isTypescriptCustomArea() { + return new org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptCustomAreaMatcher(java.util.List.of()); + } + + private final java.util.List> submatchers; + + private TypescriptCustomAreaMatcher( + 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.typescript.ast.TypescriptCustomArea.class, this.submatchers); + } + + public org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptCustomAreaMatcher withName(org.zwobble.precisely.Matcher name) { + var submatchers = new java.util.ArrayList>(this.submatchers); + submatchers.add(org.zwobble.precisely.Matchers.has("name", org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptCustomArea::name, (org.zwobble.precisely.Matcher) name)); + return new org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptCustomAreaMatcher(submatchers); + } + + // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptCustomAreaMatcher body + // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptCustomAreaMatcher body +} -- cgit v1.2.3