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 @@ -163,9 +163,10 @@ public ClassDefinition build() {
}

for (Statement statement : classDef.statements()) {
// TODO(xiaozhenliu): Add CommentStatement check here.
Preconditions.checkState(
statement instanceof ExprStatement || statement instanceof BlockStatement,
statement instanceof ExprStatement
|| statement instanceof BlockStatement
|| statement instanceof CommentStatement,
"Class statement type must be either an expression, block, or comment statement");
if (statement instanceof ExprStatement) {
Expr expr = ((ExprStatement) statement).expression();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,15 @@ public void validClassDefinition_basicWithCommentsAndHeader() {
}

@Test
public void validClassDefinition_exprAndBlockStatements() {
public void validClassDefinition_exprCommentAndBlockStatements() {
ClassDefinition.builder()
.setName("LibraryServiceStub")
.setIsNested(true)
.setScope(ScopeNode.PUBLIC)
.setStatements(
Arrays.asList(
BlockStatement.builder().setIsStatic(true).build(),
CommentStatement.withComment(LineComment.withComment("Test line comment.")),
ExprStatement.withExpr(
AssignmentExpr.builder()
.setVariableExpr(
Expand Down