1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

vfmt: fix enum field comments

This commit is contained in:
Delyan Angelov 2020-07-02 17:39:56 +03:00
parent 132170f54c
commit d809bbb715

View File

@ -315,14 +315,14 @@ pub fn (mut f Fmt) stmt(node ast.Stmt) {
}
name := it.name.after('.')
f.writeln('enum $name {')
f.comments(it.comments)
f.comments(it.comments, false)
for field in it.fields {
f.write('\t$field.name')
if field.has_expr {
f.write(' = ')
f.expr(field.expr)
}
f.comments(it.comments)
f.comments(field.comments, true)
f.writeln('')
}
f.writeln('}\n')
@ -1100,12 +1100,17 @@ pub fn (mut f Fmt) comment(node ast.Comment) {
f.writeln('*/')
}
pub fn (mut f Fmt) comments(some_comments []ast.Comment) {
pub fn (mut f Fmt) comments(some_comments []ast.Comment, remove_last_new_line bool) {
for c in some_comments {
if !f.out.last_n(1)[0].is_space() {
f.write('\t')
}
f.indent++
f.comment(c)
f.indent--
}
if remove_last_new_line {
f.remove_new_line()
}
}
@ -1328,7 +1333,7 @@ pub fn (mut f Fmt) match_expr(it ast.MatchExpr) {
f.writeln('}')
}
}
f.comments(branch.post_comments)
f.comments(branch.post_comments, false)
}
f.indent--
f.write('}')