diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-10-08 12:46:14 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2019-10-08 12:46:14 +0100 |
commit | 92cf0eba93b8d2705ed39bef1a4ea665ed3c25dc (patch) | |
tree | a015a8a8162acacb61b3353b4642c93cd80e51ae /crates/ra_ide_api/src/completion/complete_scope.rs | |
parent | 93199002af05f3a3dfd274fe10633372f2471b73 (diff) | |
parent | b043358be936b7f139efd49b7d187d64e319830e (diff) |
Merge #1924
1924: Support inferring&completing `Self` type in enum/struct/union definitions r=ice1000 a=ice1000
Signed-off-by: ice1000 <[email protected]>
An attempt to fix #1908.
This code works, but I believe the implementation is ugly. Please give me suggestions!
Co-authored-by: ice1000 <[email protected]>
Diffstat (limited to 'crates/ra_ide_api/src/completion/complete_scope.rs')
-rw-r--r-- | crates/ra_ide_api/src/completion/complete_scope.rs | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/crates/ra_ide_api/src/completion/complete_scope.rs b/crates/ra_ide_api/src/completion/complete_scope.rs index 515a6285c..38a6c3d37 100644 --- a/crates/ra_ide_api/src/completion/complete_scope.rs +++ b/crates/ra_ide_api/src/completion/complete_scope.rs | |||
@@ -310,6 +310,35 @@ mod tests { | |||
310 | } | 310 | } |
311 | 311 | ||
312 | #[test] | 312 | #[test] |
313 | fn completes_self_in_enum() { | ||
314 | assert_debug_snapshot!( | ||
315 | do_reference_completion( | ||
316 | r" | ||
317 | enum X { | ||
318 | Y(<|>) | ||
319 | } | ||
320 | " | ||
321 | ), | ||
322 | @r###"[ | ||
323 | CompletionItem { | ||
324 | label: "Self", | ||
325 | source_range: [48; 48), | ||
326 | delete: [48; 48), | ||
327 | insert: "Self", | ||
328 | kind: TypeParam, | ||
329 | }, | ||
330 | CompletionItem { | ||
331 | label: "X", | ||
332 | source_range: [48; 48), | ||
333 | delete: [48; 48), | ||
334 | insert: "X", | ||
335 | kind: Enum, | ||
336 | }, | ||
337 | ]"### | ||
338 | ); | ||
339 | } | ||
340 | |||
341 | #[test] | ||
313 | fn completes_module_items() { | 342 | fn completes_module_items() { |
314 | assert_debug_snapshot!( | 343 | assert_debug_snapshot!( |
315 | do_reference_completion( | 344 | do_reference_completion( |