aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide/src/completion/completion_context.rs
diff options
context:
space:
mode:
authorFlorian Diebold <[email protected]>2020-03-07 16:53:22 +0000
committerFlorian Diebold <[email protected]>2020-03-07 16:53:22 +0000
commit941a5744095e55b9b0cafa63b10cb5480d02cc03 (patch)
treeea4470b4aba752a930203b81c87f28c226231c77 /crates/ra_ide/src/completion/completion_context.rs
parent020c00e44df1514b921669edc85129b37bce1610 (diff)
Fix CompletionContext module field (by removing it)
Two uses only needed the crate; one was wrong and should use the module from the scope instead.
Diffstat (limited to 'crates/ra_ide/src/completion/completion_context.rs')
-rw-r--r--crates/ra_ide/src/completion/completion_context.rs8
1 files changed, 3 insertions, 5 deletions
diff --git a/crates/ra_ide/src/completion/completion_context.rs b/crates/ra_ide/src/completion/completion_context.rs
index d173ef1f3..e7a8c78d0 100644
--- a/crates/ra_ide/src/completion/completion_context.rs
+++ b/crates/ra_ide/src/completion/completion_context.rs
@@ -24,7 +24,7 @@ pub(crate) struct CompletionContext<'a> {
24 pub(super) original_token: SyntaxToken, 24 pub(super) original_token: SyntaxToken,
25 /// The token before the cursor, in the macro-expanded file. 25 /// The token before the cursor, in the macro-expanded file.
26 pub(super) token: SyntaxToken, 26 pub(super) token: SyntaxToken,
27 pub(super) module: Option<hir::Module>, 27 pub(super) krate: Option<hir::Crate>,
28 pub(super) name_ref_syntax: Option<ast::NameRef>, 28 pub(super) name_ref_syntax: Option<ast::NameRef>,
29 pub(super) function_syntax: Option<ast::FnDef>, 29 pub(super) function_syntax: Option<ast::FnDef>,
30 pub(super) use_item_syntax: Option<ast::UseItem>, 30 pub(super) use_item_syntax: Option<ast::UseItem>,
@@ -73,8 +73,7 @@ impl<'a> CompletionContext<'a> {
73 let fake_ident_token = 73 let fake_ident_token =
74 file_with_fake_ident.syntax().token_at_offset(position.offset).right_biased().unwrap(); 74 file_with_fake_ident.syntax().token_at_offset(position.offset).right_biased().unwrap();
75 75
76 // TODO: shouldn't this take the position into account? (in case we're inside a mod {}) 76 let krate = sema.to_module_def(position.file_id).map(|m| m.krate());
77 let module = sema.to_module_def(position.file_id);
78 let original_token = 77 let original_token =
79 original_file.syntax().token_at_offset(position.offset).left_biased()?; 78 original_file.syntax().token_at_offset(position.offset).left_biased()?;
80 let token = sema.descend_into_macros(original_token.clone()); 79 let token = sema.descend_into_macros(original_token.clone());
@@ -84,7 +83,7 @@ impl<'a> CompletionContext<'a> {
84 original_token, 83 original_token,
85 token, 84 token,
86 offset: position.offset, 85 offset: position.offset,
87 module, 86 krate,
88 name_ref_syntax: None, 87 name_ref_syntax: None,
89 function_syntax: None, 88 function_syntax: None,
90 use_item_syntax: None, 89 use_item_syntax: None,
@@ -132,7 +131,6 @@ impl<'a> CompletionContext<'a> {
132 if new_offset >= actual_expansion.text_range().end() { 131 if new_offset >= actual_expansion.text_range().end() {
133 break; 132 break;
134 } 133 }
135 // TODO check that the expansions 'look the same' up to the inserted token?
136 original_file = actual_expansion; 134 original_file = actual_expansion;
137 hypothetical_file = hypothetical_expansion.0; 135 hypothetical_file = hypothetical_expansion.0;
138 fake_ident_token = hypothetical_expansion.1; 136 fake_ident_token = hypothetical_expansion.1;