mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-27 05:23:24 +00:00
v4
This commit is contained in:
parent
0863024b1a
commit
0a91a54794
2 changed files with 20 additions and 20 deletions
|
@ -89,12 +89,12 @@ fn line_to_block(acc: &mut Assists, comment: ast::Comment) -> Option<()> {
|
|||
// contents of each line comment when they're put into the block comment.
|
||||
let indentation = IndentLevel::from_token(comment.syntax());
|
||||
|
||||
let cms = comments
|
||||
let block_comment_body = comments
|
||||
.into_iter()
|
||||
.map(|c| line_comment_text(indentation, c))
|
||||
.collect::<Vec<String>>();
|
||||
|
||||
let block_comment_body = cms.into_iter().join("\n");
|
||||
.collect::<Vec<String>>()
|
||||
.into_iter()
|
||||
.join("\n");
|
||||
|
||||
let block_prefix =
|
||||
CommentKind { shape: CommentShape::Block, ..comment.kind() }.prefix();
|
||||
|
|
|
@ -55,27 +55,27 @@ pub(crate) fn desugar_doc_comment(acc: &mut Assists, ctx: &AssistContext<'_>) ->
|
|||
}
|
||||
};
|
||||
|
||||
let text = match comments {
|
||||
Either::Left(comment) => {
|
||||
let text = comment.text();
|
||||
text[comment.prefix().len()..(text.len() - "*/".len())]
|
||||
.trim()
|
||||
.lines()
|
||||
.map(|l| l.strip_prefix(&indentation).unwrap_or(l))
|
||||
.join("\n")
|
||||
}
|
||||
Either::Right(comments) => comments
|
||||
.into_iter()
|
||||
.map(|cm| line_comment_text(IndentLevel(0), cm))
|
||||
.collect::<Vec<_>>()
|
||||
.join("\n"),
|
||||
};
|
||||
|
||||
acc.add(
|
||||
AssistId("desugar_doc_comment", AssistKind::RefactorRewrite),
|
||||
"Desugar doc-comment to attribute macro",
|
||||
target,
|
||||
|edit| {
|
||||
let text = match comments {
|
||||
Either::Left(comment) => {
|
||||
let text = comment.text();
|
||||
text[comment.prefix().len()..(text.len() - "*/".len())]
|
||||
.trim()
|
||||
.lines()
|
||||
.map(|l| l.strip_prefix(&indentation).unwrap_or(l))
|
||||
.join("\n")
|
||||
}
|
||||
Either::Right(comments) => comments
|
||||
.into_iter()
|
||||
.map(|cm| line_comment_text(IndentLevel(0), cm))
|
||||
.collect::<Vec<_>>()
|
||||
.join("\n"),
|
||||
};
|
||||
|
||||
let hashes = "#".repeat(required_hashes(&text));
|
||||
|
||||
let prefix = match placement {
|
||||
|
|
Loading…
Reference in a new issue