diff --git a/project/jimmer-dto-compiler/src/main/antlr/org/babyfish/jimmer/dto/compiler/Dto.g4 b/project/jimmer-dto-compiler/src/main/antlr/org/babyfish/jimmer/dto/compiler/Dto.g4 index c68eb97b7a..5010f614e5 100644 --- a/project/jimmer-dto-compiler/src/main/antlr/org/babyfish/jimmer/dto/compiler/Dto.g4 +++ b/project/jimmer-dto-compiler/src/main/antlr/org/babyfish/jimmer/dto/compiler/Dto.g4 @@ -53,10 +53,10 @@ dtoBody explicitProp : - micro | aliasGroup | positiveProp | negativeProp | userProp + macro | aliasGroup | positiveProp | negativeProp | userProp ; -micro +macro : '#' name=Identifier ( @@ -83,7 +83,7 @@ aliasPattern aliasGroupProp : - micro | positiveProp + macro | positiveProp ; positiveProp diff --git a/project/jimmer-dto-compiler/src/main/java/org/babyfish/jimmer/dto/compiler/DtoTypeBuilder.java b/project/jimmer-dto-compiler/src/main/java/org/babyfish/jimmer/dto/compiler/DtoTypeBuilder.java index 47d1ccf094..caac6526cd 100644 --- a/project/jimmer-dto-compiler/src/main/java/org/babyfish/jimmer/dto/compiler/DtoTypeBuilder.java +++ b/project/jimmer-dto-compiler/src/main/java/org/babyfish/jimmer/dto/compiler/DtoTypeBuilder.java @@ -118,8 +118,8 @@ class DtoTypeBuilder { } for (DtoParser.ExplicitPropContext prop : body.explicitProps) { - if (prop.micro() != null) { - handleMicro(prop.micro()); + if (prop.macro() != null) { + handleMacro(prop.macro()); } else if (prop.aliasGroup() != null) { handleAliasGroup(prop.aliasGroup()); } else if (prop.positiveProp() != null) { @@ -163,36 +163,36 @@ private DtoTypeBuilder(DtoTypeBuilder base, Set> remo this.aliasPositivePropMap = aliasPositiveMap; } - private void handleMicro(DtoParser.MicroContext micro) { - boolean isAllReferences = micro.name.getText().equals("allReferences"); - if (!micro.name.getText().equals("allScalars") && !isAllReferences) { + private void handleMacro(DtoParser.MacroContext macro) { + boolean isAllReferences = macro.name.getText().equals("allReferences"); + if (!macro.name.getText().equals("allScalars") && !isAllReferences) { throw ctx.exception( - micro.name.getLine(), - micro.name.getCharPositionInLine(), - "Illegal micro name \"" + - micro.name.getText() + + macro.name.getLine(), + macro.name.getCharPositionInLine(), + "Illegal macro name \"" + + macro.name.getText() + "\", it must be \"#allScalars\" or \"#allReferences\"" ); } if (!positivePropMap.isEmpty() || !negativePropAliasMap.isEmpty()) { throw ctx.exception( - micro.name.getLine(), - micro.name.getCharPositionInLine(), + macro.name.getLine(), + macro.name.getCharPositionInLine(), "`#" + - micro.name + + macro.name + "` must be defined at the beginning" ); } Mandatory mandatory; - if (micro.required != null) { + if (macro.required != null) { mandatory = Mandatory.REQUIRED; - } else if (micro.optional != null) { + } else if (macro.optional != null) { if (modifiers.contains(DtoModifier.SPECIFICATION)) { throw ctx.exception( - micro.name.getLine(), - micro.name.getCharPositionInLine(), + macro.name.getLine(), + macro.name.getCharPositionInLine(), "Unnecessary optional modifier '?', all properties of specification are automatically optional" ); } @@ -206,7 +206,7 @@ private void handleMicro(DtoParser.MicroContext micro) { .findFirst() .orElse(DtoModifier.STATIC); - if (micro.args.isEmpty()) { + if (macro.args.isEmpty()) { for (P baseProp : ctx.getProps(baseType).values()) { if (isAllReferences ? isAutoReference(baseProp) : isAutoScalar(baseProp)) { DtoPropBuilder propBuilder = @@ -214,8 +214,8 @@ private void handleMicro(DtoParser.MicroContext micro) { this, currentAliasGroup, baseProp, - micro.start.getLine(), - micro.start.getCharPositionInLine(), + macro.start.getLine(), + macro.start.getCharPositionInLine(), isAllReferences ? "id" : null, mandatory, inputModifier, @@ -229,7 +229,7 @@ private void handleMicro(DtoParser.MicroContext micro) { Map> nameTypeMap = new HashMap<>(); collectSuperTypes(baseType, qualifiedNameTypeMap, nameTypeMap); Set handledBaseTypes = new LinkedHashSet<>(); - for (DtoParser.QualifiedNameContext qnCtx : micro.args) { + for (DtoParser.QualifiedNameContext qnCtx : macro.args) { String qualifiedName = qnCtx.parts.stream().map(Token::getText).collect(Collectors.joining(".")); T baseType = qualifiedName.equals("this") ? this.baseType : qualifiedNameTypeMap.get(qualifiedName); if (baseType == null) { @@ -377,8 +377,8 @@ private void handleAliasGroup(DtoParser.AliasGroupContext group) { currentAliasGroup = new AliasPattern(ctx, group.pattern); try { for (DtoParser.AliasGroupPropContext prop : group.props) { - if (prop.micro() != null) { - handleMicro(prop.micro()); + if (prop.macro() != null) { + handleMacro(prop.macro()); } else { handlePositiveProp(prop.positiveProp()); } diff --git a/project/jimmer-dto-compiler/src/test/java/org/babyfish/jimmer/dto/compiler/DtoCompilerTest.java b/project/jimmer-dto-compiler/src/test/java/org/babyfish/jimmer/dto/compiler/DtoCompilerTest.java index fcde80da8b..1b41e8d6d6 100644 --- a/project/jimmer-dto-compiler/src/test/java/org/babyfish/jimmer/dto/compiler/DtoCompilerTest.java +++ b/project/jimmer-dto-compiler/src/test/java/org/babyfish/jimmer/dto/compiler/DtoCompilerTest.java @@ -7,7 +7,6 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -import java.io.BufferedReader; import java.io.IOException; import java.io.Reader; import java.io.StringReader; @@ -221,7 +220,7 @@ public void testAllReferencesWithOverride() { } @Test - public void testMixedMicro() { + public void testMixedMacro() { List> dtoTypes = MyDtoCompiler.book( "input BookInput {\n" + " #allScalars(this)" +