Skip to content

Commit

Permalink
Merge pull request #15 from Matts966/feature/better-comment-placement
Browse files Browse the repository at this point in the history
Better placement of comments
  • Loading branch information
Matts966 authored Apr 18, 2022
2 parents e42a474 + c25e070 commit 5988095
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions zetasql/parser/unparser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1373,6 +1373,8 @@ void Unparser::visitASTQuery(const ASTQuery* node, void* data) {
visitASTChildren(node, data);
}
PrintCloseParenIfNeeded(node);
// ASTQuery always ends parent.
formatter_.FlushCommentsPassedBy(node->parent()->GetParseLocationRange().end(), data);
}

void Unparser::visitASTSetOperation(const ASTSetOperation* node, void* data) {
Expand Down
2 changes: 2 additions & 0 deletions zetasql/parser/unparser.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,9 @@ class Unparser : public ParseTreeVisitor {
}

void visitASTChildren(const ASTNode* node, void* data) {
formatter_.FlushCommentsPassedBy(node->GetParseLocationRange().start(), data);
node->ChildrenAccept(this, data);
formatter_.FlushCommentsPassedBy(node->GetParseLocationRange().end(), data);
}

void visit(const ASTNode* node, void* data) override {
Expand Down

0 comments on commit 5988095

Please sign in to comment.