Skip to content

Commit

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

* 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
  • Loading branch information
miraleung authored Nov 7, 2020
1 parent e6c9726 commit 97caddc
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,16 @@ public Builder setAnnotations(AnnotationNode... annotations) {

public abstract Builder setAnnotations(List<AnnotationNode> annotations);

public abstract PackageInfoDefinition build();
abstract PackageInfoDefinition autoBuild();

public PackageInfoDefinition build() {
PackageInfoDefinition packageInfo = autoBuild();
String contextInfo = String.format("package info for %s", packageInfo.pakkage());
NodeValidator.checkNoNullElements(packageInfo.fileHeader(), "file header", contextInfo);
NodeValidator.checkNoNullElements(
packageInfo.headerCommentStatements(), "header comments", contextInfo);
NodeValidator.checkNoNullElements(packageInfo.annotations(), "annotations", contextInfo);
return packageInfo;
}
}
}

0 comments on commit 97caddc

Please sign in to comment.