diff --git a/parser/printer.go b/parser/printer.go index 64063c8..09a519d 100644 --- a/parser/printer.go +++ b/parser/printer.go @@ -144,6 +144,7 @@ func (p *printer) printSelect(s *Select) { } if len(s.Cases) == 1 && s.Cases[0].Pattern.Value == "__soong_conditions_default__" { p.printExpression(s.Cases[0].Value) + p.pos = s.RBracePos return } p.requestSpace() @@ -317,8 +318,8 @@ func (p *printer) printEndOfLineCommentsBefore(pos scanner.Position) { if len(p.skippedComments) > 0 { for _, c := range p.skippedComments { p.printComment(c) + p._requestNewline() } - p._requestNewline() p.skippedComments = nil } for p.curComment < len(p.comments) && p.comments[p.curComment].Pos().Line < pos.Line { @@ -406,7 +407,9 @@ func (p *printer) printComment(cg *CommentGroup) { p._requestNewline() } } - p.pos = comment.End() + if p.pos.Offset < comment.End().Offset { + p.pos = comment.End() + } } } diff --git a/parser/printer_test.go b/parser/printer_test.go index 30425c2..166bb3c 100644 --- a/parser/printer_test.go +++ b/parser/printer_test.go @@ -281,7 +281,6 @@ module // test output: ` // test module { // test - srcs: [ "src1.c", "src2.c", @@ -356,9 +355,7 @@ test // test `, output: ` test { // test - // test - } `, }, @@ -598,12 +595,10 @@ foo { }), } `, - // TODO(b/323382414): This shouldn't have an empty newline after stuff output: ` // test foo { stuff: "c2", // test2 - } `, },