summaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2026-08-30 11:16:26 +0100
committerMichael Williamson <mike@zwobble.org>2026-08-30 11:17:39 +0100
commit9de4242330fe137133327533f24073613da8d201 (patch)
treea921ea5a3a1c3c331027d24c3b58ce2fdfe5b0a4 /src/main/java
parentf0f663b188cdc365628511636ea92946d2d1842c (diff)
Add export names statement to TypeScript AST
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/org/zwobble/hobgoblin/compiler/output/lang/typescript/TypescriptWriter.java18
-rw-r--r--src/main/java/org/zwobble/hobgoblin/compiler/output/lang/typescript/ast/TypescriptExportNamesStatement.java44
-rw-r--r--src/main/java/org/zwobble/hobgoblin/compiler/output/lang/typescript/ast/TypescriptStatement.java2
3 files changed, 63 insertions, 1 deletions
diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/typescript/TypescriptWriter.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/typescript/TypescriptWriter.java
index b2674c6..99ad2e4 100644
--- a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/typescript/TypescriptWriter.java
+++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/typescript/TypescriptWriter.java
@@ -72,6 +72,10 @@ public class TypescriptWriter implements AutoCloseable {
this.writeClassDeclaration(classDeclaration);
}
+ case TypescriptExportNamesStatement exportNamesStatement -> {
+ this.writeExportNamesStatement(exportNamesStatement);
+ }
+
case TypescriptExpressionStatement expressionStatement -> {
this.writeExpressionStatement(expressionStatement);
}
@@ -102,6 +106,20 @@ public class TypescriptWriter implements AutoCloseable {
this.writer.write("}");
}
+ private void writeExportNamesStatement(
+ TypescriptExportNamesStatement exportNamesStatement
+ ) throws IOException {
+ this.writer.write("export {");
+
+ writeWithSeparator(
+ exportNamesStatement.names(),
+ this::writeIdentifier,
+ () -> this.writer.write(", ")
+ );
+
+ this.writer.write("};");
+ }
+
private void writeExpressionStatement(
TypescriptExpressionStatement expressionStatement
) throws IOException {
diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/typescript/ast/TypescriptExportNamesStatement.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/typescript/ast/TypescriptExportNamesStatement.java
new file mode 100644
index 0000000..4912f68
--- /dev/null
+++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/typescript/ast/TypescriptExportNamesStatement.java
@@ -0,0 +1,44 @@
+// Generated by hobgoblin.
+
+package org.zwobble.hobgoblin.compiler.output.lang.typescript.ast;
+
+// Custom area start: org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptExportNamesStatement imports
+// Custom area end: org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptExportNamesStatement imports
+
+public record TypescriptExportNamesStatement(
+ java.util.List<org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptIdentifier> names
+) implements org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptStatement {
+ public static org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptExportNamesStatement.Builder arbitrary() {
+ return new org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptExportNamesStatement.Builder(java.util.List.of());
+ }
+
+ public record Builder(
+ java.util.List<org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptIdentifier> names
+ ) implements org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptStatement.Builder {
+ public org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptExportNamesStatement build() {
+ return new org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptExportNamesStatement(names);
+ }
+
+ public org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptExportNamesStatement.Builder withNames(java.util.List<org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptIdentifier> names) {
+ return new org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptExportNamesStatement.Builder(names);
+ }
+
+ public org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptExportNamesStatement.Builder addName(org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptIdentifier name) {
+ var names = new java.util.ArrayList<org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptIdentifier>(this.names);
+ names.add(name);
+ return new org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptExportNamesStatement.Builder(names);
+ }
+
+ public org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptExportNamesStatement.Builder addName(org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptIdentifier.Builder name) {
+ var names = new java.util.ArrayList<org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptIdentifier>(this.names);
+ names.add(name.build());
+ return new org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptExportNamesStatement.Builder(names);
+ }
+
+ // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptExportNamesStatement.Builder body
+ // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptExportNamesStatement.Builder body
+ }
+
+ // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptExportNamesStatement body
+ // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptExportNamesStatement body
+}
diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/typescript/ast/TypescriptStatement.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/typescript/ast/TypescriptStatement.java
index 9a47c84..6d24493 100644
--- a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/typescript/ast/TypescriptStatement.java
+++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/typescript/ast/TypescriptStatement.java
@@ -5,7 +5,7 @@ package org.zwobble.hobgoblin.compiler.output.lang.typescript.ast;
// Custom area start: org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptStatement imports
// Custom area end: org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptStatement imports
-public sealed interface TypescriptStatement permits org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptClassDeclaration, org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptExpressionStatement {
+public sealed interface TypescriptStatement permits org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptClassDeclaration, org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptExportNamesStatement, org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptExpressionStatement {
public interface Builder {
public org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptStatement build();