From 5471c1ef4b2fda2fbaa63f7d8404abf04a3e9da4 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 11 Apr 2019 16:22:10 +0300 Subject: generalize SourceAnalyzer to handle all defs with bodies --- crates/ra_ide_api/src/completion/complete_dot.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'crates/ra_ide_api/src/completion') diff --git a/crates/ra_ide_api/src/completion/complete_dot.rs b/crates/ra_ide_api/src/completion/complete_dot.rs index 358057364..4a111aba5 100644 --- a/crates/ra_ide_api/src/completion/complete_dot.rs +++ b/crates/ra_ide_api/src/completion/complete_dot.rs @@ -305,6 +305,30 @@ mod tests { kind: Method, detail: "pub fn blah(&self)" } +]"### + ); + } + + #[test] + fn test_completion_works_in_consts() { + assert_debug_snapshot_matches!( + do_ref_completion( + r" + struct A { the_field: u32 } + const X: u32 = { + A { the_field: 92 }.<|> + }; + ", + ), + @r###"[ + CompletionItem { + label: "the_field", + source_range: [106; 106), + delete: [106; 106), + insert: "the_field", + kind: Field, + detail: "u32" + } ]"### ); } -- cgit v1.2.3