summaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2026-09-27 10:47:31 +0100
committerMichael Williamson <mike@zwobble.org>2026-09-27 10:47:31 +0100
commit44bc89a7d3c587d26110983a806f933ac3de4333 (patch)
treef80895a3135a0aac77680cb023d4789a0dcee5be /src/main/java
parentb70f537b17bd0aa5a06635b5c34e79613e5e5ce9 (diff)
Extract TypescriptNamedExport
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/org/zwobble/hobgoblin/compiler/output/generators/typescripttypes/TypescriptTypesGenerator.java12
-rw-r--r--src/main/java/org/zwobble/hobgoblin/compiler/output/lang/typescript/TypescriptWriter.java6
-rw-r--r--src/main/java/org/zwobble/hobgoblin/compiler/output/lang/typescript/ast/TypescriptExportNamesStatement.java26
-rw-r--r--src/main/java/org/zwobble/hobgoblin/compiler/output/lang/typescript/ast/TypescriptNamedExport.java36
4 files changed, 62 insertions, 18 deletions
diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/typescripttypes/TypescriptTypesGenerator.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/typescripttypes/TypescriptTypesGenerator.java
index 293143c..e80e298 100644
--- a/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/typescripttypes/TypescriptTypesGenerator.java
+++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/typescripttypes/TypescriptTypesGenerator.java
@@ -205,7 +205,7 @@ public class TypescriptTypesGenerator implements Generator {
)
),
new TypescriptExportNamesStatement(List.of(
- typescriptTypeName
+ new TypescriptNamedExport(typescriptTypeName)
))
)
));
@@ -330,7 +330,9 @@ public class TypescriptTypesGenerator implements Generator {
body,
structDefinition.docComment()
),
- new TypescriptExportNamesStatement(List.of(typescriptTypeName))
+ new TypescriptExportNamesStatement(List.of(
+ new TypescriptNamedExport(typescriptTypeName)
+ ))
);
}
@@ -353,7 +355,11 @@ public class TypescriptTypesGenerator implements Generator {
)
),
// TODO: represent type exports properly in AST
- new TypescriptExportNamesStatement(List.of(TypescriptIdentifier.of("type " + typescriptTypeName.value())))
+ new TypescriptExportNamesStatement(List.of(
+ new TypescriptNamedExport(
+ TypescriptIdentifier.of("type " + typescriptTypeName.value())
+ )
+ ))
);
}
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 18a2475..764ebe7 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
@@ -183,8 +183,10 @@ public class TypescriptWriter implements AutoCloseable {
this.writer.write("export {");
writeWithSeparator(
- exportNamesStatement.names(),
- this::writeIdentifier,
+ exportNamesStatement.exports(),
+ export -> {
+ this.writeIdentifier(export.exportName());
+ },
() -> this.writer.write(", ")
);
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
index 4912f68..580ab1b 100644
--- 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
@@ -6,33 +6,33 @@ package org.zwobble.hobgoblin.compiler.output.lang.typescript.ast;
// 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
+ java.util.List<org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptNamedExport> exports
) 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
+ java.util.List<org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptNamedExport> exports
) 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);
+ return new org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptExportNamesStatement(exports);
}
- 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 withExports(java.util.List<org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptNamedExport> exports) {
+ return new org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptExportNamesStatement.Builder(exports);
}
- 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 addExport(org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptNamedExport export) {
+ var exports = new java.util.ArrayList<org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptNamedExport>(this.exports);
+ exports.add(export);
+ return new org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptExportNamesStatement.Builder(exports);
}
- 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);
+ public org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptExportNamesStatement.Builder addExport(org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptNamedExport.Builder export) {
+ var exports = new java.util.ArrayList<org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptNamedExport>(this.exports);
+ exports.add(export.build());
+ return new org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptExportNamesStatement.Builder(exports);
}
// Custom area start: org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptExportNamesStatement.Builder body
diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/typescript/ast/TypescriptNamedExport.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/typescript/ast/TypescriptNamedExport.java
new file mode 100644
index 0000000..47048c4
--- /dev/null
+++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/typescript/ast/TypescriptNamedExport.java
@@ -0,0 +1,36 @@
+// Generated by hobgoblin.
+
+package org.zwobble.hobgoblin.compiler.output.lang.typescript.ast;
+
+// Custom area start: org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptNamedExport imports
+// Custom area end: org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptNamedExport imports
+
+public record TypescriptNamedExport(
+ org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptIdentifier exportName
+) {
+ public static org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptNamedExport.Builder arbitrary() {
+ return new org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptNamedExport.Builder(org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptIdentifier.arbitrary().build());
+ }
+
+ public record Builder(
+ org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptIdentifier exportName
+ ) {
+ public org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptNamedExport build() {
+ return new org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptNamedExport(exportName);
+ }
+
+ public org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptNamedExport.Builder withExportName(org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptIdentifier exportName) {
+ return new org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptNamedExport.Builder(exportName);
+ }
+
+ public org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptNamedExport.Builder withExportName(org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptIdentifier.Builder exportName) {
+ return new org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptNamedExport.Builder(exportName.build());
+ }
+
+ // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptNamedExport.Builder body
+ // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptNamedExport.Builder body
+ }
+
+ // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptNamedExport body
+ // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptNamedExport body
+}