Skip to content

Commit

Permalink
fix(Go): fix missing imports (#739)
Browse files Browse the repository at this point in the history
* auto commit

* auto commit

* auto commit

---------

Co-authored-by: Shubham Chaturvedi <anotherosscontributor@gmail.com>
  • Loading branch information
rishav-karanjit and ShubhamChaturvedi7 authored Dec 9, 2024
1 parent caef779 commit 8a7d9fe
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1216,6 +1216,18 @@ private void handleDepErrorSerializer(
)
);
} else {
w.addImportFromModule(
SmithyNameResolver.getGoModuleNameForSmithyNamespace(
depShape.toShapeId().getNamespace()
),
SmithyNameResolver.smithyTypesNamespace(depShape)
);
w.addImportFromModule(
SmithyNameResolver.getGoModuleNameForSmithyNamespace(
depShape.toShapeId().getNamespace()
),
SmithyNameResolver.shapeNamespace(depShape)
);
w.write(
"""
case $L.$LBaseException:
Expand Down Expand Up @@ -1487,6 +1499,12 @@ func Error_FromDafny(err $L.Error)(error) {
final var depService = context
.model()
.expectShape(dep, ServiceShape.class);
writer.addImportFromModule(
SmithyNameResolver.getGoModuleNameForSmithyNamespace(
depService.toShapeId().getNamespace()
),
SmithyNameResolver.shapeNamespace(depService)
);
w.write(
"""
if err.Is_$L() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,12 @@ private String referencedResourceShape(final Shape resourceOrService) {
),
SmithyNameResolver.shapeNamespace(resourceShape)
);
writer.addImportFromModule(
SmithyNameResolver.getGoModuleNameForSmithyNamespace(
resourceOrService.toShapeId().getNamespace()
),
SmithyNameResolver.smithyTypesNamespace(resourceShape)
);
namespace =
SmithyNameResolver.shapeNamespace(resourceOrService).concat(".");
}
Expand Down Expand Up @@ -582,6 +588,19 @@ public String stringShape(final StringShape shape) {
);
}
if (shape.hasTrait(EnumTrait.class)) {
if (
!shape
.toShapeId()
.getNamespace()
.equals(context.settings().getService().getNamespace())
) {
writer.addImportFromModule(
SmithyNameResolver.getGoModuleNameForSmithyNamespace(
shape.toShapeId().getNamespace()
),
DafnyNameResolver.dafnyTypesNamespace(shape)
);
}
if (this.isOptional) {
return """
return func () *%s.%s {
Expand Down

0 comments on commit 8a7d9fe

Please sign in to comment.