-
Notifications
You must be signed in to change notification settings - Fork 51
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
add codegen support for string array and operation context params in endpoint bindings #519
Conversation
} | ||
|
||
private Result visit(JmespathExpression expr, Shape current) { | ||
if (expr instanceof FunctionExpression) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nit] Since Java 17 you can do
if (expr instanceof FunctionExpression fexpr) {
// look ma, typecasting is already done
return visitFunction(fexpr, current)
}
[also nit, but tangential] if we could switch to Java 21 we could even do Pattern Matching and do something like
return switch (expr) {
case FunctionExpression fexpr -> return visitFunction(fexpr, current);
....
}
* trying to recursively compose/organize Writable templates. | ||
*/ | ||
@SmithyInternalApi | ||
public class GoJmespathExpressionGenerator { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should really have tests for this class
var lookahead = new GoJmespathExpressionGenerator(ctx, new GoWriter(""), leftMember, expr.getRight()) | ||
.generate("v"); | ||
|
||
++idIndex; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not quite sure I follow why we increase the index when visiting the projection. Each field increases the index because we're visiting a concrete field, but why do we increase it here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need a new identifier for the slice variable that holds the result of the overall projection (it's declared in the following write()).
return new Result(listOf(STRING_SHAPE), "v" + idIndex); | ||
} | ||
|
||
public record Result(Shape shape, String ident) {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<3
GoCodegenContext
field toCodegenVisitor
and pass it down. This context object contains a handful of principal codegen resources which everything generally needs, and passing it simplifies a lot of constructor calls (observe the difference inOperationGenerator
. This matches the newDirectedCodegen
pattern.