Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Unified Diff: mojom/mojom_parser/formatter/printer.go

Issue 1750183002: Small formatter fixes. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojom/mojom_parser/formatter/formatter_test.go ('k') | mojom/mojom_parser/formatter/printer_test.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojom/mojom_parser/formatter/printer.go
diff --git a/mojom/mojom_parser/formatter/printer.go b/mojom/mojom_parser/formatter/printer.go
index 1529c165da151a37ca2d4cad7a59e1c252f5bc12..5c382008e151439da7505c1d84dc9747000645dc 100644
--- a/mojom/mojom_parser/formatter/printer.go
+++ b/mojom/mojom_parser/formatter/printer.go
@@ -267,11 +267,11 @@ func (p *printer) writeEnumValue(enumValue *mojom.EnumValue) {
// closing brace.
func (p *printer) writeDeclaredObjectsContainer(container mojom.DeclaredObjectsContainer) {
+ p.writef("%v {", container.(mojom.DeclaredObject).NameToken().Text)
if len(container.GetDeclaredObjects()) == 0 && !containsFinalComments(container.(mojom.MojomElement)) {
- p.writef("%v{};", container.(mojom.DeclaredObject).NameToken().Text)
+ p.writef("};")
return
}
- p.writef("%v {", container.(mojom.DeclaredObject).NameToken().Text)
p.writeRightComments(container.(mojom.MojomElement))
p.incIndent()
p.nl()
@@ -322,15 +322,16 @@ func (p *printer) writeAttributesBase(attrs *mojom.Attributes, singleLine bool)
p.writeAttribute(&attr)
if idx < len(attrs.List)-1 {
p.writef(",")
- if singleLine {
- p.write(" ")
- } else {
+ if !singleLine {
p.nl()
}
+ p.write(" ")
}
}
p.writef("]")
- if !singleLine {
+ if singleLine {
+ p.write(" ")
+ } else {
p.nl()
}
}
@@ -573,7 +574,7 @@ func (p *printer) write(s string) {
func (p *printer) nl() {
// Before going to the next line, print the last comment on the line.
if p.eolComment != nil {
- p.writef(" %s", p.eolComment.Text)
+ p.writef(" %s", p.eolComment.Text)
p.eolComment = nil
}
« no previous file with comments | « mojom/mojom_parser/formatter/formatter_test.go ('k') | mojom/mojom_parser/formatter/printer_test.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698