diff options
| author | Michael Williamson <mike@zwobble.org> | 2026-06-20 11:12:31 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2026-06-20 20:33:57 +0100 |
| commit | b4e83536273f228996124a33c52221ed0d0c0299 (patch) | |
| tree | 5492a055230a9d3d326c67eab4e849c2a8d0a7b5 | |
| parent | 60a89e424f6ad477ecc89760407d6999c5ee8d48 (diff) | |
Introduce Java identifier
47 files changed, 539 insertions, 329 deletions
diff --git a/hobgoblin/src/output/lang/java/ast.hob b/hobgoblin/src/output/lang/java/ast.hob index 83807cc..e77fb33 100644 --- a/hobgoblin/src/output/lang/java/ast.hob +++ b/hobgoblin/src/output/lang/java/ast.hob @@ -3,7 +3,7 @@ import {DocComment} from ast; // == Compilation units == struct JavaCompilationUnit { - field packageName: List[String]; + field packageName: List[JavaIdentifier]; field typeDeclaration: JavaTypeDeclaration; } @@ -15,12 +15,12 @@ sum JavaTypeDeclaration { variant JavaInterfaceDeclaration; variant JavaRecordDeclaration; - field name: String; + field name: JavaIdentifier; field customArea: JavaCustomArea; } struct JavaClassDeclaration { - field name: String; + field name: JavaIdentifier; field implementsTypes: List[JavaTypeRef]; field body: List[JavaClassBodyDeclaration]; field customArea: JavaCustomArea; @@ -28,18 +28,18 @@ struct JavaClassDeclaration { } struct JavaEnumDeclaration { - field name: String; + field name: JavaIdentifier; field constants: List[JavaEnumConstant]; field customArea: JavaCustomArea; field docComment: DocComment; } struct JavaEnumConstant { - field name: String; + field name: JavaIdentifier; } struct JavaInterfaceDeclaration { - field name: String; + field name: JavaIdentifier; field openness: JavaInterfaceOpenness; field permitsTypes: List[JavaTypeRef]; field body: List[JavaClassBodyDeclaration]; @@ -54,11 +54,11 @@ enum JavaInterfaceOpenness { struct JavaRecordComponent { field type: JavaTypeRef; - field name: String; + field name: JavaIdentifier; } struct JavaRecordDeclaration { - field name: String; + field name: JavaIdentifier; field components: List[JavaRecordComponent]; field implementsTypes: List[JavaTypeRef]; field body: List[JavaClassBodyDeclaration]; @@ -79,7 +79,7 @@ sum JavaClassBodyDeclaration { } struct JavaConstructorDeclaration { - field typeName: String; + field typeName: JavaIdentifier; field visibility: JavaVisibility; field params: List[JavaParam]; field body: JavaBlock; @@ -88,11 +88,11 @@ struct JavaConstructorDeclaration { struct JavaFieldDeclaration { field visibility: JavaVisibility; field type: JavaTypeRef; - field name: String; + field name: JavaIdentifier; } struct JavaMethodDeclaration { - field name: String; + field name: JavaIdentifier; field visibility: JavaVisibility; field kind: JavaMethodKind; field returnType: JavaTypeRef; @@ -109,7 +109,7 @@ enum JavaMethodKind { struct JavaParam { field type: JavaTypeRef; - field name: String; + field name: JavaIdentifier; } // == Type references == @@ -166,7 +166,7 @@ struct JavaAssignment { struct JavaFieldAccess { field receiver: JavaExpression; - field fieldName: String; + field fieldName: JavaIdentifier; } struct JavaIntegerLiteral { @@ -175,13 +175,13 @@ struct JavaIntegerLiteral { struct JavaMethodCall { field receiver: JavaExpression; - field methodName: String; + field methodName: JavaIdentifier; field args: List[JavaExpression]; } struct JavaMethodRef { field type: JavaTypeRef; - field methodName: String; + field methodName: JavaIdentifier; } struct JavaNewExpression { @@ -193,17 +193,17 @@ struct JavaNullLiteral { } struct JavaRef { - field name: String; + field name: JavaIdentifier; } struct JavaStaticFieldAccess { field type: JavaTypeRef; - field fieldName: String; + field fieldName: JavaIdentifier; } struct JavaStaticMethodCall { field type: JavaTypeRef; - field methodName: String; + field methodName: JavaIdentifier; field args: List[JavaExpression]; } @@ -211,6 +211,12 @@ struct JavaStringLiteral { field value: String; } +// == Identifiers == + +struct JavaIdentifier { + field value: String; +} + // == Custom areas == struct JavaCustomArea { diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/java/JavaGenerator.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/java/JavaGenerator.java index e68acaa..ae9a81d 100644 --- a/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/java/JavaGenerator.java +++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/java/JavaGenerator.java @@ -2,15 +2,18 @@ package org.zwobble.hobgoblin.compiler.output.generators.java; import org.zwobble.hobgoblin.compiler.output.lang.java.JavaWriter; import org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCompilationUnit; +import org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier; import org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaTypeArg; import org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaTypeRef; import org.zwobble.hobgoblin.compiler.types.*; +import org.zwobble.hobgoblin.compiler.util.Casing; import java.io.File; import java.io.IOException; import java.nio.file.Path; import java.util.ArrayList; import java.util.List; +import java.util.stream.Collectors; public class JavaGenerator { private final JavaGeneratorConfig config; @@ -25,22 +28,24 @@ public class JavaGenerator { ) throws IOException { for (var javaCompilationUnit : javaCompilationUnits) { var javaCompilationUnitPath = sourceRootDirectory - .resolve(String.join(File.separator, javaCompilationUnit.packageName())) - .resolve(javaCompilationUnit.typeDeclaration().name() + ".java"); + .resolve(javaCompilationUnit.packageName().stream().map(JavaIdentifier::value).collect(Collectors.joining(File.separator))) + .resolve(javaCompilationUnit.typeDeclaration().name().value() + ".java"); try (var writer = JavaWriter.file(javaCompilationUnitPath)) { writer.writeCompilationUnit(javaCompilationUnit); } } } - public List<String> namespaceToJavaPackageParts(NamespaceName namespaceName) { + public List<JavaIdentifier> namespaceToJavaPackageParts(NamespaceName namespaceName) { var ancestorNamespaceName = namespaceName; var remainingNamespaceNameParts = new ArrayList<String>(); while (!ancestorNamespaceName.isRoot()) { var namespaceConfig = this.config.namespaceConfig(ancestorNamespaceName); if (namespaceConfig.isPresent()) { var packageParts = new ArrayList<>(namespaceConfig.get().packageName()); - packageParts.addAll(remainingNamespaceNameParts.reversed()); + for (var namespaceNamePart : remainingNamespaceNameParts.reversed()) { + packageParts.add(generatePackageNamePart(namespaceNamePart)); + } return packageParts; } remainingNamespaceNameParts.add(ancestorNamespaceName.parts().getLast()); @@ -48,10 +53,28 @@ public class JavaGenerator { } var packageParts = new ArrayList<>(this.config.packageName()); - packageParts.addAll(namespaceName.parts()); + for (var namespaceNamePart : namespaceName.parts()) { + packageParts.add(generatePackageNamePart(namespaceNamePart)); + } return packageParts; } + public JavaIdentifier generateEnumConstantName(String name) { + return new JavaIdentifier(Casing.lowerCamelCaseToUpperCase(name)); + } + + public JavaIdentifier generateFieldName(String name) { + return new JavaIdentifier(name); + } + + public JavaIdentifier generatePackageNamePart(String part) { + return JavaIdentifier.of(part); + } + + public JavaIdentifier generateTypeName(String name) { + return new JavaIdentifier(name); + } + public JavaTypeRef generateTypeRef(Type type) { return this.generateTypeRef(type, false); } @@ -76,7 +99,10 @@ public class JavaGenerator { } case EnumType enumType -> - JavaTypeRef.topLevel(namespaceToJavaPackageParts(enumType.namespaceName()), enumType.name()); + JavaTypeRef.topLevel( + namespaceToJavaPackageParts(enumType.namespaceName()), + generateTypeName(enumType.name()) + ); case SimpleNativeType simpleNativeType -> { var nativeTypeConfig = this.config.nativeTypeConfig(simpleNativeType); @@ -90,16 +116,22 @@ public class JavaGenerator { } else { yield JavaTypeRef.topLevel( namespaceToJavaPackageParts(simpleNativeType.namespaceName()), - simpleNativeType.name() + generateTypeName(simpleNativeType.name()) ); } } case StructType structType -> - JavaTypeRef.topLevel(namespaceToJavaPackageParts(structType.namespaceName()), structType.name()); + JavaTypeRef.topLevel( + namespaceToJavaPackageParts(structType.namespaceName()), + generateTypeName(structType.name()) + ); case SumType sumType -> - JavaTypeRef.topLevel(namespaceToJavaPackageParts(sumType.namespaceName()), sumType.name()); + JavaTypeRef.topLevel( + namespaceToJavaPackageParts(sumType.namespaceName()), + generateTypeName(sumType.name()) + ); case TypeLevelValueType typeLevelValueType -> throw new UnsupportedOperationException("TODO"); diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/java/JavaGeneratorConfig.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/java/JavaGeneratorConfig.java index 9be9eed..7eb2c32 100644 --- a/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/java/JavaGeneratorConfig.java +++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/java/JavaGeneratorConfig.java @@ -1,10 +1,7 @@ package org.zwobble.hobgoblin.compiler.output.generators.java; import org.zwobble.hobgoblin.compiler.builtins.NativeTypes; -import org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIntegerLiteral; -import org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaStaticMethodCall; -import org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaStringLiteral; -import org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaTypeRef; +import org.zwobble.hobgoblin.compiler.output.lang.java.ast.*; import org.zwobble.hobgoblin.compiler.parser.Parser; import org.zwobble.hobgoblin.compiler.types.NamespaceName; import org.zwobble.hobgoblin.compiler.types.SimpleNativeType; @@ -13,7 +10,7 @@ import org.zwobble.json5.reader.Json5ObjectReader; import java.util.*; public record JavaGeneratorConfig( - List<String> packageName, + List<JavaIdentifier> packageName, Map<NamespaceName, JavaNamespaceConfig> namespaceConfigs, Map<SimpleNativeType, JavaNativeTypeConfig> nativeTypeConfigs ) { @@ -23,7 +20,7 @@ public record JavaGeneratorConfig( var nativeTypeConfigs = parseNativeTypeConfigs(output); return new JavaGeneratorConfig( - Arrays.asList(packageName.split("\\.")), + parseJavaPackageName(packageName), namespaceConfigs, nativeTypeConfigs ); @@ -37,7 +34,7 @@ public record JavaGeneratorConfig( var hobgoblinNamespace = Parser.parseNamespaceName(hobgoblinNamespaceString); var javaPackageString = namespaceJson.getString("java").value(); - var javaPackage = Arrays.asList(javaPackageString.split("\\.")); + var javaPackage = parseJavaPackageName(javaPackageString); namespaceConfigs.put(hobgoblinNamespace, new JavaNamespaceConfig(javaPackage)); } @@ -58,7 +55,9 @@ public record JavaGeneratorConfig( ); var javaTypeString = nativeTypeJson.getString("java").value(); - var javaTypeParts = Arrays.asList(javaTypeString.split("\\.")); + var javaTypeParts = Arrays.stream(javaTypeString.split("\\.")) + .map(JavaIdentifier::of) + .toList(); var javaTypeRef = JavaTypeRef.topLevel(javaTypeParts.subList(0, javaTypeParts.size() - 1), javaTypeParts.getLast()); nativeTypeConfigs.put(hobgoblinType, new JavaNativeTypeConfig(javaTypeRef, Optional.empty(), Optional.empty())); @@ -68,12 +67,18 @@ public record JavaGeneratorConfig( return nativeTypeConfigs; } + private static List<JavaIdentifier> parseJavaPackageName(String packageName) { + return Arrays.stream(packageName.split("\\.")) + .map(JavaIdentifier::of) + .toList(); + } + private static final Map<SimpleNativeType, JavaNativeTypeConfig> DEFAULT_NATIVE_TYPE_CONFIGS = Map.ofEntries( Map.entry(NativeTypes.INT_32, JavaNativeTypeConfig.primitive(JavaTypeRef.INT, JavaTypeRef.INT_BOXED, new JavaIntegerLiteral(0))), Map.entry(NativeTypes.INT_64, JavaNativeTypeConfig.primitive(JavaTypeRef.LONG, JavaTypeRef.LONG_BOXED, new JavaIntegerLiteral(0))), Map.entry(NativeTypes.STRING, JavaNativeTypeConfig.of(JavaTypeRef.STRING, new JavaStringLiteral(""))), - Map.entry(NativeTypes.LIST_INNER, JavaNativeTypeConfig.of(JavaTypeRef.LIST, new JavaStaticMethodCall(JavaTypeRef.LIST, "of", List.of()))), - Map.entry(NativeTypes.OPTION_INNER, JavaNativeTypeConfig.of(JavaTypeRef.OPTIONAL, new JavaStaticMethodCall(JavaTypeRef.OPTIONAL, "empty", List.of()))) + Map.entry(NativeTypes.LIST_INNER, JavaNativeTypeConfig.of(JavaTypeRef.LIST, new JavaStaticMethodCall(JavaTypeRef.LIST, JavaIdentifier.of("of"), List.of()))), + Map.entry(NativeTypes.OPTION_INNER, JavaNativeTypeConfig.of(JavaTypeRef.OPTIONAL, new JavaStaticMethodCall(JavaTypeRef.OPTIONAL, JavaIdentifier.of("empty"), List.of()))) ); public Optional<JavaNativeTypeConfig> nativeTypeConfig(SimpleNativeType type) { diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/java/JavaNamespaceConfig.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/java/JavaNamespaceConfig.java index 3c313cd..4e6d8d8 100644 --- a/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/java/JavaNamespaceConfig.java +++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/java/JavaNamespaceConfig.java @@ -1,6 +1,8 @@ package org.zwobble.hobgoblin.compiler.output.generators.java; +import org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier; + import java.util.List; -public record JavaNamespaceConfig(List<String> packageName) { +public record JavaNamespaceConfig(List<JavaIdentifier> packageName) { } 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 index 8cd8b40..b8a634c 100644 --- 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 @@ -85,22 +85,20 @@ public class JavaPreciselyMatchersGenerator implements Generator { TypedStructDefinitionNode structDefinition, Context context ) { - var matcherTypeName = structDefinition.name() + "Matcher"; + var matcherTypeName = this.javaGenerator.generateTypeName(structDefinition.name() + "Matcher"); var structType = structDefinition.type(); - var javaStructTypeRef = JavaTypeRef.topLevel( - namespaceToJavaPackageParts(structType.namespaceName()), - structDefinition.name() - ); + var javaStructTypeRef = this.javaGenerator.generateTypeRef(structType); var javaMatcherTypeRef = JavaTypeRef.topLevel( namespaceToJavaPackageParts(structType.namespaceName()), matcherTypeName ); + var submatchersIdentifier = JavaIdentifier.of("submatchers"); var methods = new ArrayList<JavaClassBodyDeclaration>(List.of( new JavaMethodDeclaration( - "is" + lowerCamelCaseToUpperCamelCase(structDefinition.name()), + this.javaGenerator.generateFieldName("is" + lowerCamelCaseToUpperCamelCase(structDefinition.name())), JavaVisibility.PUBLIC, JavaMethodKind.STATIC, javaMatcherTypeRef, @@ -109,7 +107,7 @@ public class JavaPreciselyMatchersGenerator implements Generator { new JavaReturn(new JavaNewExpression( javaMatcherTypeRef, List.of( - new JavaStaticMethodCall(JavaTypeRef.LIST, "of", List.of()) + new JavaStaticMethodCall(JavaTypeRef.LIST, JavaIdentifier.of("of"), List.of()) ) )) )) @@ -117,7 +115,7 @@ public class JavaPreciselyMatchersGenerator implements Generator { new JavaFieldDeclaration( JavaVisibility.PRIVATE, JavaTypeRef.list(matcherRef(JavaTypeArg.superType(javaStructTypeRef))), - "submatchers" + submatchersIdentifier ), new JavaConstructorDeclaration( matcherTypeName, @@ -125,52 +123,52 @@ public class JavaPreciselyMatchersGenerator implements Generator { List.of( new JavaParam( JavaTypeRef.list(matcherRef(JavaTypeArg.superType(javaStructTypeRef))), - "submatchers" + submatchersIdentifier ) ), new JavaBlock(List.of( new JavaExpressionStatement( new JavaAssignment( - new JavaFieldAccess(new JavaRef("this"), "submatchers"), - new JavaRef("submatchers") + new JavaFieldAccess(JavaRef.THIS, submatchersIdentifier), + new JavaRef(submatchersIdentifier) ) ) )) ), new JavaMethodDeclaration( - "match", + JavaIdentifier.of("match"), JavaVisibility.PUBLIC, JavaMethodKind.INSTANCE, MATCH_RESULT_REF, - List.of(new JavaParam(JavaTypeRef.OBJECT, "actual")), + List.of(new JavaParam(JavaTypeRef.OBJECT, JavaIdentifier.of("actual"))), new JavaBlock(List.of( new JavaReturn( new JavaMethodCall( - new JavaMethodCall(new JavaRef("this"), "toMatcher", List.of()), - "match", - List.of(new JavaRef("actual")) + new JavaMethodCall(JavaRef.THIS, JavaIdentifier.of("toMatcher"), List.of()), + JavaIdentifier.of("match"), + List.of(new JavaRef(JavaIdentifier.of("actual"))) ) ) )) ), new JavaMethodDeclaration( - "describe", + JavaIdentifier.of("describe"), JavaVisibility.PUBLIC, JavaMethodKind.INSTANCE, - JavaTypeRef.topLevel(PRECISELY_PACKAGE_NAME, "TextTree"), + TEXT_TREE_REF, List.of(), new JavaBlock(List.of( new JavaReturn( new JavaMethodCall( - new JavaMethodCall(new JavaRef("this"), "toMatcher", List.of()), - "describe", + new JavaMethodCall(JavaRef.THIS, JavaIdentifier.of("toMatcher"), List.of()), + JavaIdentifier.of("describe"), List.of() ) ) )) ), new JavaMethodDeclaration( - "toMatcher", + JavaIdentifier.of("toMatcher"), JavaVisibility.PRIVATE, JavaMethodKind.INSTANCE, matcherRef(JavaTypeRef.OBJECT), @@ -178,10 +176,11 @@ public class JavaPreciselyMatchersGenerator implements Generator { new JavaBlock(List.of( new JavaReturn(new JavaStaticMethodCall( MATCHERS_REF, - "instanceOf", + JavaIdentifier.of("instanceOf"), List.of( - new JavaStaticFieldAccess(javaStructTypeRef, "class"), - new JavaFieldAccess(new JavaRef("this"), "submatchers") + // TODO: replace with class accessor + new JavaStaticFieldAccess(javaStructTypeRef, JavaIdentifier.of("class")), + new JavaFieldAccess(JavaRef.THIS, submatchersIdentifier) ) )) )) @@ -191,13 +190,15 @@ public class JavaPreciselyMatchersGenerator implements Generator { for (var field : structDefinition.fields()) { var fieldType = field.type().value(); var javaFieldTypeRef = this.javaGenerator.generateReferenceTypeRef(fieldType); + var javaFieldName = this.javaGenerator.generateFieldName(field.name()); + methods.add(new JavaMethodDeclaration( - "with" + lowerCamelCaseToUpperCamelCase(field.name()), + this.javaGenerator.generateFieldName("with" + lowerCamelCaseToUpperCamelCase(field.name())), JavaVisibility.PUBLIC, JavaMethodKind.INSTANCE, javaMatcherTypeRef, List.of( - new JavaParam(matcherRef(JavaTypeArg.superType(javaFieldTypeRef)), field.name()) + new JavaParam(matcherRef(JavaTypeArg.superType(javaFieldTypeRef)), javaFieldName) ), new JavaBlock(List.of( // TODO: avoid using Java streams here @@ -207,31 +208,31 @@ public class JavaPreciselyMatchersGenerator implements Generator { new JavaMethodCall( new JavaStaticMethodCall( JavaTypeRef.STREAM, - "concat", + JavaIdentifier.of("concat"), List.of( new JavaMethodCall( - new JavaFieldAccess(new JavaRef("this"), "submatchers"), - "stream", + new JavaFieldAccess(JavaRef.THIS, submatchersIdentifier), + JavaIdentifier.of("stream"), List.of() ), new JavaStaticMethodCall( JavaTypeRef.STREAM, - "of", + JavaIdentifier.of("of"), List.of( new JavaStaticMethodCall( MATCHERS_REF, - "has", + JavaIdentifier.of("has"), List.of( new JavaStringLiteral(field.name()), - new JavaMethodRef(javaStructTypeRef, field.name()), - new JavaRef(field.name()) + new JavaMethodRef(javaStructTypeRef, javaFieldName), + new JavaRef(javaFieldName) ) ) ) ) ) ), - "toList", + JavaIdentifier.of("toList"), List.of() ) ) @@ -242,20 +243,14 @@ public class JavaPreciselyMatchersGenerator implements Generator { return new JavaClassDeclaration( matcherTypeName, - List.of( - JavaTypeRef.topLevelGeneric( - PRECISELY_PACKAGE_NAME, - "Matcher", - List.of(JavaTypeArg.invariant(JavaTypeRef.OBJECT)) - ) - ), + List.of(matcherRef(JavaTypeArg.invariant(JavaTypeRef.OBJECT))), methods, JavaCustomArea.forType(javaMatcherTypeRef, "body"), DocComment.EMPTY ); } - private List<String> namespaceToJavaPackageParts(NamespaceName namespaceName) { + private List<JavaIdentifier> namespaceToJavaPackageParts(NamespaceName namespaceName) { return this.javaGenerator.namespaceToJavaPackageParts(namespaceName); } @@ -280,9 +275,10 @@ public class JavaPreciselyMatchersGenerator implements Generator { } - private static final List<String> PRECISELY_PACKAGE_NAME = List.of("org", "zwobble", "precisely"); - private static final JavaTypeRef MATCH_RESULT_REF = JavaTypeRef.topLevel(PRECISELY_PACKAGE_NAME, "MatchResult"); - private static final JavaTypeRef MATCHERS_REF = JavaTypeRef.topLevel(PRECISELY_PACKAGE_NAME, "Matchers"); + private static final List<JavaIdentifier> PRECISELY_PACKAGE_NAME = List.of(JavaIdentifier.of("org"), JavaIdentifier.of("zwobble"), JavaIdentifier.of("precisely")); + private static final JavaTypeRef MATCH_RESULT_REF = JavaTypeRef.topLevel(PRECISELY_PACKAGE_NAME, JavaIdentifier.of("MatchResult")); + private static final JavaTypeRef MATCHERS_REF = JavaTypeRef.topLevel(PRECISELY_PACKAGE_NAME, JavaIdentifier.of("Matchers")); + private static final JavaTypeRef TEXT_TREE_REF = JavaTypeRef.topLevel(PRECISELY_PACKAGE_NAME, JavaIdentifier.of("TextTree")); private static JavaTypeRef matcherRef(JavaTypeRef arg) { return matcherRef(JavaTypeArg.invariant(arg)); @@ -291,7 +287,7 @@ public class JavaPreciselyMatchersGenerator implements Generator { private static JavaTypeRef matcherRef(JavaTypeArg arg) { return JavaTypeRef.topLevelGeneric( PRECISELY_PACKAGE_NAME, - "Matcher", + JavaIdentifier.of("Matcher"), List.of(arg) ); } diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/javatypes/JavaTypesGenerator.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/javatypes/JavaTypesGenerator.java index 2456f5c..c85ff5d 100644 --- a/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/javatypes/JavaTypesGenerator.java +++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/javatypes/JavaTypesGenerator.java @@ -10,7 +10,6 @@ import org.zwobble.hobgoblin.compiler.output.generators.java.JavaNativeTypeConfi import org.zwobble.hobgoblin.compiler.output.lang.java.ast.*; import org.zwobble.hobgoblin.compiler.typechecker.TypesInfo; import org.zwobble.hobgoblin.compiler.types.*; -import org.zwobble.hobgoblin.compiler.util.Casing; import org.zwobble.json5.reader.Json5ObjectReader; import java.io.IOException; @@ -21,7 +20,9 @@ import static org.zwobble.hobgoblin.compiler.util.Casing.lowerCamelCaseToUpperCa public class JavaTypesGenerator implements Generator { public static final String NAME = "java-types"; - private static final String BUILDER_TYPE_NAME = "Builder"; + private static final JavaIdentifier ARBITRARY_METHOD_NAME = new JavaIdentifier("arbitrary"); + private static final JavaIdentifier BUILDER_TYPE_NAME = new JavaIdentifier("Builder"); + private static final JavaIdentifier BUILD_METHOD_NAME = new JavaIdentifier("build"); public static OutputConfig parseOutputConfig(Path projectRoot, Json5ObjectReader output) { return () -> { @@ -106,7 +107,7 @@ public class JavaTypesGenerator implements Generator { Context context ) { return new JavaEnumDeclaration( - enumDefinition.name(), + generateTypeName(enumDefinition.name()), enumDefinition.variants().stream() .map(variant -> new JavaEnumConstant(generateEnumConstantName(variant.name()))) .toList(), @@ -122,7 +123,7 @@ public class JavaTypesGenerator implements Generator { var components = structDefinition.fields().stream() .map(field -> new JavaRecordComponent( generateTypeRef(field.type(), context), - field.name() + generateFieldName(field.name()) )) .toList(); @@ -137,12 +138,12 @@ public class JavaTypesGenerator implements Generator { .toList(); return new JavaRecordDeclaration( - structDefinition.name(), + generateTypeName(structDefinition.name()), components, implementsTypes, List.of( new JavaMethodDeclaration( - "arbitrary", + ARBITRARY_METHOD_NAME, JavaVisibility.PUBLIC, JavaMethodKind.STATIC, builderJavaTypeRef, @@ -174,7 +175,7 @@ public class JavaTypesGenerator implements Generator { var body = new ArrayList<JavaClassBodyDeclaration>(); body.add(new JavaMethodDeclaration( - "build", + BUILD_METHOD_NAME, JavaVisibility.PUBLIC, JavaMethodKind.INSTANCE, generateTypeRef(structDefinition.type(), context), @@ -188,7 +189,7 @@ public class JavaTypesGenerator implements Generator { )); for (var field : structDefinition.fields()) { - var withMethodName = "with" + lowerCamelCaseToUpperCamelCase(field.name()); + var withMethodName = generateFieldName("with" + lowerCamelCaseToUpperCamelCase(field.name())); body.add(new JavaMethodDeclaration( withMethodName, @@ -196,7 +197,7 @@ public class JavaTypesGenerator implements Generator { JavaMethodKind.INSTANCE, builderJavaTypeRef, List.of( - new JavaParam(generateTypeRef(field.type(), context), field.name()) + new JavaParam(generateTypeRef(field.type(), context), generateFieldName(field.name())) ), new JavaBlock(List.of( new JavaReturn(new JavaNewExpression( @@ -215,14 +216,14 @@ public class JavaTypesGenerator implements Generator { JavaMethodKind.INSTANCE, builderJavaTypeRef, List.of( - new JavaParam(fieldBuilderTypeRef.get(), field.name()) + new JavaParam(fieldBuilderTypeRef.get(), generateFieldName(field.name())) ), new JavaBlock(List.of( new JavaReturn(new JavaNewExpression( builderJavaTypeRef, components.stream().<JavaExpression>map(argComponent -> { - if (argComponent.name().equals(field.name())) { - return new JavaMethodCall(new JavaRef(field.name()), "build", List.of()); + if (argComponent.name().equals(generateFieldName(field.name()))) { + return new JavaMethodCall(new JavaRef(generateFieldName(field.name())), BUILD_METHOD_NAME, List.of()); } else { return new JavaRef(argComponent.name()); } @@ -252,7 +253,7 @@ public class JavaTypesGenerator implements Generator { for (var field : sumDefinition.fields()) { body.add(new JavaMethodDeclaration( - field.name(), + generateFieldName(field.name()), JavaVisibility.PUBLIC, JavaMethodKind.INSTANCE, generateTypeRef(field.type().value(), context), @@ -262,7 +263,7 @@ public class JavaTypesGenerator implements Generator { } return new JavaInterfaceDeclaration( - sumDefinition.name(), + generateTypeName(sumDefinition.name()), JavaInterfaceOpenness.SEALED, sumDefinition.variants().stream() .map(variant -> generateTypeRef(variant.type(), context)) @@ -283,7 +284,7 @@ public class JavaTypesGenerator implements Generator { List.of(), List.of( new JavaMethodDeclaration( - "build", + BUILD_METHOD_NAME, JavaVisibility.PUBLIC, JavaMethodKind.INSTANCE, generateTypeRef(sumDefinition.type(), context), @@ -296,7 +297,7 @@ public class JavaTypesGenerator implements Generator { ); } - private List<String> namespaceToJavaPackageParts(NamespaceName namespaceName) { + private List<JavaIdentifier> namespaceToJavaPackageParts(NamespaceName namespaceName) { return this.javaGenerator.namespaceToJavaPackageParts(namespaceName); } @@ -330,7 +331,7 @@ public class JavaTypesGenerator implements Generator { private JavaTypeRef generateBuilderTypeRef(NamespaceName namespaceName, String name) { var javaPackage = namespaceToJavaPackageParts(namespaceName); - return JavaTypeRef.inner(javaPackage, name, BUILDER_TYPE_NAME); + return JavaTypeRef.inner(javaPackage, generateTypeName(name), BUILDER_TYPE_NAME); } private JavaExpression arbitraryValue( @@ -358,10 +359,10 @@ public class JavaTypesGenerator implements Generator { .flatMap(nativeTypeConfig -> nativeTypeConfig.arbitraryValue()) .orElseGet(() -> { var javaPackageName = namespaceToJavaPackageParts(simpleNativeType.namespaceName()); - var javaClassName = "HobgoblinNative" + lowerCamelCaseToUpperCamelCase(javaPackageName.getLast()); + var javaClassName = JavaIdentifier.of("HobgoblinNative" + lowerCamelCaseToUpperCamelCase(javaPackageName.getLast().value())); return new JavaStaticMethodCall( JavaTypeRef.topLevel(javaPackageName, javaClassName), - "arbitrary" + simpleNativeType.name(), + generateFieldName("arbitrary" + simpleNativeType.name()), List.of() ); }); @@ -369,8 +370,8 @@ public class JavaTypesGenerator implements Generator { case StructType structType -> { yield new JavaMethodCall( - new JavaStaticMethodCall(generateTypeRef(structType, context), "arbitrary", List.of()), - "build", + new JavaStaticMethodCall(generateTypeRef(structType, context), ARBITRARY_METHOD_NAME, List.of()), + BUILD_METHOD_NAME, List.of() ); } @@ -439,8 +440,16 @@ public class JavaTypesGenerator implements Generator { }; } - private static String generateEnumConstantName(String name) { - return Casing.lowerCamelCaseToUpperCase(name); + private JavaIdentifier generateEnumConstantName(String name) { + return this.javaGenerator.generateEnumConstantName(name); + } + + private JavaIdentifier generateFieldName(String name) { + return this.javaGenerator.generateFieldName(name); + } + + private JavaIdentifier generateTypeName(String name) { + return this.javaGenerator.generateTypeName(name); } private Optional<JavaNativeTypeConfig> nativeTypeConfig(SimpleNativeType type) { 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 0e5fd92..5814998 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 @@ -46,7 +46,7 @@ public class JavaWriter implements AutoCloseable { public void writeCompilationUnit(JavaCompilationUnit compilationUnit) throws IOException { this.writer.writeHeader(); this.writer.write("package "); - this.writer.write(String.join(".", compilationUnit.packageName())); + this.writePackageName(compilationUnit.packageName()); this.writer.write(";"); this.writer.newLine(); this.writer.newLine(); @@ -107,7 +107,7 @@ public class JavaWriter implements AutoCloseable { writeDocComment(classDeclaration.docComment()); this.writer.write("public class "); - this.writer.write(classDeclaration.name()); + this.writeIdentifier(classDeclaration.name()); this.writer.write(" "); this.writeImplements(classDeclaration.implementsTypes()); @@ -151,7 +151,7 @@ public class JavaWriter implements AutoCloseable { void writeConstructorDeclaration(JavaConstructorDeclaration constructor) throws IOException { writeVisibility(constructor.visibility()); this.writer.write(" "); - this.writer.write(constructor.typeName()); + this.writeIdentifier(constructor.typeName()); this.writer.write("("); writeWithSeparator( @@ -159,7 +159,7 @@ public class JavaWriter implements AutoCloseable { param -> { writeTypeRef(param.type()); writer.write(" "); - writer.write(param.name()); + this.writeIdentifier(param.name()); }, () -> writer.write(", ") ); @@ -188,7 +188,7 @@ public class JavaWriter implements AutoCloseable { private void writeEnumDeclaration(JavaEnumDeclaration enumDeclaration) throws IOException { this.writeDocComment(enumDeclaration.docComment()); this.writer.write("public enum "); - this.writer.write(enumDeclaration.name()); + this.writeIdentifier(enumDeclaration.name()); this.writer.write(" {"); this.writer.indent(); this.writer.newLine(); @@ -196,7 +196,7 @@ public class JavaWriter implements AutoCloseable { if (!enumDeclaration.constants().isEmpty()) { writeWithSeparator( enumDeclaration.constants(), - constant -> this.writer.write(constant.name()), + constant -> this.writeIdentifier(constant.name()), () -> { this.writer.write(","); this.writer.newLine(); @@ -267,7 +267,7 @@ public class JavaWriter implements AutoCloseable { private void writeFieldAccess(JavaFieldAccess fieldAccess) throws IOException { this.writeExpression(fieldAccess.receiver()); this.writer.write("."); - this.writer.write(fieldAccess.fieldName()); + this.writeIdentifier(fieldAccess.fieldName()); } private void writeFieldDeclaration(JavaFieldDeclaration fieldDeclaration) throws IOException { @@ -275,10 +275,18 @@ public class JavaWriter implements AutoCloseable { this.writer.write(" final "); this.writeTypeRef(fieldDeclaration.type()); this.writer.write(" "); - this.writer.write(fieldDeclaration.name()); + this.writeIdentifier(fieldDeclaration.name()); this.writer.write(";"); } + private void writeIdentifier(JavaIdentifier identifier) throws IOException { + this.writer.write(identifier.value()); + } + + private static void writeIdentifier(JavaIdentifier identifier, WriteString writer) throws IOException { + writer.write(identifier.value()); + } + private void writeImplements(List<JavaTypeRef> implementsTypes) throws IOException { if (!implementsTypes.isEmpty()) { this.writer.write("implements "); @@ -307,7 +315,7 @@ public class JavaWriter implements AutoCloseable { } } this.writer.write("interface "); - this.writer.write(interfaceDeclaration.name()); + this.writeIdentifier(interfaceDeclaration.name()); this.writer.write(" "); if (!interfaceDeclaration.permitsTypes().isEmpty()) { @@ -338,7 +346,7 @@ public class JavaWriter implements AutoCloseable { private void writeMethodCall(JavaMethodCall call) throws IOException { this.writeExpression(call.receiver()); this.writer.write("."); - this.writer.write(call.methodName()); + this.writeIdentifier(call.methodName()); this.writer.write("("); this.writeWithSeparator( call.args(), @@ -362,7 +370,7 @@ public class JavaWriter implements AutoCloseable { writeTypeRef(method.returnType()); this.writer.write(" "); - this.writer.write(method.name()); + this.writeIdentifier(method.name()); this.writer.write("("); writeWithSeparator( @@ -370,7 +378,7 @@ public class JavaWriter implements AutoCloseable { param -> { writeTypeRef(param.type()); writer.write(" "); - writer.write(param.name()); + this.writeIdentifier(param.name()); }, () -> writer.write(", ") ); @@ -395,7 +403,7 @@ public class JavaWriter implements AutoCloseable { private void writeMethodRef(JavaMethodRef methodRef) throws IOException { this.writeTypeRef(methodRef.type()); this.writer.write("::"); - this.writer.write(methodRef.methodName()); + this.writeIdentifier(methodRef.methodName()); } private void writeNewExpression(JavaNewExpression newExpression) throws IOException { @@ -414,11 +422,19 @@ public class JavaWriter implements AutoCloseable { this.writer.write("null"); } + private void writePackageName(List<JavaIdentifier> packageName) throws IOException { + writeWithSeparator( + packageName, + this::writeIdentifier, + () -> this.writer.write(".") + ); + } + private void writeRecordDeclaration(JavaRecordDeclaration recordDeclaration) throws IOException { writeDocComment(recordDeclaration.docComment()); this.writer.write("public record "); - this.writer.write(recordDeclaration.name()); + this.writeIdentifier(recordDeclaration.name()); this.writer.write("("); writeWithSeparator( @@ -426,7 +442,7 @@ public class JavaWriter implements AutoCloseable { component -> { writeTypeRef(component.type()); writer.write(" "); - writer.write(component.name()); + this.writeIdentifier(component.name()); }, () -> writer.write(", ") ); @@ -452,7 +468,7 @@ public class JavaWriter implements AutoCloseable { } private void writeRef(JavaRef ref) throws IOException { - this.writer.write(ref.name()); + this.writeIdentifier(ref.name()); } private void writeReturnStatement(JavaReturn returnStatement) throws IOException { @@ -464,13 +480,13 @@ public class JavaWriter implements AutoCloseable { private void writeStaticFieldAccess(JavaStaticFieldAccess staticFieldAccess) throws IOException { this.writeTypeRef(staticFieldAccess.type()); this.writer.write("."); - this.writer.write(staticFieldAccess.fieldName()); + this.writeIdentifier(staticFieldAccess.fieldName()); } private void writeStaticMethodCall(JavaStaticMethodCall call) throws IOException { this.writeTypeRef(call.type()); this.writer.write("."); - this.writer.write(call.methodName()); + this.writeIdentifier(call.methodName()); this.writer.write("("); this.writeWithSeparator( call.args(), @@ -505,13 +521,13 @@ public class JavaWriter implements AutoCloseable { private static void writeTypeRef(JavaTypeRef type, WriteString writer) throws IOException { for (var part : type.packageName()) { - writer.write(part); + writeIdentifier(part, writer); writer.write("."); } writeWithSeparator( type.typeNames(), - writer::write, + typeName -> writeIdentifier(typeName, writer), () -> writer.write(".") ); diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaClassDeclaration.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaClassDeclaration.java index 434d536..940742e 100644 --- a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaClassDeclaration.java +++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaClassDeclaration.java @@ -2,20 +2,24 @@ package org.zwobble.hobgoblin.compiler.output.lang.java.ast; -public record JavaClassDeclaration(String name, java.util.List<org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaTypeRef> implementsTypes, java.util.List<org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaClassBodyDeclaration> body, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCustomArea customArea, org.zwobble.hobgoblin.compiler.ast.DocComment docComment) implements org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaTypeDeclaration, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaClassBodyDeclaration { +public record JavaClassDeclaration(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier name, java.util.List<org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaTypeRef> implementsTypes, java.util.List<org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaClassBodyDeclaration> body, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCustomArea customArea, org.zwobble.hobgoblin.compiler.ast.DocComment docComment) implements org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaTypeDeclaration, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaClassBodyDeclaration { public static org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaClassDeclaration.Builder arbitrary() { - return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaClassDeclaration.Builder("", java.util.List.of(), java.util.List.of(), org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCustomArea.arbitrary().build(), org.zwobble.hobgoblin.compiler.ast.HobgoblinNativeAst.arbitraryDocComment()); + return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaClassDeclaration.Builder(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier.arbitrary().build(), java.util.List.of(), java.util.List.of(), org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCustomArea.arbitrary().build(), org.zwobble.hobgoblin.compiler.ast.HobgoblinNativeAst.arbitraryDocComment()); } - public record Builder(String name, java.util.List<org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaTypeRef> implementsTypes, java.util.List<org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaClassBodyDeclaration> body, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCustomArea customArea, org.zwobble.hobgoblin.compiler.ast.DocComment docComment) implements org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaTypeDeclaration.Builder, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaClassBodyDeclaration.Builder { + public record Builder(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier name, java.util.List<org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaTypeRef> implementsTypes, java.util.List<org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaClassBodyDeclaration> body, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCustomArea customArea, org.zwobble.hobgoblin.compiler.ast.DocComment docComment) implements org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaTypeDeclaration.Builder, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaClassBodyDeclaration.Builder { public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaClassDeclaration build() { return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaClassDeclaration(name, implementsTypes, body, customArea, docComment); } - public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaClassDeclaration.Builder withName(String name) { + public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaClassDeclaration.Builder withName(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier name) { return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaClassDeclaration.Builder(name, implementsTypes, body, customArea, docComment); } + public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaClassDeclaration.Builder withName(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier.Builder name) { + return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaClassDeclaration.Builder(name.build(), implementsTypes, body, customArea, docComment); + } + public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaClassDeclaration.Builder withImplementsTypes(java.util.List<org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaTypeRef> implementsTypes) { return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaClassDeclaration.Builder(name, implementsTypes, body, customArea, docComment); } diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaCompilationUnit.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaCompilationUnit.java index 252380c..42a58d0 100644 --- a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaCompilationUnit.java +++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaCompilationUnit.java @@ -2,17 +2,17 @@ package org.zwobble.hobgoblin.compiler.output.lang.java.ast; -public record JavaCompilationUnit(java.util.List<String> packageName, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaTypeDeclaration typeDeclaration) { +public record JavaCompilationUnit(java.util.List<org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier> packageName, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaTypeDeclaration typeDeclaration) { public static org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCompilationUnit.Builder arbitrary() { return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCompilationUnit.Builder(java.util.List.of(), org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaClassDeclaration.arbitrary().build()); } - public record Builder(java.util.List<String> packageName, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaTypeDeclaration typeDeclaration) { + public record Builder(java.util.List<org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier> packageName, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaTypeDeclaration typeDeclaration) { public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCompilationUnit build() { return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCompilationUnit(packageName, typeDeclaration); } - public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCompilationUnit.Builder withPackageName(java.util.List<String> packageName) { + public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCompilationUnit.Builder withPackageName(java.util.List<org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier> packageName) { return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCompilationUnit.Builder(packageName, typeDeclaration); } diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaConstructorDeclaration.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaConstructorDeclaration.java index c8d1d77..5f474b6 100644 --- a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaConstructorDeclaration.java +++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaConstructorDeclaration.java @@ -2,20 +2,24 @@ package org.zwobble.hobgoblin.compiler.output.lang.java.ast; -public record JavaConstructorDeclaration(String typeName, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaVisibility visibility, java.util.List<org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaParam> params, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaBlock body) implements org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaClassBodyDeclaration { +public record JavaConstructorDeclaration(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier typeName, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaVisibility visibility, java.util.List<org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaParam> params, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaBlock body) implements org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaClassBodyDeclaration { public static org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaConstructorDeclaration.Builder arbitrary() { - return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaConstructorDeclaration.Builder("", org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaVisibility.PUBLIC, java.util.List.of(), org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaBlock.arbitrary().build()); + return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaConstructorDeclaration.Builder(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier.arbitrary().build(), org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaVisibility.PUBLIC, java.util.List.of(), org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaBlock.arbitrary().build()); } - public record Builder(String typeName, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaVisibility visibility, java.util.List<org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaParam> params, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaBlock body) implements org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaClassBodyDeclaration.Builder { + public record Builder(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier typeName, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaVisibility visibility, java.util.List<org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaParam> params, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaBlock body) implements org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaClassBodyDeclaration.Builder { public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaConstructorDeclaration build() { return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaConstructorDeclaration(typeName, visibility, params, body); } - public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaConstructorDeclaration.Builder withTypeName(String typeName) { + public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaConstructorDeclaration.Builder withTypeName(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier typeName) { return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaConstructorDeclaration.Builder(typeName, visibility, params, body); } + public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaConstructorDeclaration.Builder withTypeName(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier.Builder typeName) { + return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaConstructorDeclaration.Builder(typeName.build(), visibility, params, body); + } + public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaConstructorDeclaration.Builder withVisibility(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaVisibility visibility) { return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaConstructorDeclaration.Builder(typeName, visibility, params, body); } diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaEnumConstant.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaEnumConstant.java index 6e7e775..1a6bb83 100644 --- a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaEnumConstant.java +++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaEnumConstant.java @@ -2,20 +2,24 @@ package org.zwobble.hobgoblin.compiler.output.lang.java.ast; -public record JavaEnumConstant(String name) { +public record JavaEnumConstant(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier name) { public static org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaEnumConstant.Builder arbitrary() { - return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaEnumConstant.Builder(""); + return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaEnumConstant.Builder(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier.arbitrary().build()); } - public record Builder(String name) { + public record Builder(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier name) { public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaEnumConstant build() { return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaEnumConstant(name); } - public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaEnumConstant.Builder withName(String name) { + public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaEnumConstant.Builder withName(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier name) { return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaEnumConstant.Builder(name); } + public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaEnumConstant.Builder withName(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier.Builder name) { + return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaEnumConstant.Builder(name.build()); + } + // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaEnumConstant.Builder body // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaEnumConstant.Builder body } diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaEnumDeclaration.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaEnumDeclaration.java index c46ae99..58d98ca 100644 --- a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaEnumDeclaration.java +++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaEnumDeclaration.java @@ -2,20 +2,24 @@ package org.zwobble.hobgoblin.compiler.output.lang.java.ast; -public record JavaEnumDeclaration(String name, java.util.List<org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaEnumConstant> constants, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCustomArea customArea, org.zwobble.hobgoblin.compiler.ast.DocComment docComment) implements org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaTypeDeclaration { +public record JavaEnumDeclaration(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier name, java.util.List<org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaEnumConstant> constants, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCustomArea customArea, org.zwobble.hobgoblin.compiler.ast.DocComment docComment) implements org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaTypeDeclaration { public static org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaEnumDeclaration.Builder arbitrary() { - return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaEnumDeclaration.Builder("", java.util.List.of(), org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCustomArea.arbitrary().build(), org.zwobble.hobgoblin.compiler.ast.HobgoblinNativeAst.arbitraryDocComment()); + return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaEnumDeclaration.Builder(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier.arbitrary().build(), java.util.List.of(), org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCustomArea.arbitrary().build(), org.zwobble.hobgoblin.compiler.ast.HobgoblinNativeAst.arbitraryDocComment()); } - public record Builder(String name, java.util.List<org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaEnumConstant> constants, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCustomArea customArea, org.zwobble.hobgoblin.compiler.ast.DocComment docComment) implements org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaTypeDeclaration.Builder { + public record Builder(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier name, java.util.List<org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaEnumConstant> constants, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCustomArea customArea, org.zwobble.hobgoblin.compiler.ast.DocComment docComment) implements org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaTypeDeclaration.Builder { public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaEnumDeclaration build() { return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaEnumDeclaration(name, constants, customArea, docComment); } - public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaEnumDeclaration.Builder withName(String name) { + public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaEnumDeclaration.Builder withName(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier name) { return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaEnumDeclaration.Builder(name, constants, customArea, docComment); } + public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaEnumDeclaration.Builder withName(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier.Builder name) { + return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaEnumDeclaration.Builder(name.build(), constants, customArea, docComment); + } + public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaEnumDeclaration.Builder withConstants(java.util.List<org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaEnumConstant> constants) { return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaEnumDeclaration.Builder(name, constants, customArea, docComment); } diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaFieldAccess.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaFieldAccess.java index 3ae942a..6ad4e18 100644 --- a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaFieldAccess.java +++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaFieldAccess.java @@ -2,12 +2,12 @@ package org.zwobble.hobgoblin.compiler.output.lang.java.ast; -public record JavaFieldAccess(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaExpression receiver, String fieldName) implements org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaExpression { +public record JavaFieldAccess(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaExpression receiver, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier fieldName) implements org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaExpression { public static org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaFieldAccess.Builder arbitrary() { - return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaFieldAccess.Builder(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIntegerLiteral.arbitrary().build(), ""); + return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaFieldAccess.Builder(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIntegerLiteral.arbitrary().build(), org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier.arbitrary().build()); } - public record Builder(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaExpression receiver, String fieldName) implements org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaExpression.Builder { + public record Builder(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaExpression receiver, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier fieldName) implements org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaExpression.Builder { public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaFieldAccess build() { return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaFieldAccess(receiver, fieldName); } @@ -20,10 +20,14 @@ public record JavaFieldAccess(org.zwobble.hobgoblin.compiler.output.lang.java.as return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaFieldAccess.Builder(receiver.build(), fieldName); } - public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaFieldAccess.Builder withFieldName(String fieldName) { + public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaFieldAccess.Builder withFieldName(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier fieldName) { return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaFieldAccess.Builder(receiver, fieldName); } + public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaFieldAccess.Builder withFieldName(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier.Builder fieldName) { + return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaFieldAccess.Builder(receiver, fieldName.build()); + } + // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaFieldAccess.Builder body // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaFieldAccess.Builder body } diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaFieldDeclaration.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaFieldDeclaration.java index 61a0d27..b87df63 100644 --- a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaFieldDeclaration.java +++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaFieldDeclaration.java @@ -2,12 +2,12 @@ package org.zwobble.hobgoblin.compiler.output.lang.java.ast; -public record JavaFieldDeclaration(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaVisibility visibility, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaTypeRef type, String name) implements org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaClassBodyDeclaration { +public record JavaFieldDeclaration(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaVisibility visibility, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaTypeRef type, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier name) implements org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaClassBodyDeclaration { public static org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaFieldDeclaration.Builder arbitrary() { - return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaFieldDeclaration.Builder(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaVisibility.PUBLIC, org.zwobble.hobgoblin.compiler.output.lang.java.ast.HobgoblinNativeAst.arbitraryJavaTypeRef(), ""); + return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaFieldDeclaration.Builder(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaVisibility.PUBLIC, 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.JavaVisibility visibility, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaTypeRef type, String name) implements org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaClassBodyDeclaration.Builder { + public record Builder(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaVisibility visibility, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaTypeRef type, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier name) implements org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaClassBodyDeclaration.Builder { public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaFieldDeclaration build() { return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaFieldDeclaration(visibility, type, name); } @@ -20,10 +20,14 @@ public record JavaFieldDeclaration(org.zwobble.hobgoblin.compiler.output.lang.ja return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaFieldDeclaration.Builder(visibility, type, name); } - public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaFieldDeclaration.Builder withName(String name) { + public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaFieldDeclaration.Builder withName(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier name) { return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaFieldDeclaration.Builder(visibility, type, name); } + public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaFieldDeclaration.Builder withName(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier.Builder name) { + return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaFieldDeclaration.Builder(visibility, type, name.build()); + } + // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaFieldDeclaration.Builder body // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaFieldDeclaration.Builder body } diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaIdentifier.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaIdentifier.java new file mode 100644 index 0000000..b7364f3 --- /dev/null +++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaIdentifier.java @@ -0,0 +1,28 @@ +// Generated by hobgoblin. + +package org.zwobble.hobgoblin.compiler.output.lang.java.ast; + +public record JavaIdentifier(String value) { + public static org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier.Builder arbitrary() { + return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier.Builder(""); + } + + public record Builder(String value) { + public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier build() { + return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier(value); + } + + public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier.Builder withValue(String value) { + return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier.Builder(value); + } + + // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier.Builder body + // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier.Builder body + } + + // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier body + public static JavaIdentifier of(String value) { + return new JavaIdentifier(value); + } + // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier body +} diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaInterfaceDeclaration.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaInterfaceDeclaration.java index cae6525..aefc444 100644 --- a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaInterfaceDeclaration.java +++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaInterfaceDeclaration.java @@ -2,20 +2,24 @@ package org.zwobble.hobgoblin.compiler.output.lang.java.ast; -public record JavaInterfaceDeclaration(String name, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaInterfaceOpenness openness, java.util.List<org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaTypeRef> permitsTypes, java.util.List<org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaClassBodyDeclaration> body, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCustomArea customArea, org.zwobble.hobgoblin.compiler.ast.DocComment docComment) implements org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaTypeDeclaration, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaClassBodyDeclaration { +public record JavaInterfaceDeclaration(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier name, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaInterfaceOpenness openness, java.util.List<org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaTypeRef> permitsTypes, java.util.List<org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaClassBodyDeclaration> body, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCustomArea customArea, org.zwobble.hobgoblin.compiler.ast.DocComment docComment) implements org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaTypeDeclaration, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaClassBodyDeclaration { public static org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaInterfaceDeclaration.Builder arbitrary() { - return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaInterfaceDeclaration.Builder("", org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaInterfaceOpenness.OPEN, java.util.List.of(), java.util.List.of(), org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCustomArea.arbitrary().build(), org.zwobble.hobgoblin.compiler.ast.HobgoblinNativeAst.arbitraryDocComment()); + return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaInterfaceDeclaration.Builder(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier.arbitrary().build(), org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaInterfaceOpenness.OPEN, java.util.List.of(), java.util.List.of(), org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCustomArea.arbitrary().build(), org.zwobble.hobgoblin.compiler.ast.HobgoblinNativeAst.arbitraryDocComment()); } - public record Builder(String name, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaInterfaceOpenness openness, java.util.List<org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaTypeRef> permitsTypes, java.util.List<org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaClassBodyDeclaration> body, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCustomArea customArea, org.zwobble.hobgoblin.compiler.ast.DocComment docComment) implements org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaTypeDeclaration.Builder, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaClassBodyDeclaration.Builder { + public record Builder(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier name, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaInterfaceOpenness openness, java.util.List<org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaTypeRef> permitsTypes, java.util.List<org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaClassBodyDeclaration> body, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCustomArea customArea, org.zwobble.hobgoblin.compiler.ast.DocComment docComment) implements org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaTypeDeclaration.Builder, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaClassBodyDeclaration.Builder { public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaInterfaceDeclaration build() { return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaInterfaceDeclaration(name, openness, permitsTypes, body, customArea, docComment); } - public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaInterfaceDeclaration.Builder withName(String name) { + public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaInterfaceDeclaration.Builder withName(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier name) { return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaInterfaceDeclaration.Builder(name, openness, permitsTypes, body, customArea, docComment); } + public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaInterfaceDeclaration.Builder withName(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier.Builder name) { + return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaInterfaceDeclaration.Builder(name.build(), openness, permitsTypes, body, customArea, docComment); + } + public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaInterfaceDeclaration.Builder withOpenness(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaInterfaceOpenness openness) { return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaInterfaceDeclaration.Builder(name, openness, permitsTypes, body, customArea, docComment); } diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaMethodCall.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaMethodCall.java index 24841c3..4eb5443 100644 --- a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaMethodCall.java +++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaMethodCall.java @@ -2,12 +2,12 @@ package org.zwobble.hobgoblin.compiler.output.lang.java.ast; -public record JavaMethodCall(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaExpression receiver, String methodName, java.util.List<org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaExpression> args) implements org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaExpression { +public record JavaMethodCall(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaExpression receiver, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier methodName, java.util.List<org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaExpression> args) implements org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaExpression { public static org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaMethodCall.Builder arbitrary() { - return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaMethodCall.Builder(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIntegerLiteral.arbitrary().build(), "", java.util.List.of()); + return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaMethodCall.Builder(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIntegerLiteral.arbitrary().build(), org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier.arbitrary().build(), java.util.List.of()); } - public record Builder(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaExpression receiver, String methodName, java.util.List<org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaExpression> args) implements org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaExpression.Builder { + public record Builder(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaExpression receiver, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier methodName, java.util.List<org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaExpression> args) implements org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaExpression.Builder { public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaMethodCall build() { return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaMethodCall(receiver, methodName, args); } @@ -20,10 +20,14 @@ public record JavaMethodCall(org.zwobble.hobgoblin.compiler.output.lang.java.ast return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaMethodCall.Builder(receiver.build(), methodName, args); } - public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaMethodCall.Builder withMethodName(String methodName) { + public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaMethodCall.Builder withMethodName(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier methodName) { return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaMethodCall.Builder(receiver, methodName, args); } + public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaMethodCall.Builder withMethodName(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier.Builder methodName) { + return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaMethodCall.Builder(receiver, methodName.build(), args); + } + public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaMethodCall.Builder withArgs(java.util.List<org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaExpression> args) { return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaMethodCall.Builder(receiver, methodName, args); } diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaMethodDeclaration.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaMethodDeclaration.java index 6665e5e..d4aa351 100644 --- a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaMethodDeclaration.java +++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaMethodDeclaration.java @@ -2,20 +2,24 @@ package org.zwobble.hobgoblin.compiler.output.lang.java.ast; -public record JavaMethodDeclaration(String name, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaVisibility visibility, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaMethodKind kind, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaTypeRef returnType, java.util.List<org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaParam> params, java.util.Optional<org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaBlock> body) implements org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaClassBodyDeclaration { +public record JavaMethodDeclaration(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier name, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaVisibility visibility, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaMethodKind kind, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaTypeRef returnType, java.util.List<org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaParam> params, java.util.Optional<org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaBlock> body) implements org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaClassBodyDeclaration { public static org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaMethodDeclaration.Builder arbitrary() { - return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaMethodDeclaration.Builder("", org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaVisibility.PUBLIC, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaMethodKind.STATIC, org.zwobble.hobgoblin.compiler.output.lang.java.ast.HobgoblinNativeAst.arbitraryJavaTypeRef(), java.util.List.of(), java.util.Optional.empty()); + return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaMethodDeclaration.Builder(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier.arbitrary().build(), org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaVisibility.PUBLIC, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaMethodKind.STATIC, org.zwobble.hobgoblin.compiler.output.lang.java.ast.HobgoblinNativeAst.arbitraryJavaTypeRef(), java.util.List.of(), java.util.Optional.empty()); } - public record Builder(String name, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaVisibility visibility, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaMethodKind kind, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaTypeRef returnType, java.util.List<org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaParam> params, java.util.Optional<org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaBlock> body) implements org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaClassBodyDeclaration.Builder { + public record Builder(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier name, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaVisibility visibility, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaMethodKind kind, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaTypeRef returnType, java.util.List<org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaParam> params, java.util.Optional<org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaBlock> body) implements org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaClassBodyDeclaration.Builder { public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaMethodDeclaration build() { return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaMethodDeclaration(name, visibility, kind, returnType, params, body); } - public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaMethodDeclaration.Builder withName(String name) { + public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaMethodDeclaration.Builder withName(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier name) { return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaMethodDeclaration.Builder(name, visibility, kind, returnType, params, body); } + public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaMethodDeclaration.Builder withName(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier.Builder name) { + return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaMethodDeclaration.Builder(name.build(), visibility, kind, returnType, params, body); + } + public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaMethodDeclaration.Builder withVisibility(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaVisibility visibility) { return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaMethodDeclaration.Builder(name, visibility, kind, returnType, params, body); } @@ -42,7 +46,7 @@ public record JavaMethodDeclaration(String name, org.zwobble.hobgoblin.compiler. // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaMethodDeclaration body public JavaMethodDeclaration( - String name, + JavaIdentifier name, JavaVisibility visibility, JavaMethodKind kind, JavaTypeRef returnType, diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaMethodRef.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaMethodRef.java index 98aa682..fb58886 100644 --- a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaMethodRef.java +++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaMethodRef.java @@ -2,12 +2,12 @@ package org.zwobble.hobgoblin.compiler.output.lang.java.ast; -public record JavaMethodRef(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaTypeRef type, String methodName) implements org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaExpression { +public record JavaMethodRef(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaTypeRef type, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier methodName) implements org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaExpression { public static org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaMethodRef.Builder arbitrary() { - return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaMethodRef.Builder(org.zwobble.hobgoblin.compiler.output.lang.java.ast.HobgoblinNativeAst.arbitraryJavaTypeRef(), ""); + return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaMethodRef.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, String methodName) implements org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaExpression.Builder { + public record Builder(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaTypeRef type, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier methodName) implements org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaExpression.Builder { public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaMethodRef build() { return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaMethodRef(type, methodName); } @@ -16,10 +16,14 @@ public record JavaMethodRef(org.zwobble.hobgoblin.compiler.output.lang.java.ast. return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaMethodRef.Builder(type, methodName); } - public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaMethodRef.Builder withMethodName(String methodName) { + public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaMethodRef.Builder withMethodName(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier methodName) { return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaMethodRef.Builder(type, methodName); } + public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaMethodRef.Builder withMethodName(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier.Builder methodName) { + return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaMethodRef.Builder(type, methodName.build()); + } + // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaMethodRef.Builder body // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaMethodRef.Builder body } diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaParam.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaParam.java index 15dc074..e7805f4 100644 --- a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaParam.java +++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaParam.java @@ -2,12 +2,12 @@ package org.zwobble.hobgoblin.compiler.output.lang.java.ast; -public record JavaParam(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaTypeRef type, String name) { +public record JavaParam(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaTypeRef type, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier name) { public static org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaParam.Builder arbitrary() { - return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaParam.Builder(org.zwobble.hobgoblin.compiler.output.lang.java.ast.HobgoblinNativeAst.arbitraryJavaTypeRef(), ""); + return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaParam.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, String name) { + public record Builder(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaTypeRef type, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier name) { public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaParam build() { return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaParam(type, name); } @@ -16,10 +16,14 @@ public record JavaParam(org.zwobble.hobgoblin.compiler.output.lang.java.ast.Java return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaParam.Builder(type, name); } - public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaParam.Builder withName(String name) { + public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaParam.Builder withName(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier name) { return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaParam.Builder(type, name); } + public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaParam.Builder withName(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier.Builder name) { + return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaParam.Builder(type, name.build()); + } + // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaParam.Builder body // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaParam.Builder body } diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaRecordComponent.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaRecordComponent.java index d3c2fc2..4de5399 100644 --- a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaRecordComponent.java +++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaRecordComponent.java @@ -2,12 +2,12 @@ package org.zwobble.hobgoblin.compiler.output.lang.java.ast; -public record JavaRecordComponent(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaTypeRef type, String name) { +public record JavaRecordComponent(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaTypeRef type, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier name) { public static org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaRecordComponent.Builder arbitrary() { - return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaRecordComponent.Builder(org.zwobble.hobgoblin.compiler.output.lang.java.ast.HobgoblinNativeAst.arbitraryJavaTypeRef(), ""); + return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaRecordComponent.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, String name) { + public record Builder(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaTypeRef type, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier name) { public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaRecordComponent build() { return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaRecordComponent(type, name); } @@ -16,10 +16,14 @@ public record JavaRecordComponent(org.zwobble.hobgoblin.compiler.output.lang.jav return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaRecordComponent.Builder(type, name); } - public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaRecordComponent.Builder withName(String name) { + public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaRecordComponent.Builder withName(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier name) { return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaRecordComponent.Builder(type, name); } + public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaRecordComponent.Builder withName(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier.Builder name) { + return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaRecordComponent.Builder(type, name.build()); + } + // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaRecordComponent.Builder body // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaRecordComponent.Builder body } diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaRecordDeclaration.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaRecordDeclaration.java index 0a11410..b7eb1f7 100644 --- a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaRecordDeclaration.java +++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaRecordDeclaration.java @@ -2,20 +2,24 @@ package org.zwobble.hobgoblin.compiler.output.lang.java.ast; -public record JavaRecordDeclaration(String name, java.util.List<org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaRecordComponent> components, java.util.List<org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaTypeRef> implementsTypes, java.util.List<org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaClassBodyDeclaration> body, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCustomArea customArea, org.zwobble.hobgoblin.compiler.ast.DocComment docComment) implements org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaTypeDeclaration, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaClassBodyDeclaration { +public record JavaRecordDeclaration(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier name, java.util.List<org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaRecordComponent> components, java.util.List<org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaTypeRef> implementsTypes, java.util.List<org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaClassBodyDeclaration> body, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCustomArea customArea, org.zwobble.hobgoblin.compiler.ast.DocComment docComment) implements org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaTypeDeclaration, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaClassBodyDeclaration { public static org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaRecordDeclaration.Builder arbitrary() { - return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaRecordDeclaration.Builder("", java.util.List.of(), java.util.List.of(), java.util.List.of(), org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCustomArea.arbitrary().build(), org.zwobble.hobgoblin.compiler.ast.HobgoblinNativeAst.arbitraryDocComment()); + return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaRecordDeclaration.Builder(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier.arbitrary().build(), java.util.List.of(), java.util.List.of(), java.util.List.of(), org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCustomArea.arbitrary().build(), org.zwobble.hobgoblin.compiler.ast.HobgoblinNativeAst.arbitraryDocComment()); } - public record Builder(String name, java.util.List<org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaRecordComponent> components, java.util.List<org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaTypeRef> implementsTypes, java.util.List<org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaClassBodyDeclaration> body, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCustomArea customArea, org.zwobble.hobgoblin.compiler.ast.DocComment docComment) implements org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaTypeDeclaration.Builder, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaClassBodyDeclaration.Builder { + public record Builder(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier name, java.util.List<org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaRecordComponent> components, java.util.List<org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaTypeRef> implementsTypes, java.util.List<org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaClassBodyDeclaration> body, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCustomArea customArea, org.zwobble.hobgoblin.compiler.ast.DocComment docComment) implements org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaTypeDeclaration.Builder, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaClassBodyDeclaration.Builder { public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaRecordDeclaration build() { return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaRecordDeclaration(name, components, implementsTypes, body, customArea, docComment); } - public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaRecordDeclaration.Builder withName(String name) { + public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaRecordDeclaration.Builder withName(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier name) { return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaRecordDeclaration.Builder(name, components, implementsTypes, body, customArea, docComment); } + public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaRecordDeclaration.Builder withName(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier.Builder name) { + return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaRecordDeclaration.Builder(name.build(), components, implementsTypes, body, customArea, docComment); + } + public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaRecordDeclaration.Builder withComponents(java.util.List<org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaRecordComponent> components) { return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaRecordDeclaration.Builder(name, components, implementsTypes, body, customArea, docComment); } diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaRef.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaRef.java index 36c1005..f230e50 100644 --- a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaRef.java +++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaRef.java @@ -2,24 +2,29 @@ package org.zwobble.hobgoblin.compiler.output.lang.java.ast; -public record JavaRef(String name) implements org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaExpression { +public record JavaRef(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier name) implements org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaExpression { public static org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaRef.Builder arbitrary() { - return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaRef.Builder(""); + return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaRef.Builder(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier.arbitrary().build()); } - public record Builder(String name) implements org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaExpression.Builder { + public record Builder(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier name) implements org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaExpression.Builder { public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaRef build() { return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaRef(name); } - public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaRef.Builder withName(String name) { + public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaRef.Builder withName(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier name) { return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaRef.Builder(name); } + public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaRef.Builder withName(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier.Builder name) { + return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaRef.Builder(name.build()); + } + // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaRef.Builder body // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaRef.Builder body } // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaRef body + public static final JavaRef THIS = new JavaRef(JavaIdentifier.of("this")); // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaRef body } diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaStaticFieldAccess.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaStaticFieldAccess.java index d7e1e6f..799e0d1 100644 --- a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaStaticFieldAccess.java +++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaStaticFieldAccess.java @@ -2,12 +2,12 @@ package org.zwobble.hobgoblin.compiler.output.lang.java.ast; -public record JavaStaticFieldAccess(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaTypeRef type, String fieldName) implements org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaExpression { +public record JavaStaticFieldAccess(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaTypeRef type, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier fieldName) implements org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaExpression { public static org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaStaticFieldAccess.Builder arbitrary() { - return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaStaticFieldAccess.Builder(org.zwobble.hobgoblin.compiler.output.lang.java.ast.HobgoblinNativeAst.arbitraryJavaTypeRef(), ""); + return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaStaticFieldAccess.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, String fieldName) implements org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaExpression.Builder { + public record Builder(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaTypeRef type, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier fieldName) implements org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaExpression.Builder { public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaStaticFieldAccess build() { return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaStaticFieldAccess(type, fieldName); } @@ -16,10 +16,14 @@ public record JavaStaticFieldAccess(org.zwobble.hobgoblin.compiler.output.lang.j return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaStaticFieldAccess.Builder(type, fieldName); } - public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaStaticFieldAccess.Builder withFieldName(String fieldName) { + public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaStaticFieldAccess.Builder withFieldName(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier fieldName) { return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaStaticFieldAccess.Builder(type, fieldName); } + public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaStaticFieldAccess.Builder withFieldName(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier.Builder fieldName) { + return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaStaticFieldAccess.Builder(type, fieldName.build()); + } + // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaStaticFieldAccess.Builder body // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaStaticFieldAccess.Builder body } diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaStaticMethodCall.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaStaticMethodCall.java index e033efe..5abf733 100644 --- a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaStaticMethodCall.java +++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaStaticMethodCall.java @@ -2,12 +2,12 @@ package org.zwobble.hobgoblin.compiler.output.lang.java.ast; -public record JavaStaticMethodCall(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaTypeRef type, String methodName, java.util.List<org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaExpression> args) implements org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaExpression { +public record JavaStaticMethodCall(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaTypeRef type, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier methodName, java.util.List<org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaExpression> args) implements org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaExpression { public static org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaStaticMethodCall.Builder arbitrary() { - return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaStaticMethodCall.Builder(org.zwobble.hobgoblin.compiler.output.lang.java.ast.HobgoblinNativeAst.arbitraryJavaTypeRef(), "", java.util.List.of()); + return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaStaticMethodCall.Builder(org.zwobble.hobgoblin.compiler.output.lang.java.ast.HobgoblinNativeAst.arbitraryJavaTypeRef(), org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier.arbitrary().build(), java.util.List.of()); } - public record Builder(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaTypeRef type, String methodName, java.util.List<org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaExpression> args) implements org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaExpression.Builder { + public record Builder(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaTypeRef type, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier methodName, java.util.List<org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaExpression> args) implements org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaExpression.Builder { public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaStaticMethodCall build() { return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaStaticMethodCall(type, methodName, args); } @@ -16,10 +16,14 @@ public record JavaStaticMethodCall(org.zwobble.hobgoblin.compiler.output.lang.ja return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaStaticMethodCall.Builder(type, methodName, args); } - public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaStaticMethodCall.Builder withMethodName(String methodName) { + public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaStaticMethodCall.Builder withMethodName(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier methodName) { return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaStaticMethodCall.Builder(type, methodName, args); } + public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaStaticMethodCall.Builder withMethodName(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier.Builder methodName) { + return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaStaticMethodCall.Builder(type, methodName.build(), args); + } + public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaStaticMethodCall.Builder withArgs(java.util.List<org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaExpression> args) { return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaStaticMethodCall.Builder(type, methodName, args); } diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaTypeDeclaration.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaTypeDeclaration.java index 93e3474..67628bb 100644 --- a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaTypeDeclaration.java +++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaTypeDeclaration.java @@ -10,7 +10,7 @@ public sealed interface JavaTypeDeclaration permits org.zwobble.hobgoblin.compil // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaTypeDeclaration.Builder body } - public String name(); + public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier name(); public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCustomArea customArea(); diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaTypeRef.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaTypeRef.java index 2738098..39edb73 100644 --- a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaTypeRef.java +++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaTypeRef.java @@ -3,43 +3,49 @@ package org.zwobble.hobgoblin.compiler.output.lang.java.ast; import java.util.Arrays; import java.util.List; -public record JavaTypeRef(List<String> packageName, List<String> typeNames, List<JavaTypeArg> args) { +public record JavaTypeRef(List<JavaIdentifier> packageName, List<JavaIdentifier> typeNames, List<JavaTypeArg> args) { private static JavaTypeRef primitive(String name) { - return new JavaTypeRef(List.of(), List.of(name), List.of()); + return new JavaTypeRef(List.of(), List.of(new JavaIdentifier(name)), List.of()); } - public static JavaTypeRef topLevel(List<String> packageName, String name) { + public static JavaTypeRef topLevel(List<JavaIdentifier> packageName, JavaIdentifier name) { return new JavaTypeRef(packageName, List.of(name), List.of()); } - public static JavaTypeRef inner(List<String> packageName, String... typeNames) { + public static JavaTypeRef inner(List<JavaIdentifier> packageName, JavaIdentifier... typeNames) { return new JavaTypeRef(packageName, Arrays.asList(typeNames), List.of()); } public static JavaTypeRef topLevelGeneric( - List<String> packageName, - String name, + List<JavaIdentifier> packageName, + JavaIdentifier name, List<JavaTypeArg> args ) { return new JavaTypeRef(packageName, List.of(name), args); } public static JavaTypeRef generic( - List<String> packageName, - List<String> typeNames, + List<JavaIdentifier> packageName, + List<JavaIdentifier> typeNames, List<JavaTypeArg> args ) { return new JavaTypeRef(packageName, typeNames, args); } + private static class JavaPackages { + private static final List<JavaIdentifier> JAVA_LANG = List.of(JavaIdentifier.of("java"), JavaIdentifier.of("lang")); + private static final List<JavaIdentifier> JAVA_UTIL = List.of(JavaIdentifier.of("java"), JavaIdentifier.of("util")); + private static final List<JavaIdentifier> JAVA_UTIL_STREAM = List.of(JavaIdentifier.of("java"), JavaIdentifier.of("util"), JavaIdentifier.of("stream")); + } + public static final JavaTypeRef INT = primitive("int"); - public static final JavaTypeRef INT_BOXED = topLevel(List.of("java", "lang"), "Integer"); + public static final JavaTypeRef INT_BOXED = topLevel(JavaPackages.JAVA_LANG, JavaIdentifier.of("Integer")); public static final JavaTypeRef LONG = primitive("long"); - public static final JavaTypeRef LONG_BOXED = topLevel(List.of("java", "lang"), "Long"); + public static final JavaTypeRef LONG_BOXED = topLevel(JavaPackages.JAVA_LANG, JavaIdentifier.of("Long")); public static final JavaTypeRef STRING = primitive("String"); public static final JavaTypeRef VOID = primitive("void"); - public static final JavaTypeRef LIST = topLevel(List.of("java", "util"), "List"); + public static final JavaTypeRef LIST = topLevel(JavaPackages.JAVA_UTIL, JavaIdentifier.of("List")); public static JavaTypeRef list(JavaTypeRef elementType) { return new JavaTypeRef( @@ -49,9 +55,9 @@ public record JavaTypeRef(List<String> packageName, List<String> typeNames, List ); } - public static final JavaTypeRef OBJECT = topLevel(List.of("java", "lang"), "Object"); + public static final JavaTypeRef OBJECT = topLevel(JavaPackages.JAVA_LANG, JavaIdentifier.of("Object")); - public static final JavaTypeRef OPTIONAL = topLevel(List.of("java", "util"), "Optional"); + public static final JavaTypeRef OPTIONAL = topLevel(JavaPackages.JAVA_UTIL, JavaIdentifier.of("Optional")); - public static final JavaTypeRef STREAM = topLevel(List.of("java", "util", "stream"), "Stream"); + public static final JavaTypeRef STREAM = topLevel(JavaPackages.JAVA_UTIL_STREAM, JavaIdentifier.of("Stream")); } diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/JavaGeneratorTests.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/JavaGeneratorTests.java index d7c3eeb..a99995b 100644 --- a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/JavaGeneratorTests.java +++ b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/JavaGeneratorTests.java @@ -4,6 +4,7 @@ import org.junit.jupiter.api.Test; import org.zwobble.hobgoblin.compiler.output.generators.java.JavaGenerator; import org.zwobble.hobgoblin.compiler.output.generators.java.JavaGeneratorConfig; import org.zwobble.hobgoblin.compiler.output.generators.java.JavaNamespaceConfig; +import org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier; import org.zwobble.hobgoblin.compiler.types.NamespaceName; import java.util.List; @@ -16,7 +17,7 @@ public class JavaGeneratorTests { @Test public void defaultJavaPackageIsUsedForNamespacesWithoutExplicitMapping() { var config = new JavaGeneratorConfig( - List.of("com", "example"), + List.of(JavaIdentifier.of("com"), JavaIdentifier.of("example")), Map.of(), Map.of() ); @@ -24,17 +25,17 @@ public class JavaGeneratorTests { var result = generator.namespaceToJavaPackageParts(NamespaceName.of("a", "b")); - assertThat(result, equalTo(List.of("com", "example", "a", "b"))); + assertThat(result, equalTo(List.of(JavaIdentifier.of("com"), JavaIdentifier.of("example"), JavaIdentifier.of("a"), JavaIdentifier.of("b")))); } @Test public void explicitJavaPackageIsUsedForNamespaceWhenExactNamespaceHasMapping() { var config = new JavaGeneratorConfig( - List.of("com", "example"), + List.of(JavaIdentifier.of("com"), JavaIdentifier.of("example")), Map.ofEntries( Map.entry( NamespaceName.of("a", "b"), - new JavaNamespaceConfig(List.of("com", "other")) + new JavaNamespaceConfig(List.of(JavaIdentifier.of("com"), JavaIdentifier.of("other"))) ) ), Map.of() @@ -43,17 +44,17 @@ public class JavaGeneratorTests { var result = generator.namespaceToJavaPackageParts(NamespaceName.of("a", "b")); - assertThat(result, equalTo(List.of("com", "other"))); + assertThat(result, equalTo(List.of(JavaIdentifier.of("com"), JavaIdentifier.of("other")))); } @Test public void explicitJavaPackageIsUsedForNamespaceWhenAncestorNamespaceHasMapping() { var config = new JavaGeneratorConfig( - List.of("com", "example"), + List.of(JavaIdentifier.of("com"), JavaIdentifier.of("example")), Map.ofEntries( Map.entry( NamespaceName.of("a", "b"), - new JavaNamespaceConfig(List.of("com", "other")) + new JavaNamespaceConfig(List.of(JavaIdentifier.of("com"), JavaIdentifier.of("other"))) ) ), Map.of() @@ -62,6 +63,6 @@ public class JavaGeneratorTests { var result = generator.namespaceToJavaPackageParts(NamespaceName.of("a", "b", "c", "d")); - assertThat(result, equalTo(List.of("com", "other", "c", "d"))); + assertThat(result, equalTo(List.of(JavaIdentifier.of("com"), JavaIdentifier.of("other"), JavaIdentifier.of("c"), JavaIdentifier.of("d")))); } } 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 78b975d..ec09b72 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 @@ -19,12 +19,12 @@ public class JavaWriterTests { @Test public void compilationUnit() throws IOException { var java = new JavaCompilationUnit( - List.of("com", "example", "shapes"), + List.of(JavaIdentifier.of("com"), JavaIdentifier.of("example"), JavaIdentifier.of("shapes")), new JavaClassDeclaration( - "Rectangle", + JavaIdentifier.of("Rectangle"), List.of(), List.of(), - new JavaCustomArea(JavaTypeRef.topLevel(List.of(), "Rectangle"), "body"), + new JavaCustomArea(JavaTypeRef.topLevel(List.of(), JavaIdentifier.of("Rectangle")), "body"), DocComment.EMPTY ) ); @@ -47,10 +47,10 @@ public class JavaWriterTests { @Test public void emptyClassDeclaration() throws IOException { var java = new JavaClassDeclaration( - "Rectangle", + JavaIdentifier.of("Rectangle"), List.of(), List.of(), - new JavaCustomArea(JavaTypeRef.topLevel(List.of(), "Rectangle"), "body"), + new JavaCustomArea(JavaTypeRef.topLevel(List.of(), JavaIdentifier.of("Rectangle")), "body"), DocComment.EMPTY ); @@ -67,12 +67,15 @@ public class JavaWriterTests { @Test public void classDeclarationImplementingSingleInterface() throws IOException { var java = new JavaClassDeclaration( - "Rectangle", + JavaIdentifier.of("Rectangle"), List.of( - JavaTypeRef.topLevel(List.of("com.example"), "Shape") + JavaTypeRef.topLevel( + List.of(JavaIdentifier.of("com"), JavaIdentifier.of("example")), + JavaIdentifier.of("Shape") + ) ), List.of(), - new JavaCustomArea(JavaTypeRef.topLevel(List.of(), "Rectangle"), "body"), + new JavaCustomArea(JavaTypeRef.topLevel(List.of(), JavaIdentifier.of("Rectangle")), "body"), DocComment.EMPTY ); @@ -89,13 +92,13 @@ public class JavaWriterTests { @Test public void classDeclarationImplementingMultipleInterfaces() throws IOException { var java = new JavaClassDeclaration( - "Rectangle", + JavaIdentifier.of("Rectangle"), List.of( - JavaTypeRef.topLevel(List.of("com.example"), "Shape"), - JavaTypeRef.topLevel(List.of("com.example"), "Drawable") + JavaTypeRef.topLevel(List.of(JavaIdentifier.of("com"), JavaIdentifier.of("example")), JavaIdentifier.of("Shape")), + JavaTypeRef.topLevel(List.of(JavaIdentifier.of("com"), JavaIdentifier.of("example")), JavaIdentifier.of("Drawable")) ), List.of(), - new JavaCustomArea(JavaTypeRef.topLevel(List.of(), "Rectangle"), "body"), + new JavaCustomArea(JavaTypeRef.topLevel(List.of(), JavaIdentifier.of("Rectangle")), "body"), DocComment.EMPTY ); @@ -112,11 +115,11 @@ public class JavaWriterTests { @Test public void classDeclarationWithMethods() throws IOException { var java = new JavaClassDeclaration( - "Rectangle", + JavaIdentifier.of("Rectangle"), List.of(), List.of( new JavaMethodDeclaration( - "a", + JavaIdentifier.of("a"), JavaVisibility.PUBLIC, JavaMethodKind.INSTANCE, JavaTypeRef.VOID, @@ -124,7 +127,7 @@ public class JavaWriterTests { JavaBlock.EMPTY ), new JavaMethodDeclaration( - "b", + JavaIdentifier.of("b"), JavaVisibility.PUBLIC, JavaMethodKind.INSTANCE, JavaTypeRef.VOID, @@ -132,7 +135,7 @@ public class JavaWriterTests { JavaBlock.EMPTY ) ), - new JavaCustomArea(JavaTypeRef.topLevel(List.of(), "Rectangle"), "body"), + new JavaCustomArea(JavaTypeRef.topLevel(List.of(), JavaIdentifier.of("Rectangle")), "body"), DocComment.EMPTY ); @@ -155,10 +158,10 @@ public class JavaWriterTests { @Test public void classDeclarationWithDocComment() throws IOException { var java = new JavaClassDeclaration( - "Point", + JavaIdentifier.of("Point"), List.of(), List.of(), - new JavaCustomArea(JavaTypeRef.topLevel(List.of(), "Point"), "body"), + new JavaCustomArea(JavaTypeRef.topLevel(List.of(), JavaIdentifier.of("Point")), "body"), new DocComment("A 2D point.") ); @@ -176,8 +179,8 @@ public class JavaWriterTests { @Test public void emptyEnumDeclaration() throws IOException { var java = JavaEnumDeclaration.arbitrary() - .withName("SmallNumber") - .withCustomArea(JavaCustomArea.forType(JavaTypeRef.topLevel(List.of(), "SmallNumber"), "body")) + .withName(JavaIdentifier.of("SmallNumber")) + .withCustomArea(JavaCustomArea.forType(JavaTypeRef.topLevel(List.of(), JavaIdentifier.of("SmallNumber")), "body")) .build(); var string = write(writer -> writer.writeTypeDeclaration(java)); @@ -193,12 +196,12 @@ public class JavaWriterTests { @Test public void enumDeclarationWithConstants() throws IOException { var java = JavaEnumDeclaration.arbitrary() - .withName("SmallNumber") - .withCustomArea(JavaCustomArea.forType(JavaTypeRef.topLevel(List.of(), "SmallNumber"), "body")) + .withName(JavaIdentifier.of("SmallNumber")) + .withCustomArea(JavaCustomArea.forType(JavaTypeRef.topLevel(List.of(), JavaIdentifier.of("SmallNumber")), "body")) .withConstants(List.of( - JavaEnumConstant.arbitrary().withName("ZERO").build(), - JavaEnumConstant.arbitrary().withName("ONE").build(), - JavaEnumConstant.arbitrary().withName("TWO").build() + JavaEnumConstant.arbitrary().withName(JavaIdentifier.of("ZERO")).build(), + JavaEnumConstant.arbitrary().withName(JavaIdentifier.of("ONE")).build(), + JavaEnumConstant.arbitrary().withName(JavaIdentifier.of("TWO")).build() )) .build(); @@ -219,9 +222,9 @@ public class JavaWriterTests { @Test public void enumDeclarationWithDocComment() throws IOException { var java = JavaEnumDeclaration.arbitrary() - .withName("SmallNumber") + .withName(JavaIdentifier.of("SmallNumber")) .withDocComment(new DocComment("A small number.")) - .withCustomArea(JavaCustomArea.forType(JavaTypeRef.topLevel(List.of(), "SmallNumber"), "body")) + .withCustomArea(JavaCustomArea.forType(JavaTypeRef.topLevel(List.of(), JavaIdentifier.of("SmallNumber")), "body")) .build(); var string = write(writer -> writer.writeTypeDeclaration(java)); @@ -238,11 +241,11 @@ public class JavaWriterTests { @Test public void openInterfaceDeclaration() throws IOException { var java = new JavaInterfaceDeclaration( - "Shape", + JavaIdentifier.of("Shape"), JavaInterfaceOpenness.OPEN, List.of(), List.of(), - new JavaCustomArea(JavaTypeRef.topLevel(List.of(), "Shape"), "body"), + new JavaCustomArea(JavaTypeRef.topLevel(List.of(), JavaIdentifier.of("Shape")), "body"), DocComment.EMPTY ); @@ -259,11 +262,11 @@ public class JavaWriterTests { @Test public void sealedInterfaceDeclaration() throws IOException { var java = new JavaInterfaceDeclaration( - "Shape", + JavaIdentifier.of("Shape"), JavaInterfaceOpenness.SEALED, List.of(), List.of(), - new JavaCustomArea(JavaTypeRef.topLevel(List.of(), "Shape"), "body"), + new JavaCustomArea(JavaTypeRef.topLevel(List.of(), JavaIdentifier.of("Shape")), "body"), DocComment.EMPTY ); @@ -280,14 +283,14 @@ public class JavaWriterTests { @Test public void sealedInterfaceDeclarationWithPermitsTypes() throws IOException { var java = new JavaInterfaceDeclaration( - "Shape", + JavaIdentifier.of("Shape"), JavaInterfaceOpenness.SEALED, List.of( - JavaTypeRef.topLevel(List.of("abc", "def"), "One"), - JavaTypeRef.topLevel(List.of("abc", "def"), "Two") + JavaTypeRef.topLevel(List.of(JavaIdentifier.of("abc"), JavaIdentifier.of("def")), JavaIdentifier.of("One")), + JavaTypeRef.topLevel(List.of(JavaIdentifier.of("abc"), JavaIdentifier.of("def")), JavaIdentifier.of("Two")) ), List.of(), - new JavaCustomArea(JavaTypeRef.topLevel(List.of(), "Shape"), "body"), + new JavaCustomArea(JavaTypeRef.topLevel(List.of(), JavaIdentifier.of("Shape")), "body"), DocComment.EMPTY ); @@ -304,11 +307,11 @@ public class JavaWriterTests { @Test public void interfaceDeclarationWithDocComment() throws IOException { var java = new JavaInterfaceDeclaration( - "Shape", + JavaIdentifier.of("Shape"), JavaInterfaceOpenness.OPEN, List.of(), List.of(), - new JavaCustomArea(JavaTypeRef.topLevel(List.of(), "Shape"), "body"), + new JavaCustomArea(JavaTypeRef.topLevel(List.of(), JavaIdentifier.of("Shape")), "body"), new DocComment("A 2D shape.") ); @@ -326,12 +329,12 @@ public class JavaWriterTests { @Test public void interfaceDeclarationWithBody() throws IOException { var java = new JavaInterfaceDeclaration( - "Shape", + JavaIdentifier.of("Shape"), JavaInterfaceOpenness.OPEN, List.of(), List.of( new JavaMethodDeclaration( - "a", + JavaIdentifier.of("a"), JavaVisibility.PUBLIC, JavaMethodKind.STATIC, JavaTypeRef.VOID, @@ -339,7 +342,7 @@ public class JavaWriterTests { JavaBlock.EMPTY ), new JavaMethodDeclaration( - "b", + JavaIdentifier.of("b"), JavaVisibility.PUBLIC, JavaMethodKind.STATIC, JavaTypeRef.VOID, @@ -347,7 +350,7 @@ public class JavaWriterTests { JavaBlock.EMPTY ) ), - new JavaCustomArea(JavaTypeRef.topLevel(List.of(), "Shape"), "body"), + new JavaCustomArea(JavaTypeRef.topLevel(List.of(), JavaIdentifier.of("Shape")), "body"), DocComment.EMPTY ); @@ -370,11 +373,11 @@ public class JavaWriterTests { @Test public void emptyRecordDeclaration() throws IOException { var java = new JavaRecordDeclaration( - "Point", + JavaIdentifier.of("Point"), List.of(), List.of(), List.of(), - new JavaCustomArea(JavaTypeRef.topLevel(List.of(), "Point"), "body"), + new JavaCustomArea(JavaTypeRef.topLevel(List.of(), JavaIdentifier.of("Point")), "body"), DocComment.EMPTY ); @@ -391,11 +394,11 @@ public class JavaWriterTests { @Test public void recordDeclarationWithDocComment() throws IOException { var java = new JavaRecordDeclaration( - "Point", + JavaIdentifier.of("Point"), List.of(), List.of(), List.of(), - new JavaCustomArea(JavaTypeRef.topLevel(List.of(), "Point"), "body"), + new JavaCustomArea(JavaTypeRef.topLevel(List.of(), JavaIdentifier.of("Point")), "body"), new DocComment("A 2D point.") ); @@ -413,13 +416,13 @@ public class JavaWriterTests { @Test public void recordDeclarationImplementingOneInterface() throws IOException { var java = new JavaRecordDeclaration( - "Rectangle", + JavaIdentifier.of("Rectangle"), List.of(), List.of( - JavaTypeRef.topLevel(List.of("com.example"), "Shape") + JavaTypeRef.topLevel(List.of(JavaIdentifier.of("com"), JavaIdentifier.of("example")), JavaIdentifier.of("Shape")) ), List.of(), - new JavaCustomArea(JavaTypeRef.topLevel(List.of(), "Rectangle"), "body"), + new JavaCustomArea(JavaTypeRef.topLevel(List.of(), JavaIdentifier.of("Rectangle")), "body"), DocComment.EMPTY ); @@ -436,14 +439,14 @@ public class JavaWriterTests { @Test public void recordDeclarationImplementingMultipleInterfaces() throws IOException { var java = new JavaRecordDeclaration( - "Rectangle", + JavaIdentifier.of("Rectangle"), List.of(), List.of( - JavaTypeRef.topLevel(List.of("com.example"), "Shape"), - JavaTypeRef.topLevel(List.of("com.example"), "Drawable") + JavaTypeRef.topLevel(List.of(JavaIdentifier.of("com"), JavaIdentifier.of("example")), JavaIdentifier.of("Shape")), + JavaTypeRef.topLevel(List.of(JavaIdentifier.of("com"), JavaIdentifier.of("example")), JavaIdentifier.of("Drawable")) ), List.of(), - new JavaCustomArea(JavaTypeRef.topLevel(List.of(), "Rectangle"), "body"), + new JavaCustomArea(JavaTypeRef.topLevel(List.of(), JavaIdentifier.of("Rectangle")), "body"), DocComment.EMPTY ); @@ -460,12 +463,12 @@ public class JavaWriterTests { @Test public void recordDeclarationWithMethods() throws IOException { var java = new JavaRecordDeclaration( - "Rectangle", + JavaIdentifier.of("Rectangle"), List.of(), List.of(), List.of( new JavaMethodDeclaration( - "a", + JavaIdentifier.of("a"), JavaVisibility.PUBLIC, JavaMethodKind.INSTANCE, JavaTypeRef.VOID, @@ -473,7 +476,7 @@ public class JavaWriterTests { JavaBlock.EMPTY ), new JavaMethodDeclaration( - "b", + JavaIdentifier.of("b"), JavaVisibility.PUBLIC, JavaMethodKind.INSTANCE, JavaTypeRef.VOID, @@ -481,7 +484,7 @@ public class JavaWriterTests { JavaBlock.EMPTY ) ), - new JavaCustomArea(JavaTypeRef.topLevel(List.of(), "Rectangle"), "body"), + new JavaCustomArea(JavaTypeRef.topLevel(List.of(), JavaIdentifier.of("Rectangle")), "body"), DocComment.EMPTY ); @@ -504,7 +507,7 @@ public class JavaWriterTests { @Test public void emptyMethodWithoutBody() throws IOException { var java = new JavaMethodDeclaration( - "a", + JavaIdentifier.of("a"), JavaVisibility.PUBLIC, JavaMethodKind.INSTANCE, JavaTypeRef.VOID, @@ -522,7 +525,7 @@ public class JavaWriterTests { @Test public void emptyInstanceMethod() throws IOException { var java = new JavaMethodDeclaration( - "a", + JavaIdentifier.of("a"), JavaVisibility.PUBLIC, JavaMethodKind.INSTANCE, JavaTypeRef.VOID, @@ -541,7 +544,7 @@ public class JavaWriterTests { @Test public void publicInstanceMethod() throws IOException { var java = new JavaMethodDeclaration( - "a", + JavaIdentifier.of("a"), JavaVisibility.PUBLIC, JavaMethodKind.INSTANCE, JavaTypeRef.VOID, @@ -560,7 +563,7 @@ public class JavaWriterTests { @Test public void privateInstanceMethod() throws IOException { var java = new JavaMethodDeclaration( - "a", + JavaIdentifier.of("a"), JavaVisibility.PRIVATE, JavaMethodKind.INSTANCE, JavaTypeRef.VOID, @@ -579,7 +582,7 @@ public class JavaWriterTests { @Test public void emptyStaticMethod() throws IOException { var java = new JavaMethodDeclaration( - "a", + JavaIdentifier.of("a"), JavaVisibility.PUBLIC, JavaMethodKind.STATIC, JavaTypeRef.VOID, @@ -598,13 +601,13 @@ public class JavaWriterTests { @Test public void methodWithParams() throws IOException { var java = new JavaMethodDeclaration( - "a", + JavaIdentifier.of("a"), JavaVisibility.PUBLIC, JavaMethodKind.INSTANCE, JavaTypeRef.VOID, List.of( - new JavaParam(JavaTypeRef.INT, "b"), - new JavaParam(JavaTypeRef.LONG, "c") + new JavaParam(JavaTypeRef.INT, JavaIdentifier.of("b")), + new JavaParam(JavaTypeRef.LONG, JavaIdentifier.of("c")) ), JavaBlock.EMPTY ); @@ -620,7 +623,7 @@ public class JavaWriterTests { @Test public void methodWithBody() throws IOException { var java = new JavaMethodDeclaration( - "a", + JavaIdentifier.of("a"), JavaVisibility.PUBLIC, JavaMethodKind.INSTANCE, JavaTypeRef.INT, @@ -642,7 +645,7 @@ public class JavaWriterTests { @Test public void emptyConstructor() throws IOException { var java = new JavaConstructorDeclaration( - "Rectangle", + JavaIdentifier.of("Rectangle"), JavaVisibility.PUBLIC, List.of(), JavaBlock.EMPTY @@ -659,7 +662,7 @@ public class JavaWriterTests { @Test public void publicConstructor() throws IOException { var java = new JavaConstructorDeclaration( - "Rectangle", + JavaIdentifier.of("Rectangle"), JavaVisibility.PUBLIC, List.of(), JavaBlock.EMPTY @@ -676,7 +679,7 @@ public class JavaWriterTests { @Test public void privateConstructor() throws IOException { var java = new JavaConstructorDeclaration( - "Rectangle", + JavaIdentifier.of("Rectangle"), JavaVisibility.PRIVATE, List.of(), JavaBlock.EMPTY @@ -693,11 +696,11 @@ public class JavaWriterTests { @Test public void constructorWithParams() throws IOException { var java = new JavaConstructorDeclaration( - "Rectangle", + JavaIdentifier.of("Rectangle"), JavaVisibility.PUBLIC, List.of( - new JavaParam(JavaTypeRef.INT, "b"), - new JavaParam(JavaTypeRef.LONG, "c") + new JavaParam(JavaTypeRef.INT, JavaIdentifier.of("b")), + new JavaParam(JavaTypeRef.LONG, JavaIdentifier.of("c")) ), JavaBlock.EMPTY ); @@ -713,7 +716,7 @@ public class JavaWriterTests { @Test public void constructorWithBody() throws IOException { var java = new JavaConstructorDeclaration( - "Rectangle", + JavaIdentifier.of("Rectangle"), JavaVisibility.PUBLIC, List.of(), new JavaBlock(List.of( @@ -735,7 +738,7 @@ public class JavaWriterTests { var java = new JavaFieldDeclaration( JavaVisibility.PRIVATE, JavaTypeRef.INT, - "count" + JavaIdentifier.of("count") ); var string = write(writer -> writer.writeClassBodyDeclaration(java)); @@ -803,7 +806,7 @@ public class JavaWriterTests { @Test public void assignment() throws IOException { var java = new JavaAssignment( - new JavaRef("x"), + new JavaRef(JavaIdentifier.of("x")), new JavaIntegerLiteral(42) ); @@ -815,8 +818,8 @@ public class JavaWriterTests { @Test public void fieldAccess() throws IOException { var java = new JavaFieldAccess( - new JavaRef("one"), - "two" + new JavaRef(JavaIdentifier.of("one")), + JavaIdentifier.of("two") ); var string = write(writer -> writer.writeExpression(java)); @@ -827,8 +830,8 @@ public class JavaWriterTests { @Test public void staticFieldAccess() throws IOException { var java = new JavaStaticFieldAccess( - JavaTypeRef.topLevel(List.of("one"), "Two"), - "three" + JavaTypeRef.topLevel(List.of(JavaIdentifier.of("one")), JavaIdentifier.of("Two")), + JavaIdentifier.of("three") ); var string = write(writer -> writer.writeExpression(java)); @@ -839,8 +842,8 @@ public class JavaWriterTests { @Test public void referenceToMethodOnType() throws IOException { var java = new JavaMethodRef( - JavaTypeRef.topLevel(List.of("one"), "Two"), - "three" + JavaTypeRef.topLevel(List.of(JavaIdentifier.of("one")), JavaIdentifier.of("Two")), + JavaIdentifier.of("three") ); var string = write(writer -> writer.writeExpression(java)); @@ -851,7 +854,7 @@ public class JavaWriterTests { @Test public void newExpression() throws IOException { var java = new JavaNewExpression( - JavaTypeRef.topLevel(List.of("one"), "Two"), + JavaTypeRef.topLevel(List.of(JavaIdentifier.of("one")), JavaIdentifier.of("Two")), List.of(new JavaIntegerLiteral(1), new JavaIntegerLiteral(2)) ); @@ -862,7 +865,7 @@ public class JavaWriterTests { @Test public void ref() throws IOException { - var java = new JavaRef("x"); + var java = new JavaRef(JavaIdentifier.of("x")); var string = write(writer -> writer.writeExpression(java)); @@ -871,7 +874,10 @@ public class JavaWriterTests { @Test public void typeRefWithoutArgsHasNoAngleBrackets() throws IOException { - var java = JavaTypeRef.topLevel(List.of("abc", "def"), "One"); + var java = JavaTypeRef.topLevel( + List.of(JavaIdentifier.of("abc"), JavaIdentifier.of("def")), + JavaIdentifier.of("One") + ); var string = write(writer -> writer.writeTypeRef(java)); @@ -881,11 +887,11 @@ public class JavaWriterTests { @Test public void typeRefWithArgsHasAngleBrackets() throws IOException { var java = JavaTypeRef.topLevelGeneric( - List.of("abc", "def"), - "One", + List.of(JavaIdentifier.of("abc"), JavaIdentifier.of("def")), + JavaIdentifier.of("One"), List.of( - JavaTypeArg.invariant(JavaTypeRef.topLevel(List.of(), "Two")), - JavaTypeArg.invariant(JavaTypeRef.topLevel(List.of(), "Three")) + JavaTypeArg.invariant(JavaTypeRef.topLevel(List.of(), JavaIdentifier.of("Two"))), + JavaTypeArg.invariant(JavaTypeRef.topLevel(List.of(), JavaIdentifier.of("Three"))) ) ); @@ -897,11 +903,11 @@ public class JavaWriterTests { @Test public void typeRefArgCanBeSuper() throws IOException { var java = JavaTypeRef.topLevelGeneric( - List.of("abc", "def"), - "One", + List.of(JavaIdentifier.of("abc"), JavaIdentifier.of("def")), + JavaIdentifier.of("One"), List.of( - JavaTypeArg.superType(JavaTypeRef.topLevel(List.of(), "Two")), - JavaTypeArg.superType(JavaTypeRef.topLevel(List.of(), "Three")) + JavaTypeArg.superType(JavaTypeRef.topLevel(List.of(), JavaIdentifier.of("Two"))), + JavaTypeArg.superType(JavaTypeRef.topLevel(List.of(), JavaIdentifier.of("Three"))) ) ); @@ -912,7 +918,11 @@ public class JavaWriterTests { @Test public void typeRefInnerTypeNameIsSeparatedByDot() throws IOException { - var java = JavaTypeRef.inner(List.of("abc", "def"), "One", "Two"); + var java = JavaTypeRef.inner( + List.of(JavaIdentifier.of("abc"), JavaIdentifier.of("def")), + JavaIdentifier.of("One"), + JavaIdentifier.of("Two") + ); var string = write(writer -> writer.writeTypeRef(java)); @@ -922,11 +932,11 @@ public class JavaWriterTests { @Test public void customAreaContentsArePreserved() throws IOException { var java = new JavaRecordDeclaration( - "Point", + JavaIdentifier.of("Point"), List.of(), List.of(), List.of(), - new JavaCustomArea(JavaTypeRef.topLevel(List.of(), "Point"), "body"), + new JavaCustomArea(JavaTypeRef.topLevel(List.of(), JavaIdentifier.of("Point")), "body"), DocComment.EMPTY ); diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaClassDeclarationMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaClassDeclarationMatcher.java index 7461fdd..713f07f 100644 --- a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaClassDeclarationMatcher.java +++ b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaClassDeclarationMatcher.java @@ -25,7 +25,7 @@ public class JavaClassDeclarationMatcher implements org.zwobble.precisely.Matche return org.zwobble.precisely.Matchers.instanceOf(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaClassDeclaration.class, this.submatchers); } - public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaClassDeclarationMatcher withName(org.zwobble.precisely.Matcher<? super String> name) { + public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaClassDeclarationMatcher withName(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier> name) { return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaClassDeclarationMatcher(java.util.stream.Stream.concat(this.submatchers.stream(), java.util.stream.Stream.of(org.zwobble.precisely.Matchers.has("name", org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaClassDeclaration::name, name))).toList()); } diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaCompilationUnitMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaCompilationUnitMatcher.java index b2c3f8e..1c6541b 100644 --- a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaCompilationUnitMatcher.java +++ b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaCompilationUnitMatcher.java @@ -25,7 +25,7 @@ public class JavaCompilationUnitMatcher implements org.zwobble.precisely.Matcher return org.zwobble.precisely.Matchers.instanceOf(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCompilationUnit.class, this.submatchers); } - public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCompilationUnitMatcher withPackageName(org.zwobble.precisely.Matcher<? super java.util.List<String>> packageName) { + public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCompilationUnitMatcher withPackageName(org.zwobble.precisely.Matcher<? super java.util.List<org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier>> packageName) { return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCompilationUnitMatcher(java.util.stream.Stream.concat(this.submatchers.stream(), java.util.stream.Stream.of(org.zwobble.precisely.Matchers.has("packageName", org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCompilationUnit::packageName, packageName))).toList()); } diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaConstructorDeclarationMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaConstructorDeclarationMatcher.java index f755820..46bfd01 100644 --- a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaConstructorDeclarationMatcher.java +++ b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaConstructorDeclarationMatcher.java @@ -25,7 +25,7 @@ public class JavaConstructorDeclarationMatcher implements org.zwobble.precisely. return org.zwobble.precisely.Matchers.instanceOf(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaConstructorDeclaration.class, this.submatchers); } - public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaConstructorDeclarationMatcher withTypeName(org.zwobble.precisely.Matcher<? super String> typeName) { + public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaConstructorDeclarationMatcher withTypeName(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier> typeName) { return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaConstructorDeclarationMatcher(java.util.stream.Stream.concat(this.submatchers.stream(), java.util.stream.Stream.of(org.zwobble.precisely.Matchers.has("typeName", org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaConstructorDeclaration::typeName, typeName))).toList()); } diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaEnumConstantMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaEnumConstantMatcher.java index 58d6f54..eee55dd 100644 --- a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaEnumConstantMatcher.java +++ b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaEnumConstantMatcher.java @@ -25,7 +25,7 @@ public class JavaEnumConstantMatcher implements org.zwobble.precisely.Matcher<ja return org.zwobble.precisely.Matchers.instanceOf(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaEnumConstant.class, this.submatchers); } - public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaEnumConstantMatcher withName(org.zwobble.precisely.Matcher<? super String> name) { + public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaEnumConstantMatcher withName(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier> name) { return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaEnumConstantMatcher(java.util.stream.Stream.concat(this.submatchers.stream(), java.util.stream.Stream.of(org.zwobble.precisely.Matchers.has("name", org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaEnumConstant::name, name))).toList()); } diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaEnumDeclarationMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaEnumDeclarationMatcher.java index 0c7be66..3dd438a 100644 --- a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaEnumDeclarationMatcher.java +++ b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaEnumDeclarationMatcher.java @@ -25,7 +25,7 @@ public class JavaEnumDeclarationMatcher implements org.zwobble.precisely.Matcher return org.zwobble.precisely.Matchers.instanceOf(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaEnumDeclaration.class, this.submatchers); } - public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaEnumDeclarationMatcher withName(org.zwobble.precisely.Matcher<? super String> name) { + public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaEnumDeclarationMatcher withName(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier> name) { return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaEnumDeclarationMatcher(java.util.stream.Stream.concat(this.submatchers.stream(), java.util.stream.Stream.of(org.zwobble.precisely.Matchers.has("name", org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaEnumDeclaration::name, name))).toList()); } diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaFieldAccessMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaFieldAccessMatcher.java index c716d82..28cdb24 100644 --- a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaFieldAccessMatcher.java +++ b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaFieldAccessMatcher.java @@ -29,7 +29,7 @@ public class JavaFieldAccessMatcher implements org.zwobble.precisely.Matcher<jav return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaFieldAccessMatcher(java.util.stream.Stream.concat(this.submatchers.stream(), java.util.stream.Stream.of(org.zwobble.precisely.Matchers.has("receiver", org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaFieldAccess::receiver, receiver))).toList()); } - public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaFieldAccessMatcher withFieldName(org.zwobble.precisely.Matcher<? super String> fieldName) { + public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaFieldAccessMatcher withFieldName(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier> fieldName) { return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaFieldAccessMatcher(java.util.stream.Stream.concat(this.submatchers.stream(), java.util.stream.Stream.of(org.zwobble.precisely.Matchers.has("fieldName", org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaFieldAccess::fieldName, fieldName))).toList()); } diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaFieldDeclarationMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaFieldDeclarationMatcher.java index 303c088..ca79fc3 100644 --- a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaFieldDeclarationMatcher.java +++ b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaFieldDeclarationMatcher.java @@ -33,7 +33,7 @@ public class JavaFieldDeclarationMatcher implements org.zwobble.precisely.Matche return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaFieldDeclarationMatcher(java.util.stream.Stream.concat(this.submatchers.stream(), java.util.stream.Stream.of(org.zwobble.precisely.Matchers.has("type", org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaFieldDeclaration::type, type))).toList()); } - public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaFieldDeclarationMatcher withName(org.zwobble.precisely.Matcher<? super String> name) { + public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaFieldDeclarationMatcher withName(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier> name) { return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaFieldDeclarationMatcher(java.util.stream.Stream.concat(this.submatchers.stream(), java.util.stream.Stream.of(org.zwobble.precisely.Matchers.has("name", org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaFieldDeclaration::name, name))).toList()); } diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaIdentifierMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaIdentifierMatcher.java new file mode 100644 index 0000000..19434cd --- /dev/null +++ b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaIdentifierMatcher.java @@ -0,0 +1,34 @@ +// Generated by hobgoblin. + +package org.zwobble.hobgoblin.compiler.output.lang.java.ast; + +public class JavaIdentifierMatcher implements org.zwobble.precisely.Matcher<java.lang.Object> { + public static org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifierMatcher isJavaIdentifier() { + return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifierMatcher(java.util.List.of()); + } + + private final java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier>> submatchers; + + private JavaIdentifierMatcher(java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier>> 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.JavaIdentifier.class, this.submatchers); + } + + public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifierMatcher withValue(org.zwobble.precisely.Matcher<? super String> value) { + return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifierMatcher(java.util.stream.Stream.concat(this.submatchers.stream(), java.util.stream.Stream.of(org.zwobble.precisely.Matchers.has("value", org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier::value, value))).toList()); + } + + // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifierMatcher body + // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifierMatcher body +} diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaInterfaceDeclarationMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaInterfaceDeclarationMatcher.java index 0d8aef6..963a32d 100644 --- a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaInterfaceDeclarationMatcher.java +++ b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaInterfaceDeclarationMatcher.java @@ -25,7 +25,7 @@ public class JavaInterfaceDeclarationMatcher implements org.zwobble.precisely.Ma return org.zwobble.precisely.Matchers.instanceOf(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaInterfaceDeclaration.class, this.submatchers); } - public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaInterfaceDeclarationMatcher withName(org.zwobble.precisely.Matcher<? super String> name) { + public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaInterfaceDeclarationMatcher withName(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier> name) { return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaInterfaceDeclarationMatcher(java.util.stream.Stream.concat(this.submatchers.stream(), java.util.stream.Stream.of(org.zwobble.precisely.Matchers.has("name", org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaInterfaceDeclaration::name, name))).toList()); } diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaMethodCallMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaMethodCallMatcher.java index da2bc52..5fd64e0 100644 --- a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaMethodCallMatcher.java +++ b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaMethodCallMatcher.java @@ -29,7 +29,7 @@ public class JavaMethodCallMatcher implements org.zwobble.precisely.Matcher<java return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaMethodCallMatcher(java.util.stream.Stream.concat(this.submatchers.stream(), java.util.stream.Stream.of(org.zwobble.precisely.Matchers.has("receiver", org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaMethodCall::receiver, receiver))).toList()); } - public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaMethodCallMatcher withMethodName(org.zwobble.precisely.Matcher<? super String> methodName) { + public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaMethodCallMatcher withMethodName(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier> methodName) { return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaMethodCallMatcher(java.util.stream.Stream.concat(this.submatchers.stream(), java.util.stream.Stream.of(org.zwobble.precisely.Matchers.has("methodName", org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaMethodCall::methodName, methodName))).toList()); } diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaMethodDeclarationMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaMethodDeclarationMatcher.java index 69ae9b6..5d22326 100644 --- a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaMethodDeclarationMatcher.java +++ b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaMethodDeclarationMatcher.java @@ -25,7 +25,7 @@ public class JavaMethodDeclarationMatcher implements org.zwobble.precisely.Match return org.zwobble.precisely.Matchers.instanceOf(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaMethodDeclaration.class, this.submatchers); } - public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaMethodDeclarationMatcher withName(org.zwobble.precisely.Matcher<? super String> name) { + public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaMethodDeclarationMatcher withName(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier> name) { return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaMethodDeclarationMatcher(java.util.stream.Stream.concat(this.submatchers.stream(), java.util.stream.Stream.of(org.zwobble.precisely.Matchers.has("name", org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaMethodDeclaration::name, name))).toList()); } diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaMethodRefMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaMethodRefMatcher.java index ecbf83b..5a3fa79 100644 --- a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaMethodRefMatcher.java +++ b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaMethodRefMatcher.java @@ -29,7 +29,7 @@ public class JavaMethodRefMatcher implements org.zwobble.precisely.Matcher<java. return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaMethodRefMatcher(java.util.stream.Stream.concat(this.submatchers.stream(), java.util.stream.Stream.of(org.zwobble.precisely.Matchers.has("type", org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaMethodRef::type, type))).toList()); } - public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaMethodRefMatcher withMethodName(org.zwobble.precisely.Matcher<? super String> methodName) { + public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaMethodRefMatcher withMethodName(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier> methodName) { return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaMethodRefMatcher(java.util.stream.Stream.concat(this.submatchers.stream(), java.util.stream.Stream.of(org.zwobble.precisely.Matchers.has("methodName", org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaMethodRef::methodName, methodName))).toList()); } diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaParamMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaParamMatcher.java index 52cc589..67d2848 100644 --- a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaParamMatcher.java +++ b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaParamMatcher.java @@ -29,7 +29,7 @@ public class JavaParamMatcher implements org.zwobble.precisely.Matcher<java.lang return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaParamMatcher(java.util.stream.Stream.concat(this.submatchers.stream(), java.util.stream.Stream.of(org.zwobble.precisely.Matchers.has("type", org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaParam::type, type))).toList()); } - public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaParamMatcher withName(org.zwobble.precisely.Matcher<? super String> name) { + public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaParamMatcher withName(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier> name) { return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaParamMatcher(java.util.stream.Stream.concat(this.submatchers.stream(), java.util.stream.Stream.of(org.zwobble.precisely.Matchers.has("name", org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaParam::name, name))).toList()); } diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaRecordComponentMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaRecordComponentMatcher.java index 9b97101..376ba94 100644 --- a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaRecordComponentMatcher.java +++ b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaRecordComponentMatcher.java @@ -29,7 +29,7 @@ public class JavaRecordComponentMatcher implements org.zwobble.precisely.Matcher return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaRecordComponentMatcher(java.util.stream.Stream.concat(this.submatchers.stream(), java.util.stream.Stream.of(org.zwobble.precisely.Matchers.has("type", org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaRecordComponent::type, type))).toList()); } - public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaRecordComponentMatcher withName(org.zwobble.precisely.Matcher<? super String> name) { + public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaRecordComponentMatcher withName(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier> name) { return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaRecordComponentMatcher(java.util.stream.Stream.concat(this.submatchers.stream(), java.util.stream.Stream.of(org.zwobble.precisely.Matchers.has("name", org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaRecordComponent::name, name))).toList()); } diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaRecordDeclarationMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaRecordDeclarationMatcher.java index f937cf7..a19a6cf 100644 --- a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaRecordDeclarationMatcher.java +++ b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaRecordDeclarationMatcher.java @@ -25,7 +25,7 @@ public class JavaRecordDeclarationMatcher implements org.zwobble.precisely.Match return org.zwobble.precisely.Matchers.instanceOf(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaRecordDeclaration.class, this.submatchers); } - public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaRecordDeclarationMatcher withName(org.zwobble.precisely.Matcher<? super String> name) { + public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaRecordDeclarationMatcher withName(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier> name) { return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaRecordDeclarationMatcher(java.util.stream.Stream.concat(this.submatchers.stream(), java.util.stream.Stream.of(org.zwobble.precisely.Matchers.has("name", org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaRecordDeclaration::name, name))).toList()); } diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaRefMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaRefMatcher.java index cc68447..4e5a514 100644 --- a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaRefMatcher.java +++ b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaRefMatcher.java @@ -25,7 +25,7 @@ public class JavaRefMatcher implements org.zwobble.precisely.Matcher<java.lang.O return org.zwobble.precisely.Matchers.instanceOf(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaRef.class, this.submatchers); } - public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaRefMatcher withName(org.zwobble.precisely.Matcher<? super String> name) { + public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaRefMatcher withName(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier> name) { return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaRefMatcher(java.util.stream.Stream.concat(this.submatchers.stream(), java.util.stream.Stream.of(org.zwobble.precisely.Matchers.has("name", org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaRef::name, name))).toList()); } diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaStaticFieldAccessMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaStaticFieldAccessMatcher.java index d66288e..9cd874d 100644 --- a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaStaticFieldAccessMatcher.java +++ b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaStaticFieldAccessMatcher.java @@ -29,7 +29,7 @@ public class JavaStaticFieldAccessMatcher implements org.zwobble.precisely.Match return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaStaticFieldAccessMatcher(java.util.stream.Stream.concat(this.submatchers.stream(), java.util.stream.Stream.of(org.zwobble.precisely.Matchers.has("type", org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaStaticFieldAccess::type, type))).toList()); } - public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaStaticFieldAccessMatcher withFieldName(org.zwobble.precisely.Matcher<? super String> fieldName) { + public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaStaticFieldAccessMatcher withFieldName(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier> fieldName) { return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaStaticFieldAccessMatcher(java.util.stream.Stream.concat(this.submatchers.stream(), java.util.stream.Stream.of(org.zwobble.precisely.Matchers.has("fieldName", org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaStaticFieldAccess::fieldName, fieldName))).toList()); } diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaStaticMethodCallMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaStaticMethodCallMatcher.java index 1837a34..7f23124 100644 --- a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaStaticMethodCallMatcher.java +++ b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaStaticMethodCallMatcher.java @@ -29,7 +29,7 @@ public class JavaStaticMethodCallMatcher implements org.zwobble.precisely.Matche return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaStaticMethodCallMatcher(java.util.stream.Stream.concat(this.submatchers.stream(), java.util.stream.Stream.of(org.zwobble.precisely.Matchers.has("type", org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaStaticMethodCall::type, type))).toList()); } - public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaStaticMethodCallMatcher withMethodName(org.zwobble.precisely.Matcher<? super String> methodName) { + public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaStaticMethodCallMatcher withMethodName(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier> methodName) { return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaStaticMethodCallMatcher(java.util.stream.Stream.concat(this.submatchers.stream(), java.util.stream.Stream.of(org.zwobble.precisely.Matchers.has("methodName", org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaStaticMethodCall::methodName, methodName))).toList()); } |
