diff options
author | Aleksey Kladov <[email protected]> | 2019-02-24 14:01:56 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-02-24 14:01:56 +0000 |
commit | 65a2be49539375502ca95c8da455f50f580df2e3 (patch) | |
tree | f5e07db7d5ddbc920a5d768f516bf3b6097ad817 /crates/ra_ide_api/src/completion/completion_context.rs | |
parent | 666303faf3c8b4215fde884451688084e298d6a8 (diff) |
complete struct literals
Diffstat (limited to 'crates/ra_ide_api/src/completion/completion_context.rs')
-rw-r--r-- | crates/ra_ide_api/src/completion/completion_context.rs | 6 |
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 | ||