diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-02-01 22:37:59 +0000 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-02-01 22:37:59 +0000 |
commit | 4447019f4b5f24728bb7b91b161755ddb373c74c (patch) | |
tree | c53ff3531cbbad182e821eb92fa9ad201d2bff0c /crates/ra_ide_api/src/completion/completion_context.rs | |
parent | 2b5c226e86892113bcab478cdf4c9adaf1e7b2f6 (diff) | |
parent | c5852f422ff45adaa21815c1a15e03b067a56a82 (diff) |
Merge #693
693: Name resolution refactoring r=matklad a=flodiebold
This is still very WIP, but it's becoming quite big and I want to make sure this isn't going in a completely bad direction :sweat_smile:. I'm not really happy with how the path resolution looks, and I'm not sure `PerNs<Resolution>` is the best return type -- there are 'this cannot happen in the (types/values) namespace' cases everywhere. I also want to unify the `resolver` and `nameres` namespaces once I'm done switching everything to `Resolver`. Also, `Resolver` only has a lifetime because it needs to have a reference to the `ItemMap` during import resolution :confused:
The differences in the completion snapshots are almost completely just ordering (except it completes `Self` as well now), so I changed it to sort the completions before snapshotting.
Co-authored-by: Florian Diebold <[email protected]>
Diffstat (limited to 'crates/ra_ide_api/src/completion/completion_context.rs')
-rw-r--r-- | crates/ra_ide_api/src/completion/completion_context.rs | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/crates/ra_ide_api/src/completion/completion_context.rs b/crates/ra_ide_api/src/completion/completion_context.rs index 578af6e5b..5d1851da6 100644 --- a/crates/ra_ide_api/src/completion/completion_context.rs +++ b/crates/ra_ide_api/src/completion/completion_context.rs | |||
@@ -5,7 +5,7 @@ use ra_syntax::{ | |||
5 | algo::{find_leaf_at_offset, find_covering_node, find_node_at_offset}, | 5 | algo::{find_leaf_at_offset, find_covering_node, find_node_at_offset}, |
6 | SyntaxKind::*, | 6 | SyntaxKind::*, |
7 | }; | 7 | }; |
8 | use hir::source_binder; | 8 | use hir::{source_binder, Resolver}; |
9 | 9 | ||
10 | use crate::{db, FilePosition}; | 10 | use crate::{db, FilePosition}; |
11 | 11 | ||
@@ -16,6 +16,7 @@ pub(crate) struct CompletionContext<'a> { | |||
16 | pub(super) db: &'a db::RootDatabase, | 16 | pub(super) db: &'a db::RootDatabase, |
17 | pub(super) offset: TextUnit, | 17 | pub(super) offset: TextUnit, |
18 | pub(super) leaf: &'a SyntaxNode, | 18 | pub(super) leaf: &'a SyntaxNode, |
19 | pub(super) resolver: Resolver, | ||
19 | pub(super) module: Option<hir::Module>, | 20 | pub(super) module: Option<hir::Module>, |
20 | pub(super) function: Option<hir::Function>, | 21 | pub(super) function: Option<hir::Function>, |
21 | pub(super) function_syntax: Option<&'a ast::FnDef>, | 22 | pub(super) function_syntax: Option<&'a ast::FnDef>, |
@@ -42,12 +43,14 @@ impl<'a> CompletionContext<'a> { | |||
42 | original_file: &'a SourceFile, | 43 | original_file: &'a SourceFile, |
43 | position: FilePosition, | 44 | position: FilePosition, |
44 | ) -> Option<CompletionContext<'a>> { | 45 | ) -> Option<CompletionContext<'a>> { |
46 | let resolver = source_binder::resolver_for_position(db, position); | ||
45 | let module = source_binder::module_from_position(db, position); | 47 | let module = source_binder::module_from_position(db, position); |
46 | let leaf = find_leaf_at_offset(original_file.syntax(), position.offset).left_biased()?; | 48 | let leaf = find_leaf_at_offset(original_file.syntax(), position.offset).left_biased()?; |
47 | let mut ctx = CompletionContext { | 49 | let mut ctx = CompletionContext { |
48 | db, | 50 | db, |
49 | leaf, | 51 | leaf, |
50 | offset: position.offset, | 52 | offset: position.offset, |
53 | resolver, | ||
51 | module, | 54 | module, |
52 | function: None, | 55 | function: None, |
53 | function_syntax: None, | 56 | function_syntax: None, |