mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 21:35:20 +00:00
Use snippets in add_missing_members
This commit is contained in:
parent
e6fc0bdffb
commit
a04cababaa
6 changed files with 84 additions and 45 deletions
|
@ -10,7 +10,11 @@ use ra_syntax::{
|
|||
};
|
||||
use rustc_hash::{FxHashMap, FxHashSet};
|
||||
|
||||
use crate::{assist_config::SnippetCap, utils::render_snippet, AssistContext, AssistId, Assists};
|
||||
use crate::{
|
||||
assist_config::SnippetCap,
|
||||
utils::{render_snippet, Cursor},
|
||||
AssistContext, AssistId, Assists,
|
||||
};
|
||||
|
||||
// Assist: add_function
|
||||
//
|
||||
|
@ -81,7 +85,11 @@ struct FunctionTemplate {
|
|||
impl FunctionTemplate {
|
||||
fn to_string(&self, cap: Option<SnippetCap>) -> String {
|
||||
let f = match cap {
|
||||
Some(cap) => render_snippet(cap, self.fn_def.syntax(), self.placeholder_expr.syntax()),
|
||||
Some(cap) => render_snippet(
|
||||
cap,
|
||||
self.fn_def.syntax(),
|
||||
Cursor::Replace(self.placeholder_expr.syntax()),
|
||||
),
|
||||
None => self.fn_def.to_string(),
|
||||
};
|
||||
format!("{}{}{}", self.leading_ws, f, self.trailing_ws)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue