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

vfmt: handle comments

This commit is contained in:
Alexander Medvednikov
2019-11-11 17:18:32 +03:00
parent 51663520c8
commit ffa6bcfff5
14 changed files with 153 additions and 72 deletions

View File

@ -588,6 +588,9 @@ fn (s mut Scanner) scan() ScanRes {
s.ignore_line()
s.line_comment = s.text[start + 1..s.pos]
s.line_comment = s.line_comment.trim_space()
if s.is_fmt {
return scan_res(.line_comment, s.line_comment)
}
//s.fgenln('// ${s.prev_tok.str()} "$s.line_comment"')
// Skip the comment (return the next token)
return s.scan()
@ -617,8 +620,11 @@ fn (s mut Scanner) scan() ScanRes {
}
s.pos++
end := s.pos + 1
comm := s.text[start..end]
s.fgenln(comm)
comment := s.text[start..end]
if s.is_fmt {
s.line_comment = comment
return scan_res(.mline_comment, s.line_comment)
}
// Skip if not in fmt mode
return s.scan()
}