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

[ggj][engx] fix: use StringObjectValue for AnnotationNode's description #389

Merged
merged 16 commits into from
Oct 10, 2020
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
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ private static TypeNode annotationType(Class clazz) {
// TODO(unsupported): Any args that do not consist of a single string. However, this can easily be
// extended to enable such support.
@Nullable
public abstract String description();
public abstract Expr descriptionExpr();

@Override
public void accept(AstNodeVisitor visitor) {
Expand All @@ -60,7 +60,13 @@ public static Builder builder() {
public abstract static class Builder {
public abstract Builder setType(TypeNode type);

public abstract Builder setDescription(String description);
public Builder setDescription(String description) {
return setDescriptionExpr(ValueExpr.withValue(StringObjectValue.withValue(description)));
}

// This will never be anything other than a ValueExpr-wrapped StringObjectValue because
// this setter is private, and called only by setDescription above.
abstract Builder setDescriptionExpr(Expr descriptionExpr);

abstract AnnotationNode autoBuild();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,10 @@ public void visit(ScopeNode scope) {
public void visit(AnnotationNode annotation) {
buffer.append(AT);
annotation.type().accept(this);
if (annotation.description() != null && !annotation.description().isEmpty()) {
buffer.append(String.format("(\"%s\")", annotation.description()));
if (annotation.descriptionExpr() != null) {
leftParen();
annotation.descriptionExpr().accept(this);
rightParen();
}
newline();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@ private static List<Expr> createPagingStaticAssignExprs(
String.format(
"No method found for message type %s for method %s among %s",
pagedResponseMessageKey, method.name(), messageTypes.keySet()));

Field repeatedPagedResultsField = pagedResponseMessage.findAndUnwrapFirstRepeatedField();
Preconditions.checkNotNull(
repeatedPagedResultsField,
Expand Down