Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upgrade to smithy 1.49 #511

Merged
merged 1 commit into from
May 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion codegen/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
smithyVersion=1.47.0
smithyVersion=1.49.0
smithyGradleVersion=0.7.0
Original file line number Diff line number Diff line change
Expand Up @@ -223,4 +223,8 @@ public static boolean isNilable(Symbol symbol) {
|| symbol.getProperty(SymbolUtils.GO_SLICE).isPresent()
|| symbol.getProperty(SymbolUtils.GO_MAP).isPresent();
}

public static Symbol pointerTo(Symbol symbol) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice 👍

return symbol.toBuilder().putProperty(POINTABLE, true).build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@

package software.amazon.smithy.go.codegen.endpoints;

import static software.amazon.smithy.go.codegen.endpoints.EndpointParametersGenerator.parameterAsSymbol;

import java.util.ArrayList;
import java.util.List;
import software.amazon.smithy.codegen.core.Symbol;
import software.amazon.smithy.go.codegen.GoSettings;
import software.amazon.smithy.go.codegen.SymbolUtils;
import software.amazon.smithy.go.codegen.integration.ConfigField;
Expand All @@ -44,16 +45,6 @@ private static String getExportedParameterName(Parameter parameter) {
return StringUtils.capitalize(parameter.getName().getName().getValue());
}

private static Symbol parameterAsSymbol(Parameter parameter) {
return switch (parameter.getType()) {
case STRING -> SymbolUtils.createPointableSymbolBuilder("string")
.putProperty(SymbolUtils.GO_UNIVERSE_TYPE, true).build();

case BOOLEAN -> SymbolUtils.createPointableSymbolBuilder("bool")
.putProperty(SymbolUtils.GO_UNIVERSE_TYPE, true).build();
};
}

@Override
public List<RuntimeClientPlugin> getClientPlugins() {
runtimeClientPlugins.add(RuntimeClientPlugin.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import static software.amazon.smithy.go.codegen.GoWriter.goBlockTemplate;
import static software.amazon.smithy.go.codegen.GoWriter.goDocTemplate;
import static software.amazon.smithy.go.codegen.GoWriter.goTemplate;
import static software.amazon.smithy.go.codegen.SymbolUtils.pointerTo;

import java.io.Serializable;
import java.util.Comparator;
Expand All @@ -27,7 +28,9 @@
import java.util.Optional;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;
import software.amazon.smithy.codegen.core.CodegenException;
import software.amazon.smithy.codegen.core.Symbol;
import software.amazon.smithy.go.codegen.GoUniverseTypes;
import software.amazon.smithy.go.codegen.GoWriter;
import software.amazon.smithy.go.codegen.SmithyGoDependency;
import software.amazon.smithy.go.codegen.SymbolUtils;
Expand Down Expand Up @@ -149,12 +152,11 @@ private GoWriter.Writable generateDefaultsMethod(Parameters parameters) {

private GoWriter.Writable generateDefaultValue(Parameter parameter, Value defaultValue) {
return switch (parameter.getType()) {
case STRING -> goTemplate("$ptrString:T($value:S)", MapUtils.of(
"ptrString", SymbolUtils.createValueSymbolBuilder("String", SmithyGoDependency.SMITHY_PTR).build(),
"value", defaultValue.expectStringValue()));
case BOOLEAN -> goTemplate("$ptrBool:T($value:L)", MapUtils.of(
"ptrBool", SymbolUtils.createValueSymbolBuilder("Bool", SmithyGoDependency.SMITHY_PTR).build(),
"value", defaultValue.expectBooleanValue()));
case STRING -> goTemplate("$T($S)",
SmithyGoDependency.SMITHY_PTR.func("String"), defaultValue.expectStringValue());
case BOOLEAN -> goTemplate("$T($L)",
SmithyGoDependency.SMITHY_PTR.func("Bool"), defaultValue.expectBooleanValue());
case STRING_ARRAY -> throw new CodegenException("unsupported endpoint parameter type stringArray");
};
}

Expand Down Expand Up @@ -197,11 +199,9 @@ private GoWriter.Writable generateValidationMethod(Parameters parameters) {

public static Symbol parameterAsSymbol(Parameter parameter) {
return switch (parameter.getType()) {
case STRING -> SymbolUtils.createPointableSymbolBuilder("string")
.putProperty(SymbolUtils.GO_UNIVERSE_TYPE, true).build();

case BOOLEAN -> SymbolUtils.createPointableSymbolBuilder("bool")
.putProperty(SymbolUtils.GO_UNIVERSE_TYPE, true).build();
case STRING -> pointerTo(GoUniverseTypes.String);
case BOOLEAN -> pointerTo(GoUniverseTypes.Bool);
case STRING_ARRAY -> throw new CodegenException("unsupported endpoint parameter type stringArray");
};
}

Expand Down
Loading