Skip to content

Commit

Permalink
update for java idiomatic style, and update smithy-go version
Browse files Browse the repository at this point in the history
  • Loading branch information
skotambkar committed Apr 30, 2021
1 parent 342f8a2 commit 9315ba7
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ private static GoDependency relativePackage(
private static final class Versions {
private static final String GO_STDLIB = "1.15";
private static final String GO_CMP = "v0.5.4";
private static final String SMITHY_GO = "v1.3.1";
private static final String SMITHY_GO = "v1.3.2-0.20210427182611-342f8a297d6e";
private static final String GO_JMESPATH = "v0.4.0";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -325,11 +325,14 @@ private void generateSerFunction(

Symbol symbol = symbolProvider.toSymbol(shape);

String functionName = shape.hasTrait(SyntheticClone.class)
? ProtocolGenerator.getOperationDocumentSerFuncName(
shape, context.getProtocolName())
: ProtocolGenerator.getDocumentSerializerFunctionName(
shape, context.getService(), context.getProtocolName());
String functionName;
if (shape.hasTrait(SyntheticClone.class)) {
functionName = ProtocolGenerator.getOperationDocumentSerFuncName(
shape, context.getProtocolName());
} else {
functionName = ProtocolGenerator.getDocumentSerializerFunctionName(
shape, context.getService(), context.getProtocolName());
}

String additionalArguments = getAdditionalSerArguments().entrySet().stream()
.map(entry -> String.format(", %s %s", entry.getKey(), entry.getValue()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -666,14 +666,14 @@ private void writeHttpBindingSetter(
}

private void writeHttpBindingMember(
final GenerationContext context,
GenerationContext context,
HttpBinding binding
) {
GoWriter writer = context.getWriter();
Model model = context.getModel();
MemberShape memberShape = binding.getMember();
final Shape targetShape = model.expectShape(memberShape.getTarget());
final HttpBinding.Location location = binding.getLocation();
Shape targetShape = model.expectShape(memberShape.getTarget());
HttpBinding.Location location = binding.getLocation();

// return an error if member shape targets location label, but is unset.
if (location.equals(HttpBinding.Location.LABEL)) {
Expand Down Expand Up @@ -782,28 +782,18 @@ private void writeQueryBinding(
.getMember();
writer.openBlock("for i := range $L {", "}", operand, () -> {
GoValueAccessUtils.writeIfZeroValue(context.getModel(), writer, collectionMember,
operand + "[i]", () -> {
writer.write("continue");
});
operand + "[i]", () -> writer.write("continue"));

String addQuery = String.format("$L.AddQuery(%s).$L", isQueryParams ? "$L" : "$S");
writeHttpBindingSetter(context, writer, collectionMember, location, operand + "[i]",
(w, s) -> {
if (isQueryParams) {
w.writeInline("$L.AddQuery($L).$L", dest, locationName, s);
} else {
w.writeInline("$L.AddQuery($S).$L", dest, locationName, s);
}
});
(w, s) -> w.writeInline(addQuery, dest, locationName, s));
});
} else {
writeHttpBindingSetter(context, writer, memberShape, location, operand,
(w, s) -> {
if (isQueryParams) {
w.writeInline("$L.SetQuery($L).$L", dest, locationName, s);
} else {
w.writeInline("$L.SetQuery($S).$L", dest, locationName, s);
}
});
return;
}

String setQuery = String.format("$L.SetQuery(%s).$L", isQueryParams ? "$L" : "$S");
writeHttpBindingSetter(context, writer, memberShape, location, operand,
(w, s) -> w.writeInline(setQuery, dest, locationName, s));
}

private void writeHeaderBinding(
Expand Down

0 comments on commit 9315ba7

Please sign in to comment.