From 24f1231b30cebb9c2b667d46b3ad79804c85a470 Mon Sep 17 00:00:00 2001 From: Mira Leung Date: Fri, 6 Nov 2020 21:43:36 -0800 Subject: [PATCH] [ggj][ast][engx] fix: validate non-null elements for ForStatement (#461) * fix: swap assertEquals args in JavaWriterVisitorTest to match (expected, actusl) order * fix: swap assertEquals args in ImportWriterVisitorTest to match (expected, actusl) order * fix: add node validator to refactor/centralize null element checks * fix: validate non-null elements for IfStatement * fix: validate non-null elements for AnonymousClassExpr * fix: validate non-null elements for BlockStatement * fix: validate non-null elements for ClassDefinition * fix: validate non-null elements for ConcreteReference * fix: validate non-null elements for ForStatement --- .../java/com/google/api/generator/engine/ast/ForStatement.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/google/api/generator/engine/ast/ForStatement.java b/src/main/java/com/google/api/generator/engine/ast/ForStatement.java index 7c6222d411..b1216b6210 100644 --- a/src/main/java/com/google/api/generator/engine/ast/ForStatement.java +++ b/src/main/java/com/google/api/generator/engine/ast/ForStatement.java @@ -48,6 +48,7 @@ public abstract static class Builder { public ForStatement build() { ForStatement forStatement = autoBuild(); + NodeValidator.checkNoNullElements(forStatement.body(), "body", "for-statement"); Preconditions.checkState( forStatement.localVariableExpr().isDecl(), "For-statement variable must be a declaration");