diff --git a/codegen/gradle.properties b/codegen/gradle.properties index 544c84cf7..3f06b8d01 100644 --- a/codegen/gradle.properties +++ b/codegen/gradle.properties @@ -1,2 +1,2 @@ -smithyVersion=1.37.0 +smithyVersion=1.39.0 smithyGradleVersion=0.7.0 diff --git a/codegen/smithy-go-codegen/src/main/java/software/amazon/smithy/go/codegen/endpoints/EndpointClientPluginsGenerator.java b/codegen/smithy-go-codegen/src/main/java/software/amazon/smithy/go/codegen/endpoints/EndpointClientPluginsGenerator.java index a541f20fe..ae51cd219 100644 --- a/codegen/smithy-go-codegen/src/main/java/software/amazon/smithy/go/codegen/endpoints/EndpointClientPluginsGenerator.java +++ b/codegen/smithy-go-codegen/src/main/java/software/amazon/smithy/go/codegen/endpoints/EndpointClientPluginsGenerator.java @@ -54,7 +54,7 @@ private static String getAddEndpointMiddlewareFuncName(String operationName) { } private static String getExportedParameterName(Parameter parameter) { - return StringUtils.capitalize(parameter.getName().asString()); + return StringUtils.capitalize(parameter.getName().getName().getValue()); } private static Symbol parameterAsSymbol(Parameter parameter) { @@ -126,9 +126,9 @@ public void processFinalizedModel(GoSettings settings, Model model) { if (rulesetOpt.isPresent()) { var clientContextParams = clientContextParamsTrait.get(); var parameters = rulesetOpt.get().getParameters(); - parameters.toList().stream().forEach(param -> { + parameters.forEach(param -> { if ( - clientContextParams.getParameters().containsKey(param.getName().asString()) + clientContextParams.getParameters().containsKey(param.getName().getName().getValue()) && !param.getBuiltIn().isPresent() ) { var documentation = param.getDocumentation().isPresent() diff --git a/codegen/smithy-go-codegen/src/main/java/software/amazon/smithy/go/codegen/endpoints/EndpointMiddlewareGenerator.java b/codegen/smithy-go-codegen/src/main/java/software/amazon/smithy/go/codegen/endpoints/EndpointMiddlewareGenerator.java index 45d97a437..7cd43cc9d 100644 --- a/codegen/smithy-go-codegen/src/main/java/software/amazon/smithy/go/codegen/endpoints/EndpointMiddlewareGenerator.java +++ b/codegen/smithy-go-codegen/src/main/java/software/amazon/smithy/go/codegen/endpoints/EndpointMiddlewareGenerator.java @@ -17,6 +17,7 @@ import static software.amazon.smithy.go.codegen.GoWriter.goTemplate; +import java.util.Iterator; import java.util.List; import java.util.Optional; import software.amazon.smithy.codegen.core.CodegenException; @@ -104,8 +105,8 @@ private GoWriter.Writable generateMiddlewareType( return (GoWriter w) -> { w.openBlock("type $L struct {", "}", getMiddlewareObjectName(operationName), () -> { w.write("EndpointResolver $T", SymbolUtils.createValueSymbolBuilder("EndpointResolverV2").build()); - for (Parameter param : parameters.toList()) { - if (param.getBuiltIn().isPresent()) { + for (Iterator iter = parameters.iterator(); iter.hasNext();) { + if (iter.next().getBuiltIn().isPresent()) { for (GoIntegration integration : this.integrations) { var builtInHandlerOpt = integration.getEndpointBuiltinHandler(); if (builtInHandlerOpt.isPresent()) { @@ -116,11 +117,10 @@ private GoWriter.Writable generateMiddlewareType( } } - if (clientContextParamsTrait.isPresent()) { var clientContextParams = clientContextParamsTrait.get(); - parameters.toList().stream().forEach(param -> { - if (clientContextParams.getParameters().containsKey(param.getName().asString()) + parameters.forEach(param -> { + if (clientContextParams.getParameters().containsKey(param.getName().getName().getValue()) && !param.getBuiltIn().isPresent()) { w.write("$L $P", getExportedParameterName(param), parameterAsSymbol(param)); } @@ -295,8 +295,8 @@ private GoWriter.Writable generateLegacyResolverValidator() { private GoWriter.Writable generateBuiltInResolverInvocation(Parameters parameters) { return (GoWriter writer) -> { - for (Parameter parameter : parameters.toList()) { - if (parameter.getBuiltIn().isPresent()) { + for (Iterator iter = parameters.iterator(); iter.hasNext();) { + if (iter.next().getBuiltIn().isPresent()) { for (GoIntegration integration : this.integrations) { var builtInHandlerOpt = integration.getEndpointBuiltinHandler(); if (builtInHandlerOpt.isPresent()) { @@ -311,12 +311,11 @@ private GoWriter.Writable generateBuiltInResolverInvocation(Parameters parameter private GoWriter.Writable generateClientContextParamBinding( Parameters parameters, Optional clientContextParamsTrait) { - return (GoWriter writer) -> { if (clientContextParamsTrait.isPresent()) { var clientContextParams = clientContextParamsTrait.get(); - parameters.toList().stream().forEach(param -> { - if (clientContextParams.getParameters().containsKey(param.getName().asString()) + parameters.forEach(param -> { + if (clientContextParams.getParameters().containsKey(param.getName().getName().getValue()) && !param.getBuiltIn().isPresent() ) { var name = getExportedParameterName(param); @@ -355,9 +354,9 @@ private GoWriter.Writable generateContextParamBinding(OperationShape operationSh private GoWriter.Writable generateStaticContextParamBinding(Parameters parameters, OperationShape operationShape) { var staticContextParamTraitOpt = operationShape.getTrait(StaticContextParamsTrait.class); return (GoWriter writer) -> { - parameters.toList().stream().forEach(param -> { + parameters.forEach(param -> { if (staticContextParamTraitOpt.isPresent()) { - var paramName = param.getName().asString(); + var paramName = param.getName().getName().getValue(); var staticParam = staticContextParamTraitOpt .get() @@ -453,8 +452,8 @@ private GoWriter.Writable generateMiddlewareAdder( private GoWriter.Writable generateBuiltInInitialization(Parameters parameters) { return (GoWriter writer) -> { - for (Parameter parameter : parameters.toList()) { - if (parameter.getBuiltIn().isPresent()) { + for (Iterator iter = parameters.iterator(); iter.hasNext();) { + if (iter.next().getBuiltIn().isPresent()) { for (GoIntegration integration : this.integrations) { var builtInHandlerOpt = integration.getEndpointBuiltinHandler(); if (builtInHandlerOpt.isPresent()) { @@ -473,9 +472,9 @@ private GoWriter.Writable generateClientContextParamInitialization( return (GoWriter writer) -> { if (clientContextParamsTrait.isPresent()) { var clientContextParams = clientContextParamsTrait.get(); - parameters.toList().stream().forEach(param -> { + parameters.forEach(param -> { if ( - clientContextParams.getParameters().containsKey(param.getName().asString()) + clientContextParams.getParameters().containsKey(param.getName().getName().getValue()) && !param.getBuiltIn().isPresent() ) { var name = getExportedParameterName(param); @@ -496,7 +495,7 @@ public static String getMiddlewareObjectName(String operationName) { } public static String getExportedParameterName(Parameter parameter) { - return StringUtils.capitalize(parameter.getName().asString()); + return StringUtils.capitalize(parameter.getName().getName().getValue()); } public static Symbol parameterAsSymbol(Parameter parameter) { diff --git a/codegen/smithy-go-codegen/src/main/java/software/amazon/smithy/go/codegen/endpoints/EndpointParametersGenerator.java b/codegen/smithy-go-codegen/src/main/java/software/amazon/smithy/go/codegen/endpoints/EndpointParametersGenerator.java index 401f03776..cbc210108 100644 --- a/codegen/smithy-go-codegen/src/main/java/software/amazon/smithy/go/codegen/endpoints/EndpointParametersGenerator.java +++ b/codegen/smithy-go-codegen/src/main/java/software/amazon/smithy/go/codegen/endpoints/EndpointParametersGenerator.java @@ -22,16 +22,18 @@ import java.io.Serializable; import java.util.Comparator; +import java.util.Iterator; import java.util.Map; import java.util.Optional; import java.util.stream.Stream; +import java.util.stream.StreamSupport; import software.amazon.smithy.codegen.core.Symbol; import software.amazon.smithy.go.codegen.GoWriter; import software.amazon.smithy.go.codegen.SmithyGoDependency; import software.amazon.smithy.go.codegen.SymbolUtils; import software.amazon.smithy.model.node.StringNode; import software.amazon.smithy.rulesengine.language.EndpointRuleSet; -import software.amazon.smithy.rulesengine.language.eval.Value; +import software.amazon.smithy.rulesengine.language.evaluation.value.Value; import software.amazon.smithy.rulesengine.language.syntax.parameters.Parameter; import software.amazon.smithy.rulesengine.language.syntax.parameters.Parameters; import software.amazon.smithy.utils.MapUtils; @@ -93,12 +95,12 @@ private GoWriter.Writable generateParametersTypeDocs() { private GoWriter.Writable generateParametersMembers(Parameters parameters) { return (GoWriter w) -> { w.indent(); - parameters.toList().stream().forEach((parameter) -> { + parameters.forEach((parameter) -> { var writeChain = new GoWriter.ChainWritable() .add(parameter.getDocumentation(), GoWriter::goTemplate) // TODO[GH-25977529]: fix incorrect wrapping in generated comment .add(parameter.isRequired(), goTemplate("Parameter is required.")) - .add(parameter.getDefaultValue(), (defaultValue) -> { + .add(parameter.getDefault(), (defaultValue) -> { return goTemplate("Defaults to " + defaultValue + " if no value is provided."); }) .add(parameter.getBuiltIn(), GoWriter::goTemplate) @@ -131,7 +133,7 @@ private GoWriter.Writable generateDefaultsMethod(Parameters parameters) { "funcName", DEFAULT_VALUE_FUNC_NAME)), "setDefaults", (GoWriter.Writable) (GoWriter w) -> { sortParameters(parameters).forEach((parameter) -> { - parameter.getDefaultValue().ifPresent(defaultValue -> { + parameter.getDefault().ifPresent(defaultValue -> { w.writeGoTemplate(""" if p.$memberName:L == nil { p.$memberName:L = $defaultValue:W @@ -151,10 +153,10 @@ private GoWriter.Writable generateDefaultValue(Parameter parameter, Value defaul return switch (parameter.getType()) { case STRING -> goTemplate("$ptrString:T($value:S)", MapUtils.of( "ptrString", SymbolUtils.createValueSymbolBuilder("String", SmithyGoDependency.SMITHY_PTR).build(), - "value", defaultValue.expectString())); + "value", defaultValue.expectStringValue())); case BOOLEAN -> goTemplate("$ptrBool:T($value:L)", MapUtils.of( "ptrBool", SymbolUtils.createValueSymbolBuilder("Bool", SmithyGoDependency.SMITHY_PTR).build(), - "value", defaultValue.expectBool())); + "value", defaultValue.expectBooleanValue())); }; } @@ -206,8 +208,8 @@ public static Symbol parameterAsSymbol(Parameter parameter) { } public static boolean haveRequiredParameters(Parameters parameters) { - for (Parameter parameter : parameters.toList()) { - if (parameter.isRequired()) { + for (Iterator iter = parameters.iterator(); iter.hasNext();) { + if (iter.next().isRequired()) { return true; } } @@ -216,7 +218,7 @@ public static boolean haveRequiredParameters(Parameters parameters) { } public static String getExportedParameterName(Parameter parameter) { - return StringUtils.capitalize(parameter.getName().asString()); + return StringUtils.capitalize(parameter.getName().getName().getValue()); } public static String getExportedParameterName(StringNode name) { @@ -245,7 +247,9 @@ public EndpointParametersGenerator build() { } public static Stream sortParameters(Parameters parameters) { - return parameters.toList().stream().sorted(new Sorted()); + return StreamSupport + .stream(parameters.spliterator(), false) + .sorted(new Sorted()); } public static final class Sorted implements Comparator, Serializable { @@ -274,7 +278,7 @@ public int compare(Parameter a, Parameter b) { return requiredOption; } - return a.getName().asString().compareTo(b.getName().asString()); + return a.getName().getName().getValue().compareTo(b.getName().getName().getValue()); } } } diff --git a/codegen/smithy-go-codegen/src/main/java/software/amazon/smithy/go/codegen/endpoints/EndpointResolverGenerator.java b/codegen/smithy-go-codegen/src/main/java/software/amazon/smithy/go/codegen/endpoints/EndpointResolverGenerator.java index 8abf63d41..37bee724b 100644 --- a/codegen/smithy-go-codegen/src/main/java/software/amazon/smithy/go/codegen/endpoints/EndpointResolverGenerator.java +++ b/codegen/smithy-go-codegen/src/main/java/software/amazon/smithy/go/codegen/endpoints/EndpointResolverGenerator.java @@ -26,6 +26,7 @@ import static software.amazon.smithy.go.codegen.endpoints.FnGenerator.isFnResultOptional; import java.util.ArrayList; +import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Optional; @@ -35,22 +36,24 @@ import software.amazon.smithy.go.codegen.GoWriter; import software.amazon.smithy.go.codegen.SmithyGoDependency; import software.amazon.smithy.go.codegen.SymbolUtils; +import software.amazon.smithy.model.SourceException; import software.amazon.smithy.model.SourceLocation; import software.amazon.smithy.rulesengine.language.Endpoint; import software.amazon.smithy.rulesengine.language.EndpointRuleSet; -import software.amazon.smithy.rulesengine.language.eval.Type; +import software.amazon.smithy.rulesengine.language.error.RuleError; +import software.amazon.smithy.rulesengine.language.evaluation.type.OptionalType; import software.amazon.smithy.rulesengine.language.syntax.Identifier; -import software.amazon.smithy.rulesengine.language.syntax.expr.Expression; -import software.amazon.smithy.rulesengine.language.syntax.expr.Literal; -import software.amazon.smithy.rulesengine.language.syntax.expr.Reference; -import software.amazon.smithy.rulesengine.language.syntax.fn.FunctionDefinition; -import software.amazon.smithy.rulesengine.language.syntax.fn.IsSet; +import software.amazon.smithy.rulesengine.language.syntax.expressions.Expression; +import software.amazon.smithy.rulesengine.language.syntax.expressions.ExpressionVisitor; +import software.amazon.smithy.rulesengine.language.syntax.expressions.Reference; +import software.amazon.smithy.rulesengine.language.syntax.expressions.functions.FunctionDefinition; +import software.amazon.smithy.rulesengine.language.syntax.expressions.functions.IsSet; +import software.amazon.smithy.rulesengine.language.syntax.expressions.literal.Literal; import software.amazon.smithy.rulesengine.language.syntax.parameters.Parameter; import software.amazon.smithy.rulesengine.language.syntax.parameters.Parameters; import software.amazon.smithy.rulesengine.language.syntax.rule.Condition; import software.amazon.smithy.rulesengine.language.syntax.rule.Rule; -import software.amazon.smithy.rulesengine.language.visit.ExpressionVisitor; -import software.amazon.smithy.rulesengine.language.visit.RuleValueVisitor; +import software.amazon.smithy.rulesengine.language.syntax.rule.RuleValueVisitor; import software.amazon.smithy.utils.MapUtils; import software.amazon.smithy.utils.SmithyBuilder; @@ -145,11 +148,12 @@ private static String getMemberParameterName(Parameter p) { private GoWriter.Writable generateResolveMethodBody(EndpointRuleSet ruleset) { var scope = Scope.empty(); - for (Parameter p : ruleset.getParameters().toList()) { + for (Iterator iter = ruleset.getParameters().iterator(); iter.hasNext();) { // Required parameters can be dereferenced directly so that read access are // always by value. // Optional parameters will be dereferenced via conditional checks. String identName; + Parameter p = iter.next(); if (p.isRequired()) { identName = getLocalVarParameterName(p); } else { @@ -157,8 +161,7 @@ private GoWriter.Writable generateResolveMethodBody(EndpointRuleSet ruleset) { } scope = scope.withIdent(p.toExpression(), identName); } - - ruleset.typecheck(); + ruleset.typeCheck(); return goTemplate(""" $paramsWithDefaults:W $validateParams:W @@ -172,9 +175,13 @@ private GoWriter.Writable generateResolveMethodBody(EndpointRuleSet ruleset) { "validateParams", generateValidateParams(ruleset.getParameters()), "paramsWithDefaults", generateParamsWithDefaults(), "paramVars", (GoWriter.Writable) (GoWriter w) -> { - ruleset.getParameters().toList().stream().filter(Parameter::isRequired).forEach((p) -> { - w.write("$L := *$L", getLocalVarParameterName(p), getMemberParameterName(p)); - }); + for (Iterator iter = ruleset.getParameters().iterator(); iter.hasNext();) { + Parameter param = iter.next(); + if (!param.isRequired()) { + continue; + } + w.write("$L := *$L", getLocalVarParameterName(param), getMemberParameterName(param)); + } }, "rules", generateRulesList(ruleset.getRules(), scope))); } @@ -183,8 +190,7 @@ private GoWriter.Writable generateParamsWithDefaults() { return goTemplate("$paramArgName:L = $paramArgName:L.$withDefaults:L()", commonCodegenArgs, MapUtils.of( - "withDefaults", EndpointParametersGenerator.DEFAULT_VALUE_FUNC_NAME - )); + "withDefaults", EndpointParametersGenerator.DEFAULT_VALUE_FUNC_NAME)); } private GoWriter.Writable generateEmptyResolveMethodBody() { @@ -226,29 +232,35 @@ private GoWriter.Writable generateRulesList(List rules, Scope scope) { if (!rules.isEmpty()) { Rule lastRule = rules.get(rules.size() - 1); - // Trees are terminal, so we must ensure there's a final fallback condition at the end of each one. - // Generally we know we need to insert one when the final rule in a tree is not "static" i.e. it has - // conditions that might mean it is not selected. Since it may not be chosen (its set of conditions may - // evaluate to false) we MUST put a fallback error return after which we know will get executed. + // Trees are terminal, so we must ensure there's a final fallback condition at + // the end of each one. + // Generally we know we need to insert one when the final rule in a tree is not + // "static" i.e. it has + // conditions that might mean it is not selected. Since it may not be chosen + // (its set of conditions may + // evaluate to false) we MUST put a fallback error return after which we know + // will get executed. // - // However, assignment statements are conflated with conditions in the rules language, and while certain - // assignments DO have a condition associated with them (basically, checking that the result of the - // assignment is not nil), some do not. Therefore, remove "static" condition/assignments from + // However, assignment statements are conflated with conditions in the rules + // language, and while certain + // assignments DO have a condition associated with them (basically, checking + // that the result of the + // assignment is not nil), some do not. Therefore, remove "static" + // condition/assignments from // consideration. boolean needsFallback = !lastRule.getConditions().stream().filter( condition -> { - // You can't assert into a FunctionDefinition from an Expression - we have to inspect the fn + // You can't assert into a FunctionDefinition from an Expression - we have to + // inspect the fn // member of the node directly. String fn = condition.toNode().expectObjectNode().expectStringMember("fn").getValue(); // the only static assignment condition, as of this writing... return !fn.equals("uriEncode"); - } - ).toList().isEmpty(); + }).toList().isEmpty(); if (needsFallback) { w.writeGoTemplate( "return endpoint, $fmtErrorf:T(\"" + ERROR_MESSAGE_ENDOFTREE + "\")", - commonCodegenArgs - ); + commonCodegenArgs); } } }; @@ -268,7 +280,7 @@ private GoWriter.Writable generateRule(Rule rule, List conditions, Sc String conditionIdentifier; if (condition.getResult().isPresent()) { var ident = condition.getResult().get(); - conditionIdentifier = "_" + ident.asString(); + conditionIdentifier = "_" + ident.getName().getValue(); // Store the condition result so that it can be referenced in the future by the // result identifier. @@ -277,7 +289,7 @@ private GoWriter.Writable generateRule(Rule rule, List conditions, Sc conditionIdentifier = nameForExpression(fn); } - if (fn.type() instanceof Type.Option || isConditionalFnResultOptional(condition, fn)) { + if (fn.type() instanceof OptionalType || isConditionalFnResultOptional(condition, fn)) { return goTemplate(""" if exprVal := $target:W; exprVal != nil { $conditionIdent:L := *exprVal @@ -320,9 +332,14 @@ private GoWriter.Writable generateRule(Rule rule, List conditions, Sc } private static Expression conditionalFunc(Condition condition) { - var fn = condition.getFn(); + var fn = condition.getFunction(); if (fn instanceof IsSet) { - return ((IsSet) fn).getTarget(); + var setFn = ((IsSet) fn); + List argv = setFn.getArguments(); + if (argv.size() == 1) { + return argv.get(0); + } + throw new RuleError(new SourceException("expected 1 argument but found " + argv.size(), setFn)); } return fn; } diff --git a/codegen/smithy-go-codegen/src/main/java/software/amazon/smithy/go/codegen/endpoints/EndpointTestsGenerator.java b/codegen/smithy-go-codegen/src/main/java/software/amazon/smithy/go/codegen/endpoints/EndpointTestsGenerator.java index 71a286a5c..a57d34898 100644 --- a/codegen/smithy-go-codegen/src/main/java/software/amazon/smithy/go/codegen/endpoints/EndpointTestsGenerator.java +++ b/codegen/smithy-go-codegen/src/main/java/software/amazon/smithy/go/codegen/endpoints/EndpointTestsGenerator.java @@ -42,7 +42,7 @@ import software.amazon.smithy.model.node.ObjectNode; import software.amazon.smithy.model.node.StringNode; import software.amazon.smithy.rulesengine.language.EndpointRuleSet; -import software.amazon.smithy.rulesengine.language.syntax.parameters.Parameter; +import software.amazon.smithy.rulesengine.language.syntax.parameters.Parameters; import software.amazon.smithy.rulesengine.traits.EndpointTestCase; import software.amazon.smithy.rulesengine.traits.ExpectedEndpoint; import software.amazon.smithy.utils.MapUtils; @@ -71,9 +71,7 @@ public GoWriter.Writable generate(Optional ruleset, List writables = new ArrayList<>(); for (int i = 0; i < testCases.size(); i++) { @@ -103,7 +101,7 @@ private GoWriter.Writable generateTestCaseDocs(EndpointTestCase testCase) { return emptyGoTemplate(); } - private GoWriter.Writable generateTestCase(List parameters, EndpointTestCase testCase) { + private GoWriter.Writable generateTestCase(Parameters parameters, EndpointTestCase testCase) { return goTemplate(""" var params = $parametersType:T{ $parameterValues:W @@ -126,7 +124,7 @@ private GoWriter.Writable generateTestCase(List parameters, EndpointT "expectEndpoint", generateExpectEndpoint(testCase.getExpect().getEndpoint()))); } - private GoWriter.Writable generateParameterValues(List parameters, EndpointTestCase testCase) { + private GoWriter.Writable generateParameterValues(Parameters parameters, EndpointTestCase testCase) { List writables = new ArrayList<>(); // TODO filter keys based on actual modeled parameters Set parameterNames = new TreeSet<>(); diff --git a/codegen/smithy-go-codegen/src/main/java/software/amazon/smithy/go/codegen/endpoints/ExpressionGenerator.java b/codegen/smithy-go-codegen/src/main/java/software/amazon/smithy/go/codegen/endpoints/ExpressionGenerator.java index 2acbfb749..7c9d33d9e 100644 --- a/codegen/smithy-go-codegen/src/main/java/software/amazon/smithy/go/codegen/endpoints/ExpressionGenerator.java +++ b/codegen/smithy-go-codegen/src/main/java/software/amazon/smithy/go/codegen/endpoints/ExpressionGenerator.java @@ -27,14 +27,15 @@ import software.amazon.smithy.go.codegen.SymbolUtils; import software.amazon.smithy.model.SourceLocation; import software.amazon.smithy.rulesengine.language.syntax.Identifier; -import software.amazon.smithy.rulesengine.language.syntax.expr.Expression; -import software.amazon.smithy.rulesengine.language.syntax.expr.Literal; -import software.amazon.smithy.rulesengine.language.syntax.expr.Reference; -import software.amazon.smithy.rulesengine.language.syntax.expr.Template; -import software.amazon.smithy.rulesengine.language.syntax.fn.FunctionDefinition; -import software.amazon.smithy.rulesengine.language.syntax.fn.GetAttr; -import software.amazon.smithy.rulesengine.language.visit.ExpressionVisitor; -import software.amazon.smithy.rulesengine.language.visit.TemplateVisitor; +import software.amazon.smithy.rulesengine.language.syntax.expressions.Expression; +import software.amazon.smithy.rulesengine.language.syntax.expressions.ExpressionVisitor; +import software.amazon.smithy.rulesengine.language.syntax.expressions.Reference; +import software.amazon.smithy.rulesengine.language.syntax.expressions.Template; +import software.amazon.smithy.rulesengine.language.syntax.expressions.TemplateVisitor; +import software.amazon.smithy.rulesengine.language.syntax.expressions.functions.FunctionDefinition; +import software.amazon.smithy.rulesengine.language.syntax.expressions.functions.GetAttr; +import software.amazon.smithy.rulesengine.language.syntax.expressions.literal.Literal; +import software.amazon.smithy.rulesengine.language.syntax.expressions.literal.LiteralVisitor; import software.amazon.smithy.utils.MapUtils; import software.amazon.smithy.utils.StringUtils; @@ -122,10 +123,10 @@ public GoWriter.Writable visitLibraryFunction(FunctionDefinition fnDef, List { + implements LiteralVisitor { @Override - public GoWriter.Writable visitBool(boolean b) { + public GoWriter.Writable visitBoolean(boolean b) { return goTemplate(String.valueOf(b)); } diff --git a/codegen/smithy-go-codegen/src/main/java/software/amazon/smithy/go/codegen/endpoints/FnGenerator.java b/codegen/smithy-go-codegen/src/main/java/software/amazon/smithy/go/codegen/endpoints/FnGenerator.java index bc21a1658..7c5053ac4 100644 --- a/codegen/smithy-go-codegen/src/main/java/software/amazon/smithy/go/codegen/endpoints/FnGenerator.java +++ b/codegen/smithy-go-codegen/src/main/java/software/amazon/smithy/go/codegen/endpoints/FnGenerator.java @@ -24,8 +24,8 @@ import software.amazon.smithy.go.codegen.GoWriter; import software.amazon.smithy.go.codegen.SmithyGoDependency; import software.amazon.smithy.go.codegen.SymbolUtils; -import software.amazon.smithy.rulesengine.language.syntax.expr.Expression; -import software.amazon.smithy.rulesengine.language.syntax.fn.FunctionDefinition; +import software.amazon.smithy.rulesengine.language.syntax.expressions.Expression; +import software.amazon.smithy.rulesengine.language.syntax.expressions.functions.FunctionDefinition; import software.amazon.smithy.utils.MapUtils; public class FnGenerator { @@ -47,7 +47,6 @@ GoWriter.Writable generate(FunctionDefinition fnDef, List fnArgs) { goFn = this.fnProvider.fnFor(fnDef.getId()); } - List writableFnArgs = new ArrayList<>(); fnArgs.forEach((expr) -> { writableFnArgs.add(new ExpressionGenerator(scope, this.fnProvider).generate(expr)); @@ -72,7 +71,8 @@ public Symbol fnFor(String name) { case "uriEncode" -> SymbolUtils.createValueSymbolBuilder("URIEncode", SmithyGoDependency.SMITHY_ENDPOINT_RULESFN).build(); - default -> null; }; + default -> null; + }; } } diff --git a/codegen/smithy-go-codegen/src/main/java/software/amazon/smithy/go/codegen/endpoints/Scope.java b/codegen/smithy-go-codegen/src/main/java/software/amazon/smithy/go/codegen/endpoints/Scope.java index 846cae826..de91ecd3a 100644 --- a/codegen/smithy-go-codegen/src/main/java/software/amazon/smithy/go/codegen/endpoints/Scope.java +++ b/codegen/smithy-go-codegen/src/main/java/software/amazon/smithy/go/codegen/endpoints/Scope.java @@ -18,7 +18,7 @@ import java.util.HashMap; import java.util.Map; import java.util.Optional; -import software.amazon.smithy.rulesengine.language.syntax.expr.Expression; +import software.amazon.smithy.rulesengine.language.syntax.expressions.Expression; /* * Provides contextualized scope down the call tree to inform generator of expression origin.