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

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

Issue 1770243002: Change line limit to 80 char. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 9 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') | no next file » | 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 1ca4b3e26905f1f77b936b88d4703b2e206b5011..b4f243ebfc670ea0495cf4f6ab6435e839c3602c 100644
--- a/mojom/mojom_parser/formatter/printer.go
+++ b/mojom/mojom_parser/formatter/printer.go
@@ -63,7 +63,7 @@ type printer struct {
// newPrinter is a constructor for printer.
func newPrinter() (p *printer) {
p = new(printer)
- p.maxLineLength = 100
+ p.maxLineLength = 80
return
}
@@ -240,6 +240,22 @@ func (p *printer) writeMethodParams(params *mojom.MojomStruct) {
extraIndent := p.lineLength() - p.indentSize
if ownLine {
+ // If we are printing every parameter on its own line, check to see if
+ // aligning the parameters to the right of the method name can be done.
+ for _, param := range declaredObjects {
+ scratch := newPrinter()
+ scratch.maxLineLength = -1
+ scratch.writeMethodParam(param.(*mojom.StructField))
+ // If any parameter would go beyond the maximum line length, start the
+ // list of parameters on the line after the method name and indented 4
+ // more than the method itself.
+ if len(scratch.result())+p.lineLength() > p.maxLineLength {
+ p.nl()
+ extraIndent = 4
+ break
+ }
+ }
+
p.indentSize += extraIndent
}
« no previous file with comments | « mojom/mojom_parser/formatter/formatter_test.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698