Skip to content

Commit

Permalink
feat: add inline struct field comments (#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
ttytm authored Mar 25, 2024
1 parent 7f91919 commit 609d66a
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion analyzer/psi/doc_comment_extractor.v
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,22 @@ pub fn extract_doc_comment(el PsiElement) string {
comment = line
}

mut field_eol_comment := ''
if el is FieldDeclaration {
if next := el.next_sibling() {
if next is Comment {
comment_start_line := next.node.start_point().row
if comment_start_line == el_start_line {
field_eol_comment = next.get_text().trim_string_left('//').trim_space()
}
}
}
}

if comments.len == 0 {
return if field_eol_comment != '' { '... ' + field_eol_comment } else { '' }
}

comments.reverse_in_place()

lines := comments.map(it.get_text()
Expand Down Expand Up @@ -84,5 +100,6 @@ pub fn extract_doc_comment(el PsiElement) string {
}
}

return res.str()
res_str := res.str() + if field_eol_comment != '' { '\n\n... ' + field_eol_comment } else { '' }
return res_str
}

0 comments on commit 609d66a

Please sign in to comment.