Skip to content

Commit

Permalink
[ggj][engx] fix: use StringObjectValue for AnnotationNode's descripti…
Browse files Browse the repository at this point in the history
…on (#389)

* fix: support LRO package.name annotations

* feat: add microgenerator rules for cloud/asset

* fix: update CircleCI

* fix: sort message fields in asc. index order

* feat: add cloud/redis microgenerator rules

* fix: linter

* fix: update parser test method sig order

* fix: update circleci config

* fix: linter

* fix: consoliate findRepeatedField into Message

* fix: use StringObjectValue for AnnotationNode's description
  • Loading branch information
miraleung committed Oct 10, 2020
1 parent 1ff08ee commit aa3c348
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
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

0 comments on commit aa3c348

Please sign in to comment.