Skip to content
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 @@ -183,6 +183,7 @@ public void visit(TernaryExpr ternaryExpr) {
@Override
public void visit(VariableExpr variableExpr) {
variableExpr.variable().type().accept(this);
annotations(variableExpr.annotations());
if (variableExpr.exprReferenceExpr() != null) {
variableExpr.exprReferenceExpr().accept(this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,32 @@ public void writeVariableExprImports_nestedReference() {
writerVisitor.write());
}

@Test
public void writeVariableExprImports_withAnnotations() {
Variable variable =
Variable.builder()
.setName("expr")
.setType(TypeNode.withReference(ConcreteReference.withClazz(Expr.class)))
.build();

VariableExpr variableExpr =
VariableExpr.builder()
.setVariable(variable)
.setIsDecl(true)
.setAnnotations(
Arrays.asList(
AnnotationNode.withType(
TypeNode.withReference(ConcreteReference.withClazz(Generated.class)))))
.build();

variableExpr.accept(writerVisitor);
assertEquals(
LineFormatter.lines(
"import com.google.api.generator.engine.ast.Expr;\n",
"import javax.annotation.Generated;\n\n"),
writerVisitor.write());
}

@Test
public void writeAnonymousClassExprImports() {
// [Constructing] Function<List<IOException>, MethodDefinition>
Expand Down