diff options
Diffstat (limited to 'crates/ra_ide/src/completion/completion_context.rs')
-rw-r--r-- | crates/ra_ide/src/completion/completion_context.rs | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/crates/ra_ide/src/completion/completion_context.rs b/crates/ra_ide/src/completion/completion_context.rs index f833d2a9a..fddaf21e4 100644 --- a/crates/ra_ide/src/completion/completion_context.rs +++ b/crates/ra_ide/src/completion/completion_context.rs | |||
@@ -1,17 +1,19 @@ | |||
1 | //! FIXME: write short doc here | 1 | //! FIXME: write short doc here |
2 | 2 | ||
3 | use hir::{Semantics, SemanticsScope}; | 3 | use hir::{db::HirDatabase, Semantics, SemanticsScope}; |
4 | use ra_db::SourceDatabase; | 4 | use ra_db::SourceDatabase; |
5 | use ra_ide_db::RootDatabase; | 5 | use ra_ide_db::RootDatabase; |
6 | use ra_syntax::{ | 6 | use ra_syntax::{ |
7 | algo::{find_covering_element, find_node_at_offset}, | 7 | algo::{find_covering_element, find_node_at_offset}, |
8 | ast, AstNode, | 8 | ast, |
9 | ast::ArgListOwner, | ||
10 | AstNode, | ||
9 | SyntaxKind::*, | 11 | SyntaxKind::*, |
10 | SyntaxNode, SyntaxToken, TextRange, TextUnit, | 12 | SyntaxNode, SyntaxToken, TextRange, TextUnit, |
11 | }; | 13 | }; |
12 | use ra_text_edit::AtomTextEdit; | 14 | use ra_text_edit::AtomTextEdit; |
13 | 15 | ||
14 | use crate::{completion::CompletionConfig, FilePosition}; | 16 | use crate::{call_info::call_info, completion::CompletionConfig, CallInfo, FilePosition}; |
15 | 17 | ||
16 | /// `CompletionContext` is created early during completion to figure out, where | 18 | /// `CompletionContext` is created early during completion to figure out, where |
17 | /// exactly is the cursor, syntax-wise. | 19 | /// exactly is the cursor, syntax-wise. |
@@ -21,6 +23,7 @@ pub(crate) struct CompletionContext<'a> { | |||
21 | pub(super) db: &'a RootDatabase, | 23 | pub(super) db: &'a RootDatabase, |
22 | pub(super) config: &'a CompletionConfig, | 24 | pub(super) config: &'a CompletionConfig, |
23 | pub(super) offset: TextUnit, | 25 | pub(super) offset: TextUnit, |
26 | pub(super) file_position: FilePosition, | ||
24 | /// The token before the cursor, in the original file. | 27 | /// The token before the cursor, in the original file. |
25 | pub(super) original_token: SyntaxToken, | 28 | pub(super) original_token: SyntaxToken, |
26 | /// The token before the cursor, in the macro-expanded file. | 29 | /// The token before the cursor, in the macro-expanded file. |
@@ -32,6 +35,7 @@ pub(crate) struct CompletionContext<'a> { | |||
32 | pub(super) record_lit_syntax: Option<ast::RecordLit>, | 35 | pub(super) record_lit_syntax: Option<ast::RecordLit>, |
33 | pub(super) record_lit_pat: Option<ast::RecordPat>, | 36 | pub(super) record_lit_pat: Option<ast::RecordPat>, |
34 | pub(super) impl_def: Option<ast::ImplDef>, | 37 | pub(super) impl_def: Option<ast::ImplDef>, |
38 | pub(super) call_info: Option<CallInfo>, | ||
35 | pub(super) is_param: bool, | 39 | pub(super) is_param: bool, |
36 | /// If a name-binding or reference to a const in a pattern. | 40 | /// If a name-binding or reference to a const in a pattern. |
37 | /// Irrefutable patterns (like let) are excluded. | 41 | /// Irrefutable patterns (like let) are excluded. |
@@ -88,9 +92,11 @@ impl<'a> CompletionContext<'a> { | |||
88 | original_token, | 92 | original_token, |
89 | token, | 93 | token, |
90 | offset: position.offset, | 94 | offset: position.offset, |
95 | file_position: position, | ||
91 | krate, | 96 | krate, |
92 | name_ref_syntax: None, | 97 | name_ref_syntax: None, |
93 | function_syntax: None, | 98 | function_syntax: None, |
99 | call_info: None, | ||
94 | use_item_syntax: None, | 100 | use_item_syntax: None, |
95 | record_lit_syntax: None, | 101 | record_lit_syntax: None, |
96 | record_lit_pat: None, | 102 | record_lit_pat: None, |
@@ -253,6 +259,8 @@ impl<'a> CompletionContext<'a> { | |||
253 | self.use_item_syntax = | 259 | self.use_item_syntax = |
254 | self.sema.ancestors_with_macros(self.token.parent()).find_map(ast::UseItem::cast); | 260 | self.sema.ancestors_with_macros(self.token.parent()).find_map(ast::UseItem::cast); |
255 | 261 | ||
262 | self.call_info = call_info(self.db, self.file_position); | ||
263 | |||
256 | self.function_syntax = self | 264 | self.function_syntax = self |
257 | .sema | 265 | .sema |
258 | .ancestors_with_macros(self.token.parent()) | 266 | .ancestors_with_macros(self.token.parent()) |