diff options
author | Cole Faust <colefaust@google.com> | 2024-03-19 16:41:14 -0700 |
---|---|---|
committer | Cole Faust <colefaust@google.com> | 2024-03-19 17:07:00 -0700 |
commit | d2f1141871f4fb2e5b3237fd822af9e7b05bf2f1 (patch) | |
tree | ea82d4b0d798e6a634aca73246ecd46dda4c496a | |
parent | a962edf7630abb8a67dc7f2883ac4c921bd0e8a9 (diff) | |
download | blueprint-d2f1141871f4fb2e5b3237fd822af9e7b05bf2f1.tar.gz |
Get rid of some extra newlines in bpfmt
Bug: 323382414
Test: go tests, and I also ran both the old/new bpfmts on the whole aosp source tree, and the only difference between the results was one extra removed line in external/uwb
Change-Id: I4942c9247a66f1de5028de39caa5cd34b66093c3
-rw-r--r-- | parser/printer.go | 7 | ||||
-rw-r--r-- | parser/printer_test.go | 5 |
2 files changed, 5 insertions, 7 deletions
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 - } `, }, |