aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_api/src/completion/completion_context.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ide_api/src/completion/completion_context.rs')
-rw-r--r--crates/ra_ide_api/src/completion/completion_context.rs6
1 files changed, 6 insertions, 0 deletions
diff --git a/crates/ra_ide_api/src/completion/completion_context.rs b/crates/ra_ide_api/src/completion/completion_context.rs
index b9f0abe19..d351be054 100644
--- a/crates/ra_ide_api/src/completion/completion_context.rs
+++ b/crates/ra_ide_api/src/completion/completion_context.rs
@@ -21,6 +21,7 @@ pub(crate) struct CompletionContext<'a> {
21 pub(super) function: Option<hir::Function>, 21 pub(super) function: Option<hir::Function>,
22 pub(super) function_syntax: Option<&'a ast::FnDef>, 22 pub(super) function_syntax: Option<&'a ast::FnDef>,
23 pub(super) use_item_syntax: Option<&'a ast::UseItem>, 23 pub(super) use_item_syntax: Option<&'a ast::UseItem>,
24 pub(super) struct_lit_syntax: Option<&'a ast::StructLit>,
24 pub(super) is_param: bool, 25 pub(super) is_param: bool,
25 /// A single-indent path, like `foo`. `::foo` should not be considered a trivial path. 26 /// A single-indent path, like `foo`. `::foo` should not be considered a trivial path.
26 pub(super) is_trivial_path: bool, 27 pub(super) is_trivial_path: bool,
@@ -55,6 +56,7 @@ impl<'a> CompletionContext<'a> {
55 function: None, 56 function: None,
56 function_syntax: None, 57 function_syntax: None,
57 use_item_syntax: None, 58 use_item_syntax: None,
59 struct_lit_syntax: None,
58 is_param: false, 60 is_param: false,
59 is_trivial_path: false, 61 is_trivial_path: false,
60 path_prefix: None, 62 path_prefix: None,
@@ -108,6 +110,10 @@ impl<'a> CompletionContext<'a> {
108 } 110 }
109 fn classify_name_ref(&mut self, original_file: &'a SourceFile, name_ref: &ast::NameRef) { 111 fn classify_name_ref(&mut self, original_file: &'a SourceFile, name_ref: &ast::NameRef) {
110 let name_range = name_ref.syntax().range(); 112 let name_range = name_ref.syntax().range();
113 if name_ref.syntax().parent().and_then(ast::NamedField::cast).is_some() {
114 self.struct_lit_syntax = find_node_at_offset(original_file.syntax(), self.offset);
115 }
116
111 let top_node = 117 let top_node =
112 name_ref.syntax().ancestors().take_while(|it| it.range() == name_range).last().unwrap(); 118 name_ref.syntax().ancestors().take_while(|it| it.range() == name_range).last().unwrap();
113 119