aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_assists
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_assists')
-rw-r--r--crates/ra_assists/src/add_missing_impl_members.rs31
1 files changed, 23 insertions, 8 deletions
diff --git a/crates/ra_assists/src/add_missing_impl_members.rs b/crates/ra_assists/src/add_missing_impl_members.rs
index 100ebb7b6..c82447b84 100644
--- a/crates/ra_assists/src/add_missing_impl_members.rs
+++ b/crates/ra_assists/src/add_missing_impl_members.rs
@@ -109,6 +109,7 @@ fn add_missing_impl_members_inner(
109 let replaced_text_range = TextUnit::of_str(&func_bodies); 109 let replaced_text_range = TextUnit::of_str(&func_bodies);
110 110
111 edit.replace(changed_range, func_bodies); 111 edit.replace(changed_range, func_bodies);
112 // FIXME: place the cursor on the first unimplemented?
112 edit.set_cursor( 113 edit.set_cursor(
113 changed_range.start() + replaced_text_range - TextUnit::of_str(&trailing_whitespace), 114 changed_range.start() + replaced_text_range - TextUnit::of_str(&trailing_whitespace),
114 ); 115 );
@@ -138,7 +139,7 @@ fn build_func_body(def: &ast::FnDef) -> String {
138 139
139 for child in def.syntax().children_with_tokens() { 140 for child in def.syntax().children_with_tokens() {
140 match (child.prev_sibling_or_token().map(|c| c.kind()), child.kind()) { 141 match (child.prev_sibling_or_token().map(|c| c.kind()), child.kind()) {
141 (_, SyntaxKind::SEMI) => buf.push_str(" { unimplemented!() }"), 142 (_, SyntaxKind::SEMI) => buf.push_str(" {\n unimplemented!()\n}"),
142 (_, SyntaxKind::ATTR) | (_, SyntaxKind::COMMENT) => {} 143 (_, SyntaxKind::ATTR) | (_, SyntaxKind::COMMENT) => {}
143 (Some(SyntaxKind::ATTR), SyntaxKind::WHITESPACE) 144 (Some(SyntaxKind::ATTR), SyntaxKind::WHITESPACE)
144 | (Some(SyntaxKind::COMMENT), SyntaxKind::WHITESPACE) => {} 145 | (Some(SyntaxKind::COMMENT), SyntaxKind::WHITESPACE) => {}
@@ -182,8 +183,12 @@ struct S;
182 183
183impl Foo for S { 184impl Foo for S {
184 fn bar(&self) {} 185 fn bar(&self) {}
185 fn foo(&self) { unimplemented!() } 186 fn foo(&self) {
186 fn baz(&self) { unimplemented!() }<|> 187 unimplemented!()
188 }
189 fn baz(&self) {
190 unimplemented!()
191 }<|>
187}", 192}",
188 ); 193 );
189 } 194 }
@@ -216,7 +221,9 @@ struct S;
216 221
217impl Foo for S { 222impl Foo for S {
218 fn bar(&self) {} 223 fn bar(&self) {}
219 fn foo(&self) { unimplemented!() }<|> 224 fn foo(&self) {
225 unimplemented!()
226 }<|>
220}", 227}",
221 ); 228 );
222 } 229 }
@@ -233,7 +240,9 @@ impl Foo for S { <|> }",
233trait Foo { fn foo(&self); } 240trait Foo { fn foo(&self); }
234struct S; 241struct S;
235impl Foo for S { 242impl Foo for S {
236 fn foo(&self) { unimplemented!() }<|> 243 fn foo(&self) {
244 unimplemented!()
245 }<|>
237}", 246}",
238 ); 247 );
239 } 248 }
@@ -250,7 +259,9 @@ impl Foo for S {}<|>",
250trait Foo { fn foo(&self); } 259trait Foo { fn foo(&self); }
251struct S; 260struct S;
252impl Foo for S { 261impl Foo for S {
253 fn foo(&self) { unimplemented!() }<|> 262 fn foo(&self) {
263 unimplemented!()
264 }<|>
254}", 265}",
255 ) 266 )
256 } 267 }
@@ -301,7 +312,9 @@ struct S;
301 312
302mod my_mod { 313mod my_mod {
303 impl crate::Foo for S { 314 impl crate::Foo for S {
304 fn valid(some: u32) -> bool { unimplemented!() }<|> 315 fn valid(some: u32) -> bool {
316 unimplemented!()
317 }<|>
305 } 318 }
306}", 319}",
307 ) 320 )
@@ -329,7 +342,9 @@ trait Foo {
329} 342}
330struct S; 343struct S;
331impl Foo for S { 344impl Foo for S {
332 fn foo(&self) { unimplemented!() }<|> 345 fn foo(&self) {
346 unimplemented!()
347 }<|>
333}"#, 348}"#,
334 ) 349 )
335 } 350 }