diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2018-11-28 01:10:58 +0000 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2018-11-28 01:10:58 +0000 |
commit | 95c0c8f3986c8b3bcf0052d34d3ace09ebb9fa1b (patch) | |
tree | 0e5aa7337c000dd8c6ef3a7fedba68abf7feca8a /crates/ra_analysis/src/completion | |
parent | 9f08341aa486ea59cb488635f19e960523568fb8 (diff) | |
parent | 59e29aef633e906837f8fed604435976a46be691 (diff) |
Merge #247
247: Hir r=matklad a=matklad
This doesn't achive anything new, just a big refactoring.
The main change is that Descriptors are now called `hir`, and live in a separate crate.
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_analysis/src/completion')
-rw-r--r-- | crates/ra_analysis/src/completion/mod.rs | 10 | ||||
-rw-r--r-- | crates/ra_analysis/src/completion/reference_completion.rs | 16 |
2 files changed, 12 insertions, 14 deletions
diff --git a/crates/ra_analysis/src/completion/mod.rs b/crates/ra_analysis/src/completion/mod.rs index 5ef278127..e5ba92acd 100644 --- a/crates/ra_analysis/src/completion/mod.rs +++ b/crates/ra_analysis/src/completion/mod.rs | |||
@@ -7,13 +7,11 @@ use ra_syntax::{ | |||
7 | AstNode, AtomEdit, | 7 | AstNode, AtomEdit, |
8 | SyntaxNodeRef, | 8 | SyntaxNodeRef, |
9 | }; | 9 | }; |
10 | use ra_db::SyntaxDatabase; | ||
10 | use rustc_hash::{FxHashMap}; | 11 | use rustc_hash::{FxHashMap}; |
11 | 12 | ||
12 | use crate::{ | 13 | use crate::{ |
13 | db::{self, SyntaxDatabase}, | 14 | db, |
14 | descriptors::{ | ||
15 | module::{ModuleDescriptor} | ||
16 | }, | ||
17 | Cancelable, FilePosition | 15 | Cancelable, FilePosition |
18 | }; | 16 | }; |
19 | 17 | ||
@@ -31,14 +29,14 @@ pub(crate) fn completions( | |||
31 | db: &db::RootDatabase, | 29 | db: &db::RootDatabase, |
32 | position: FilePosition, | 30 | position: FilePosition, |
33 | ) -> Cancelable<Option<Vec<CompletionItem>>> { | 31 | ) -> Cancelable<Option<Vec<CompletionItem>>> { |
34 | let original_file = db.file_syntax(position.file_id); | 32 | let original_file = db.source_file(position.file_id); |
35 | // Insert a fake ident to get a valid parse tree | 33 | // Insert a fake ident to get a valid parse tree |
36 | let file = { | 34 | let file = { |
37 | let edit = AtomEdit::insert(position.offset, "intellijRulezz".to_string()); | 35 | let edit = AtomEdit::insert(position.offset, "intellijRulezz".to_string()); |
38 | original_file.reparse(&edit) | 36 | original_file.reparse(&edit) |
39 | }; | 37 | }; |
40 | 38 | ||
41 | let module = ctry!(ModuleDescriptor::guess_from_position(db, position)?); | 39 | let module = ctry!(hir::Module::guess_from_position(db, position)?); |
42 | 40 | ||
43 | let mut res = Vec::new(); | 41 | let mut res = Vec::new(); |
44 | let mut has_completions = false; | 42 | let mut has_completions = false; |
diff --git a/crates/ra_analysis/src/completion/reference_completion.rs b/crates/ra_analysis/src/completion/reference_completion.rs index 858b52e76..e1a2d5241 100644 --- a/crates/ra_analysis/src/completion/reference_completion.rs +++ b/crates/ra_analysis/src/completion/reference_completion.rs | |||
@@ -6,23 +6,23 @@ use ra_syntax::{ | |||
6 | ast::{self, LoopBodyOwner}, | 6 | ast::{self, LoopBodyOwner}, |
7 | SyntaxKind::*, | 7 | SyntaxKind::*, |
8 | }; | 8 | }; |
9 | use hir::{ | ||
10 | self, | ||
11 | FnScopes, | ||
12 | Def, | ||
13 | Path, | ||
14 | }; | ||
9 | 15 | ||
10 | use crate::{ | 16 | use crate::{ |
11 | db::RootDatabase, | 17 | db::RootDatabase, |
12 | completion::CompletionItem, | 18 | completion::CompletionItem, |
13 | descriptors::{ | ||
14 | module::{ModuleDescriptor}, | ||
15 | function::FnScopes, | ||
16 | Def, | ||
17 | Path, | ||
18 | }, | ||
19 | Cancelable | 19 | Cancelable |
20 | }; | 20 | }; |
21 | 21 | ||
22 | pub(super) fn completions( | 22 | pub(super) fn completions( |
23 | acc: &mut Vec<CompletionItem>, | 23 | acc: &mut Vec<CompletionItem>, |
24 | db: &RootDatabase, | 24 | db: &RootDatabase, |
25 | module: &ModuleDescriptor, | 25 | module: &hir::Module, |
26 | file: &SourceFileNode, | 26 | file: &SourceFileNode, |
27 | name_ref: ast::NameRef, | 27 | name_ref: ast::NameRef, |
28 | ) -> Cancelable<()> { | 28 | ) -> Cancelable<()> { |
@@ -150,7 +150,7 @@ fn complete_fn(name_ref: ast::NameRef, scopes: &FnScopes, acc: &mut Vec<Completi | |||
150 | fn complete_path( | 150 | fn complete_path( |
151 | acc: &mut Vec<CompletionItem>, | 151 | acc: &mut Vec<CompletionItem>, |
152 | db: &RootDatabase, | 152 | db: &RootDatabase, |
153 | module: &ModuleDescriptor, | 153 | module: &hir::Module, |
154 | mut path: Path, | 154 | mut path: Path, |
155 | ) -> Cancelable<()> { | 155 | ) -> Cancelable<()> { |
156 | if path.segments.is_empty() { | 156 | if path.segments.is_empty() { |