diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2018-10-30 23:10:48 +0000 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2018-10-30 23:10:48 +0000 |
commit | 032d15c392e8de7936c8729e03e6229313f3b054 (patch) | |
tree | 61cfa26801e456d5fdcd2619238c05bce62a1ac2 /crates/ra_analysis/src/descriptors/module/imp.rs | |
parent | 23cad90fe98dcca7f4b6905d9fd3ed52d2896c8c (diff) | |
parent | fbbee537228538f448a335bb0b2dabec2b3d443e (diff) |
Merge #171
171: Query-based module scopes r=matklad a=matklad
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_analysis/src/descriptors/module/imp.rs')
-rw-r--r-- | crates/ra_analysis/src/descriptors/module/imp.rs | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/crates/ra_analysis/src/descriptors/module/imp.rs b/crates/ra_analysis/src/descriptors/module/imp.rs index aecf6e29a..5fdaad137 100644 --- a/crates/ra_analysis/src/descriptors/module/imp.rs +++ b/crates/ra_analysis/src/descriptors/module/imp.rs | |||
@@ -13,7 +13,7 @@ use crate::{ | |||
13 | }; | 13 | }; |
14 | 14 | ||
15 | use super::{ | 15 | use super::{ |
16 | ModuleData, ModuleTree, ModuleId, LinkId, LinkData, Problem, ModulesDatabase | 16 | ModuleData, ModuleTree, ModuleId, LinkId, LinkData, Problem, ModulesDatabase, ModuleScope |
17 | }; | 17 | }; |
18 | 18 | ||
19 | 19 | ||
@@ -35,6 +35,18 @@ pub(super) fn modules(root: ast::Root<'_>) -> impl Iterator<Item = (SmolStr, ast | |||
35 | }) | 35 | }) |
36 | } | 36 | } |
37 | 37 | ||
38 | pub(super) fn module_scope( | ||
39 | db: &impl ModulesDatabase, | ||
40 | source_root_id: SourceRootId, | ||
41 | module_id: ModuleId, | ||
42 | ) -> Cancelable<Arc<ModuleScope>> { | ||
43 | let tree = db.module_tree(source_root_id)?; | ||
44 | let file_id = module_id.file_id(&tree); | ||
45 | let syntax = db.file_syntax(file_id); | ||
46 | let res = ModuleScope::new(&syntax); | ||
47 | Ok(Arc::new(res)) | ||
48 | } | ||
49 | |||
38 | pub(super) fn module_tree( | 50 | pub(super) fn module_tree( |
39 | db: &impl ModulesDatabase, | 51 | db: &impl ModulesDatabase, |
40 | source_root: SourceRootId, | 52 | source_root: SourceRootId, |