Skip to content

Commit

Permalink
julefmt: minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mertcandav committed Mar 29, 2024
1 parent e665d9e commit aa814fd
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions src/format.jule
Original file line number Diff line number Diff line change
Expand Up @@ -350,15 +350,15 @@ impl Formatter {
self.row = d.end.row
}

fn params(&self, mut &params: []&ast::ParamDecl) {
if params.len == 0 {
fn params(&self, mut &f: &ast::FnDecl) {
if f.params.len == 0 {
self.write("()")
ret
}
self.write("(")
let mut indented = false
let mut row = params[0].token.row
for (i, mut p) in params {
let mut row = f.token.row
for (i, mut p) in f.params {
if row != p.token.row {
self.write("\n")
if !indented {
Expand Down Expand Up @@ -394,8 +394,8 @@ impl Formatter {
}
self.format_type(p.kind)
}
if i + 1 < params.len {
if params[i + 1].token.row != p.token.row {
if i + 1 < f.params.len {
if f.params[i + 1].token.row != p.token.row {
self.pop_row_comments(p.token.row)
}
self.write(",")
Expand All @@ -413,7 +413,6 @@ impl Formatter {
fn fn_decl(&self, mut d: &ast::FnDecl) {
if d.directives.len != 0 {
self.directives(d.directives)
self.write("\n")
self.write(self.indent)
}
if d.public {
Expand All @@ -434,7 +433,7 @@ impl Formatter {
self.write(d.ident)
}
self.generics(d.generics)
self.params(d.params)
self.params(d)
if d.exceptional {
self.write("!")
}
Expand All @@ -449,8 +448,6 @@ impl Formatter {
self.format_scope(d.scope)
d.scope.unsafety = unsafety
self.row = d.scope.end.row
} else {
self.row = d.token.row
}
}

Expand Down Expand Up @@ -507,7 +504,6 @@ impl Formatter {
fn struct_decl(&self, mut d: &ast::StructDecl) {
if d.directives.len != 0 {
self.directives(d.directives)
self.write("\n")
}
if d.public {
self.write("pub ")
Expand Down Expand Up @@ -581,7 +577,6 @@ impl Formatter {
self.write(self.indent)
if d.directives.len != 0 {
self.directives(d.directives)
self.write("\n")
}
if d.cpp_linked {
self.write("cpp let ")
Expand Down

0 comments on commit aa814fd

Please sign in to comment.