vfmt: support comments after interface methods
parent
4051ce869c
commit
35096cda3f
vlib/v
|
@ -273,6 +273,7 @@ pub:
|
||||||
pub mut:
|
pub mut:
|
||||||
stmts []Stmt
|
stmts []Stmt
|
||||||
return_type table.Type
|
return_type table.Type
|
||||||
|
comments []Comment // comments *after* the header, but *before* `{`; used for InterfaceDecl
|
||||||
}
|
}
|
||||||
|
|
||||||
// break, continue
|
// break, continue
|
||||||
|
|
|
@ -688,7 +688,13 @@ pub fn (mut f Fmt) interface_decl(node ast.InterfaceDecl) {
|
||||||
f.comments_after_last_field(node.pre_comments)
|
f.comments_after_last_field(node.pre_comments)
|
||||||
for method in node.methods {
|
for method in node.methods {
|
||||||
f.write('\t')
|
f.write('\t')
|
||||||
f.writeln(method.stringify(f.table, f.cur_mod).after('fn '))
|
f.write(method.stringify(f.table, f.cur_mod).after('fn '))
|
||||||
|
f.comments(method.comments, {
|
||||||
|
inline: true
|
||||||
|
has_nl: false
|
||||||
|
level: .indent
|
||||||
|
})
|
||||||
|
f.writeln('')
|
||||||
}
|
}
|
||||||
f.writeln('}\n')
|
f.writeln('}\n')
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
pub interface ReaderWriter {
|
||||||
|
read(mut buf []byte) ?int // from Reader
|
||||||
|
write(buf []byte) ?int // from Writer
|
||||||
|
}
|
|
@ -423,6 +423,7 @@ fn (mut p Parser) interface_decl() ast.InterfaceDecl {
|
||||||
if p.tok.kind.is_start_of_type() && p.tok.line_nr == line_nr {
|
if p.tok.kind.is_start_of_type() && p.tok.line_nr == line_nr {
|
||||||
method.return_type = p.parse_type()
|
method.return_type = p.parse_type()
|
||||||
}
|
}
|
||||||
|
method.comments = p.eat_comments()
|
||||||
methods << method
|
methods << method
|
||||||
// println('register method $name')
|
// println('register method $name')
|
||||||
return_type_sym := p.table.get_type_symbol(method.return_type)
|
return_type_sym := p.table.get_type_symbol(method.return_type)
|
||||||
|
|
Loading…
Reference in New Issue