Skip to content

Commit 5b81aa0

Browse files
committed
juledoc: update to latest julefmt formatting
1 parent 299a6f4 commit 5b81aa0

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

builder/formatter.jule

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1455,7 +1455,14 @@ impl exprFormatter {
14551455
fn subIdent(&self, mut si: &ast::SubIdentExpr) {
14561456
self.format(si.Expr)
14571457
self.write(".")
1458+
if self.fmt.row != si.Ident.Row {
1459+
self.fmt.addIndent()
1460+
defer { self.fmt.doneIndent() }
1461+
self.write("\n")
1462+
self.fmt.buf.Write(self.fmt.indent)!
1463+
}
14581464
self.write(si.Ident.Kind)
1465+
self.fmt.row = si.Ident.Row
14591466
}
14601467

14611468
fn binary(&self, mut bin: &ast::BinaryExpr) {
@@ -1468,11 +1475,30 @@ impl exprFormatter {
14681475
ret
14691476
}
14701477

1478+
// Save the indentation for the SubIdentExpr.
1479+
// Arguments should be handled in this indentation.
1480+
// But exceptional call handler scopes must avoid this indentation.
1481+
//
1482+
// Respect this kind of expression:
1483+
// foo.
1484+
// Bar().
1485+
// Baz(
1486+
// "foo",
1487+
// "bar",
1488+
// "baz") else {
1489+
// println("error handling...")
1490+
// }
1491+
sie, _ := f.Expr.Kind.(&ast::SubIdentExpr)
1492+
if sie != nil && sie.Expr.Token.Row != sie.Ident.Row {
1493+
self.fmt.addIndent()
1494+
defer { self.fmt.doneIndent() }
1495+
}
1496+
14711497
// save state of zip mode
14721498
zip := self.bf.zip
14731499
self.bf.zip = self.bf.zip || len(f.Args) > 1 // enable zip mode if arguments more than one
14741500

1475-
mut row := f.Token.Row
1501+
mut row := self.fmt.row
14761502
mut indented := false
14771503
for (i, mut arg) in f.Args {
14781504
if i > 0 {
@@ -1504,6 +1530,7 @@ impl exprFormatter {
15041530
}
15051531

15061532
fn fnCall(&self, mut f: &ast::FuncCallExpr) {
1533+
self.fmt.row = f.Token.Row
15071534
if f.IsCo {
15081535
self.write("co ")
15091536
}

0 commit comments

Comments
 (0)