mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 13:25:09 +00:00
allow empty doc comments
This commit is contained in:
parent
ae282d8da6
commit
99e6438660
1 changed files with 6 additions and 4 deletions
|
@ -107,11 +107,13 @@ pub trait DocCommentsOwner: AstNode {
|
||||||
/// Returns the textual content of a doc comment block as a single string.
|
/// Returns the textual content of a doc comment block as a single string.
|
||||||
/// That is, strips leading `///` (+ optional 1 character of whitespace)
|
/// That is, strips leading `///` (+ optional 1 character of whitespace)
|
||||||
/// and joins lines.
|
/// and joins lines.
|
||||||
fn doc_comment_text(&self) -> Option<std::string::String> {
|
fn doc_comment_text(&self) -> Option<String> {
|
||||||
|
let mut has_comments = false;
|
||||||
let docs = self
|
let docs = self
|
||||||
.doc_comments()
|
.doc_comments()
|
||||||
.filter(|comment| comment.is_doc_comment())
|
.filter(|comment| comment.is_doc_comment())
|
||||||
.map(|comment| {
|
.map(|comment| {
|
||||||
|
has_comments = true;
|
||||||
let prefix_len = comment.prefix().len();
|
let prefix_len = comment.prefix().len();
|
||||||
|
|
||||||
let line = comment.text().as_str();
|
let line = comment.text().as_str();
|
||||||
|
@ -128,10 +130,10 @@ pub trait DocCommentsOwner: AstNode {
|
||||||
})
|
})
|
||||||
.join("\n");
|
.join("\n");
|
||||||
|
|
||||||
if docs.is_empty() {
|
if has_comments {
|
||||||
None
|
|
||||||
} else {
|
|
||||||
Some(docs)
|
Some(docs)
|
||||||
|
} else {
|
||||||
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue