summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--examples/01-struct/hobgoblin.json57
-rw-r--r--src/main/java/org/zwobble/hobgoblin/compiler/config/ProjectConfig.java4
-rw-r--r--src/main/java/org/zwobble/hobgoblin/compiler/output/generators/javapreciselymatchers/JavaPreciselyMatchersGenerator.java38
3 files changed, 48 insertions, 1 deletions
diff --git a/examples/01-struct/hobgoblin.json5 b/examples/01-struct/hobgoblin.json5
index 1ec9568..9d2d1b4 100644
--- a/examples/01-struct/hobgoblin.json5
+++ b/examples/01-struct/hobgoblin.json5
@@ -5,5 +5,10 @@
path: "output/java/src/gen/java",
packageName: "org.zwobble.example.types"
},
+ {
+ generator: "java-precisely-matchers",
+ path: "output/java/src/gen/java",
+ packageName: "org.zwobble.example.types",
+ },
],
-}
+} \ No newline at end of file
diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/config/ProjectConfig.java b/src/main/java/org/zwobble/hobgoblin/compiler/config/ProjectConfig.java
index 6f8eb4e..6126a0c 100644
--- a/src/main/java/org/zwobble/hobgoblin/compiler/config/ProjectConfig.java
+++ b/src/main/java/org/zwobble/hobgoblin/compiler/config/ProjectConfig.java
@@ -1,6 +1,7 @@
package org.zwobble.hobgoblin.compiler.config;
import org.zwobble.hobgoblin.compiler.output.generators.Generator;
+import org.zwobble.hobgoblin.compiler.output.generators.javapreciselymatchers.JavaPreciselyMatchersGenerator;
import org.zwobble.hobgoblin.compiler.output.generators.javatypes.JavaTypesGenerator;
import org.zwobble.json5.reader.Json5ObjectReader;
import org.zwobble.sourcetext.SourceText;
@@ -36,6 +37,9 @@ public record ProjectConfig(
case JavaTypesGenerator.NAME ->
JavaTypesGenerator.parseOutputConfig(projectRoot, outputJson);
+ case JavaPreciselyMatchersGenerator.NAME ->
+ JavaPreciselyMatchersGenerator.parseOutputConfig(projectRoot, outputJson);
+
default ->
throw new UnsupportedOperationException("TODO");
};
diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/javapreciselymatchers/JavaPreciselyMatchersGenerator.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/javapreciselymatchers/JavaPreciselyMatchersGenerator.java
new file mode 100644
index 0000000..a528639
--- /dev/null
+++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/javapreciselymatchers/JavaPreciselyMatchersGenerator.java
@@ -0,0 +1,38 @@
+package org.zwobble.hobgoblin.compiler.output.generators.javapreciselymatchers;
+
+import org.zwobble.hobgoblin.compiler.ast.typed.TypedNamespaceNode;
+import org.zwobble.hobgoblin.compiler.config.OutputConfig;
+import org.zwobble.hobgoblin.compiler.output.generators.Generator;
+import org.zwobble.hobgoblin.compiler.typechecker.TypesInfo;
+import org.zwobble.json5.reader.Json5ObjectReader;
+
+import java.io.IOException;
+import java.nio.file.Path;
+import java.util.List;
+
+public class JavaPreciselyMatchersGenerator implements Generator {
+ public static final String NAME = "java-precisely-matchers";
+
+ public static OutputConfig parseOutputConfig(Path projectRoot, Json5ObjectReader output) {
+ return () -> {
+ var relativeOutputPath = output.getString("path").value();
+ var outputPath = projectRoot.resolve(relativeOutputPath);
+ var packageName = output.getString("packageName").value();
+
+ return new JavaPreciselyMatchersGenerator(outputPath, packageName);
+ };
+ }
+
+ private final Path sourceRootDirectory;
+ private final List<String> packageName;
+
+ public JavaPreciselyMatchersGenerator(Path sourceRootDirectory, String packageName) {
+ this.sourceRootDirectory = sourceRootDirectory;
+ this.packageName = List.of(packageName.split("\\."));;
+ }
+
+ @Override
+ public void generate(List<TypedNamespaceNode> namespaces, TypesInfo typesInfo) throws IOException {
+
+ }
+}