11//! Completion of names from the current scope, e.g. locals and imported items.
22
33use crate :: completion:: { CompletionContext , Completions } ;
4+ use hir:: ScopeDef ;
45
56pub ( super ) fn complete_scope ( acc : & mut Completions , ctx : & CompletionContext ) {
67 if !ctx. is_trivial_path && !ctx. is_pat_binding_and_path {
78 return ;
89 }
910
10- ctx. scope ( ) . process_all_names ( & mut |name, res| acc. add_resolution ( ctx, name. to_string ( ) , & res) ) ;
11+ ctx. scope ( ) . process_all_names ( & mut |name, res| match ( ctx. is_pat_binding_and_path , & res) {
12+ ( true , ScopeDef :: Local ( ..) ) => { }
13+ _ => acc. add_resolution ( ctx, name. to_string ( ) , & res) ,
14+ } ) ;
1115}
1216
1317#[ cfg( test) ]
@@ -21,53 +25,23 @@ mod tests {
2125 }
2226
2327 #[ test]
24- fn nested_bind_pat_and_path ( ) {
28+ fn bind_pat_and_path_ignore_ref ( ) {
2529 assert_debug_snapshot ! (
2630 do_reference_completion(
2731 r"
28- enum First {
32+ enum Enum {
2933 A,
3034 B,
3135 }
32- enum Second {
33- A(First),
34- B(First),
35- }
36- fn quux(x: Option<Option<Second>>>) {
36+ fn quux(x: Option<Enum>) {
3737 match x {
3838 None => (),
39- Some(Some(Second(Fi <|>)) ) => (),
39+ Some(ref en <|>) => (),
4040 }
4141 }
4242 "
4343 ) ,
44- @r###"
45- [
46- CompletionItem {
47- label: "First",
48- source_range: [363; 365),
49- delete: [363; 365),
50- insert: "First",
51- kind: Enum,
52- },
53- CompletionItem {
54- label: "Second",
55- source_range: [363; 365),
56- delete: [363; 365),
57- insert: "Second",
58- kind: Enum,
59- },
60- CompletionItem {
61- label: "quux(…)",
62- source_range: [363; 365),
63- delete: [363; 365),
64- insert: "quux(${1:x})$0",
65- kind: Function,
66- lookup: "quux",
67- detail: "fn quux(x: Option<Option<Second>>)",
68- },
69- ]
70- "###
44+ @r###"[]"###
7145 ) ;
7246 }
7347
@@ -83,7 +57,7 @@ mod tests {
8357 fn quux(x: Option<Enum>) {
8458 match x {
8559 None => (),
86- Some(en <|>) => (),
60+ Some(En <|>) => (),
8761 }
8862 }
8963 "
@@ -97,13 +71,6 @@ mod tests {
9771 insert: "Enum",
9872 kind: Enum,
9973 },
100- CompletionItem {
101- label: "None",
102- source_range: [231; 233),
103- delete: [231; 233),
104- insert: "None",
105- kind: Binding,
106- },
10774 CompletionItem {
10875 label: "quux(…)",
10976 source_range: [231; 233),
@@ -112,13 +79,7 @@ mod tests {
11279 kind: Function,
11380 lookup: "quux",
11481 detail: "fn quux(x: Option<Enum>)",
115- },
116- CompletionItem {
117- label: "x",
118- source_range: [231; 233),
119- delete: [231; 233),
120- insert: "x",
121- kind: Binding,
82+ trigger_call_info: true,
12283 },
12384 ]
12485 "###
0 commit comments