diff options
Diffstat (limited to 'crates/ra_ide/src/completion/completion_context.rs')
-rw-r--r-- | crates/ra_ide/src/completion/completion_context.rs | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/crates/ra_ide/src/completion/completion_context.rs b/crates/ra_ide/src/completion/completion_context.rs index 981da2b79..48d69f7e5 100644 --- a/crates/ra_ide/src/completion/completion_context.rs +++ b/crates/ra_ide/src/completion/completion_context.rs | |||
@@ -19,6 +19,7 @@ pub(crate) struct CompletionContext<'a> { | |||
19 | pub(super) offset: TextUnit, | 19 | pub(super) offset: TextUnit, |
20 | pub(super) token: SyntaxToken, | 20 | pub(super) token: SyntaxToken, |
21 | pub(super) module: Option<hir::Module>, | 21 | pub(super) module: Option<hir::Module>, |
22 | pub(super) name_ref_syntax: Option<ast::NameRef>, | ||
22 | pub(super) function_syntax: Option<ast::FnDef>, | 23 | pub(super) function_syntax: Option<ast::FnDef>, |
23 | pub(super) use_item_syntax: Option<ast::UseItem>, | 24 | pub(super) use_item_syntax: Option<ast::UseItem>, |
24 | pub(super) record_lit_syntax: Option<ast::RecordLit>, | 25 | pub(super) record_lit_syntax: Option<ast::RecordLit>, |
@@ -69,6 +70,7 @@ impl<'a> CompletionContext<'a> { | |||
69 | token, | 70 | token, |
70 | offset: position.offset, | 71 | offset: position.offset, |
71 | module, | 72 | module, |
73 | name_ref_syntax: None, | ||
72 | function_syntax: None, | 74 | function_syntax: None, |
73 | use_item_syntax: None, | 75 | use_item_syntax: None, |
74 | record_lit_syntax: None, | 76 | record_lit_syntax: None, |
@@ -142,6 +144,8 @@ impl<'a> CompletionContext<'a> { | |||
142 | } | 144 | } |
143 | 145 | ||
144 | fn classify_name_ref(&mut self, original_file: SourceFile, name_ref: ast::NameRef) { | 146 | fn classify_name_ref(&mut self, original_file: SourceFile, name_ref: ast::NameRef) { |
147 | self.name_ref_syntax = | ||
148 | find_node_at_offset(original_file.syntax(), name_ref.syntax().text_range().start()); | ||
145 | let name_range = name_ref.syntax().text_range(); | 149 | let name_range = name_ref.syntax().text_range(); |
146 | if name_ref.syntax().parent().and_then(ast::RecordField::cast).is_some() { | 150 | if name_ref.syntax().parent().and_then(ast::RecordField::cast).is_some() { |
147 | self.record_lit_syntax = find_node_at_offset(original_file.syntax(), self.offset); | 151 | self.record_lit_syntax = find_node_at_offset(original_file.syntax(), self.offset); |
@@ -239,16 +243,15 @@ impl<'a> CompletionContext<'a> { | |||
239 | .expr() | 243 | .expr() |
240 | .map(|e| e.syntax().text_range()) | 244 | .map(|e| e.syntax().text_range()) |
241 | .and_then(|r| find_node_with_range(original_file.syntax(), r)); | 245 | .and_then(|r| find_node_with_range(original_file.syntax(), r)); |
242 | self.dot_receiver_is_ambiguous_float_literal = if let Some(ast::Expr::Literal(l)) = | 246 | self.dot_receiver_is_ambiguous_float_literal = |
243 | &self.dot_receiver | 247 | if let Some(ast::Expr::Literal(l)) = &self.dot_receiver { |
244 | { | 248 | match l.kind() { |
245 | match l.kind() { | 249 | ast::LiteralKind::FloatNumber { .. } => l.token().text().ends_with('.'), |
246 | ast::LiteralKind::FloatNumber { suffix: _ } => l.token().text().ends_with('.'), | 250 | _ => false, |
247 | _ => false, | 251 | } |
252 | } else { | ||
253 | false | ||
248 | } | 254 | } |
249 | } else { | ||
250 | false | ||
251 | } | ||
252 | } | 255 | } |
253 | if let Some(method_call_expr) = ast::MethodCallExpr::cast(parent) { | 256 | if let Some(method_call_expr) = ast::MethodCallExpr::cast(parent) { |
254 | // As above | 257 | // As above |