aboutsummaryrefslogtreecommitdiff
path: root/crates/ide_assists/src/handlers
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ide_assists/src/handlers')
-rw-r--r--crates/ide_assists/src/handlers/generate_getter.rs19
1 files changed, 12 insertions, 7 deletions
diff --git a/crates/ide_assists/src/handlers/generate_getter.rs b/crates/ide_assists/src/handlers/generate_getter.rs
index c77395824..9faaaf284 100644
--- a/crates/ide_assists/src/handlers/generate_getter.rs
+++ b/crates/ide_assists/src/handlers/generate_getter.rs
@@ -23,7 +23,7 @@ use crate::{
23// 23//
24// impl Person { 24// impl Person {
25// /// Get a reference to the person's name. 25// /// Get a reference to the person's name.
26// fn name(&self) -> &String { 26// fn $0name(&self) -> &String {
27// &self.name 27// &self.name
28// } 28// }
29// } 29// }
@@ -49,7 +49,7 @@ pub(crate) fn generate_getter(acc: &mut Assists, ctx: &AssistContext) -> Option<
49// 49//
50// impl Person { 50// impl Person {
51// /// Get a mutable reference to the person's name. 51// /// Get a mutable reference to the person's name.
52// fn name_mut(&mut self) -> &mut String { 52// fn $0name_mut(&mut self) -> &mut String {
53// &mut self.name 53// &mut self.name
54// } 54// }
55// } 55// }
@@ -119,7 +119,12 @@ pub(crate) fn generate_getter_impl(
119 strukt.syntax().text_range().end() 119 strukt.syntax().text_range().end()
120 }); 120 });
121 121
122 builder.insert(start_offset, buf); 122 match ctx.config.snippet_cap {
123 Some(cap) => {
124 builder.insert_snippet(cap, start_offset, buf.replacen("fn ", "fn $0", 1))
125 }
126 None => builder.insert(start_offset, buf),
127 }
123 }, 128 },
124 ) 129 )
125} 130}
@@ -146,7 +151,7 @@ struct Context {
146 151
147impl Context { 152impl Context {
148 /// Get a reference to the context's data. 153 /// Get a reference to the context's data.
149 fn data(&self) -> &Data { 154 fn $0data(&self) -> &Data {
150 &self.data 155 &self.data
151 } 156 }
152} 157}
@@ -167,7 +172,7 @@ struct Context {
167 172
168impl Context { 173impl Context {
169 /// Get a mutable reference to the context's data. 174 /// Get a mutable reference to the context's data.
170 fn data_mut(&mut self) -> &mut Data { 175 fn $0data_mut(&mut self) -> &mut Data {
171 &mut self.data 176 &mut self.data
172 } 177 }
173} 178}
@@ -224,7 +229,7 @@ pub(crate) struct Context {
224 229
225impl Context { 230impl Context {
226 /// Get a reference to the context's data. 231 /// Get a reference to the context's data.
227 pub(crate) fn data(&self) -> &Data { 232 pub(crate) fn $0data(&self) -> &Data {
228 &self.data 233 &self.data
229 } 234 }
230} 235}
@@ -262,7 +267,7 @@ impl Context {
262 } 267 }
263 268
264 /// Get a reference to the context's count. 269 /// Get a reference to the context's count.
265 fn count(&self) -> &usize { 270 fn $0count(&self) -> &usize {
266 &self.count 271 &self.count
267 } 272 }
268} 273}