Skip to content

Commit

Permalink
Merge pull request #13 from urbanopt/fix/trailing-comments
Browse files Browse the repository at this point in the history
fix(modelicafmt): add comments trailing at end of file
  • Loading branch information
nllong authored Aug 14, 2020
2 parents 2676b0b + ef720bf commit 1bcb19a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions examples/gmt-building-out.mo
Original file line number Diff line number Diff line change
Expand Up @@ -187,3 +187,4 @@ First implementation.
</ul>
</html>"));
end building;
/* trailing comment */
3 changes: 2 additions & 1 deletion examples/gmt-building.mo
Original file line number Diff line number Diff line change
Expand Up @@ -221,4 +221,5 @@ First implementation.
</li>
</ul>
</html>"));
end building;
end building;
/* trailing comment */
8 changes: 8 additions & 0 deletions modelicafmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -423,5 +423,13 @@ func processFile(filename string, out io.Writer) error {
defer listener.close()

antlr.ParseTreeWalkerDefault.Walk(listener, sd)
// add any remaining comments and handle newline at end of file
for _, comment := range listener.commentTokens {
listener.writeComment(comment)
}
if !listener.onNewLine {
listener.writeNewline()
}

return nil
}

0 comments on commit 1bcb19a

Please sign in to comment.