Skip to content

Commit

Permalink
[ggj][ast][engx] fix: validate non-null elements for WhileStatement (#…
Browse files Browse the repository at this point in the history
…469)

* 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

* fix: validate non-null elements for GeneralForStatement

* fix: validate non-null elements for MethodDefinition

* fix: validate non-null elements for PackageInfoDefinition

* fix: validate non-null elements for SynchronizedStatement

* fix: validate non-null elements for TryCatchStatement

* fix: validate non-null elements for VaporReference

* fix: validate non-null elements for VariableExpr

* fix: validate non-null elements for WhileStatement
  • Loading branch information
miraleung authored Nov 7, 2020
1 parent 8906223 commit a40285b
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,14 @@ public abstract static class Builder {

public abstract Builder setBody(List<Statement> body);

// Private.
abstract ImmutableList<Statement> body();

abstract WhileStatement autoBuild();

public WhileStatement build() {
WhileStatement whileStatement = autoBuild();
NodeValidator.checkNoNullElements(body(), "body", "while statement");
Preconditions.checkState(
whileStatement.conditionExpr().type().equals(TypeNode.BOOLEAN),
"While condition must be a boolean-typed expression");
Expand Down

0 comments on commit a40285b

Please sign in to comment.