diff options
author | Aleksey Kladov <[email protected]> | 2018-11-27 22:19:55 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-11-27 22:19:55 +0000 |
commit | 36b1d20c1661877c0c5a55ccd07522bc97bfc254 (patch) | |
tree | df84b92b2a05fa9cf1306b3a26bb4f5969fd0784 /crates/ra_analysis/src/hir | |
parent | 16f67ee384d5b49358de167069535af727b87dba (diff) |
rename ModuleDescriptor -> Module
Diffstat (limited to 'crates/ra_analysis/src/hir')
-rw-r--r-- | crates/ra_analysis/src/hir/mod.rs | 6 | ||||
-rw-r--r-- | crates/ra_analysis/src/hir/module/mod.rs | 40 |
2 files changed, 23 insertions, 23 deletions
diff --git a/crates/ra_analysis/src/hir/mod.rs b/crates/ra_analysis/src/hir/mod.rs index e234173a9..1de8fadcf 100644 --- a/crates/ra_analysis/src/hir/mod.rs +++ b/crates/ra_analysis/src/hir/mod.rs | |||
@@ -19,14 +19,14 @@ use crate::{ | |||
19 | 19 | ||
20 | pub(crate) use self::{ | 20 | pub(crate) use self::{ |
21 | path::{Path, PathKind}, | 21 | path::{Path, PathKind}, |
22 | module::{ModuleDescriptor, ModuleId, Problem, nameres::FileItemId}, | 22 | module::{Module, ModuleId, Problem, nameres::FileItemId}, |
23 | function::{FunctionDescriptor, FnScopes}, | 23 | function::{FunctionDescriptor, FnScopes}, |
24 | }; | 24 | }; |
25 | 25 | ||
26 | pub use self::function::FnSignatureInfo; | 26 | pub use self::function::FnSignatureInfo; |
27 | 27 | ||
28 | pub(crate) enum Def { | 28 | pub(crate) enum Def { |
29 | Module(ModuleDescriptor), | 29 | Module(Module), |
30 | Item, | 30 | Item, |
31 | } | 31 | } |
32 | 32 | ||
@@ -35,7 +35,7 @@ impl DefId { | |||
35 | let loc = db.id_maps().def_loc(self); | 35 | let loc = db.id_maps().def_loc(self); |
36 | let res = match loc { | 36 | let res = match loc { |
37 | DefLoc::Module { id, source_root } => { | 37 | DefLoc::Module { id, source_root } => { |
38 | let descr = ModuleDescriptor::new(db, source_root, id)?; | 38 | let descr = Module::new(db, source_root, id)?; |
39 | Def::Module(descr) | 39 | Def::Module(descr) |
40 | } | 40 | } |
41 | DefLoc::Item { .. } => Def::Item, | 41 | DefLoc::Item { .. } => Def::Item, |
diff --git a/crates/ra_analysis/src/hir/module/mod.rs b/crates/ra_analysis/src/hir/module/mod.rs index 4d5945b1a..33d2b95ab 100644 --- a/crates/ra_analysis/src/hir/module/mod.rs +++ b/crates/ra_analysis/src/hir/module/mod.rs | |||
@@ -22,53 +22,53 @@ use crate::{ | |||
22 | 22 | ||
23 | pub(crate) use self::nameres::ModuleScope; | 23 | pub(crate) use self::nameres::ModuleScope; |
24 | 24 | ||
25 | /// `ModuleDescriptor` is API entry point to get all the information | 25 | /// `Module` is API entry point to get all the information |
26 | /// about a particular module. | 26 | /// about a particular module. |
27 | #[derive(Debug, Clone)] | 27 | #[derive(Debug, Clone)] |
28 | pub(crate) struct ModuleDescriptor { | 28 | pub(crate) struct Module { |
29 | tree: Arc<ModuleTree>, | 29 | tree: Arc<ModuleTree>, |
30 | source_root_id: SourceRootId, | 30 | source_root_id: SourceRootId, |
31 | module_id: ModuleId, | 31 | module_id: ModuleId, |
32 | } | 32 | } |
33 | 33 | ||
34 | impl ModuleDescriptor { | 34 | impl Module { |
35 | /// Lookup `ModuleDescriptor` by `FileId`. Note that this is inherently | 35 | /// Lookup `Module` by `FileId`. Note that this is inherently |
36 | /// lossy transformation: in general, a single source might correspond to | 36 | /// lossy transformation: in general, a single source might correspond to |
37 | /// several modules. | 37 | /// several modules. |
38 | pub fn guess_from_file_id( | 38 | pub fn guess_from_file_id( |
39 | db: &impl HirDatabase, | 39 | db: &impl HirDatabase, |
40 | file_id: FileId, | 40 | file_id: FileId, |
41 | ) -> Cancelable<Option<ModuleDescriptor>> { | 41 | ) -> Cancelable<Option<Module>> { |
42 | ModuleDescriptor::guess_from_source(db, file_id, ModuleSource::SourceFile(file_id)) | 42 | Module::guess_from_source(db, file_id, ModuleSource::SourceFile(file_id)) |
43 | } | 43 | } |
44 | 44 | ||
45 | /// Lookup `ModuleDescriptor` by position in the source code. Note that this | 45 | /// Lookup `Module` by position in the source code. Note that this |
46 | /// is inherently lossy transformation: in general, a single source might | 46 | /// is inherently lossy transformation: in general, a single source might |
47 | /// correspond to several modules. | 47 | /// correspond to several modules. |
48 | pub fn guess_from_position( | 48 | pub fn guess_from_position( |
49 | db: &impl HirDatabase, | 49 | db: &impl HirDatabase, |
50 | position: FilePosition, | 50 | position: FilePosition, |
51 | ) -> Cancelable<Option<ModuleDescriptor>> { | 51 | ) -> Cancelable<Option<Module>> { |
52 | let file = db.file_syntax(position.file_id); | 52 | let file = db.file_syntax(position.file_id); |
53 | let module_source = match find_node_at_offset::<ast::Module>(file.syntax(), position.offset) | 53 | let module_source = match find_node_at_offset::<ast::Module>(file.syntax(), position.offset) |
54 | { | 54 | { |
55 | Some(m) if !m.has_semi() => ModuleSource::new_inline(position.file_id, m), | 55 | Some(m) if !m.has_semi() => ModuleSource::new_inline(position.file_id, m), |
56 | _ => ModuleSource::SourceFile(position.file_id), | 56 | _ => ModuleSource::SourceFile(position.file_id), |
57 | }; | 57 | }; |
58 | ModuleDescriptor::guess_from_source(db, position.file_id, module_source) | 58 | Module::guess_from_source(db, position.file_id, module_source) |
59 | } | 59 | } |
60 | 60 | ||
61 | fn guess_from_source( | 61 | fn guess_from_source( |
62 | db: &impl HirDatabase, | 62 | db: &impl HirDatabase, |
63 | file_id: FileId, | 63 | file_id: FileId, |
64 | module_source: ModuleSource, | 64 | module_source: ModuleSource, |
65 | ) -> Cancelable<Option<ModuleDescriptor>> { | 65 | ) -> Cancelable<Option<Module>> { |
66 | let source_root_id = db.file_source_root(file_id); | 66 | let source_root_id = db.file_source_root(file_id); |
67 | let module_tree = db.module_tree(source_root_id)?; | 67 | let module_tree = db.module_tree(source_root_id)?; |
68 | 68 | ||
69 | let res = match module_tree.any_module_for_source(module_source) { | 69 | let res = match module_tree.any_module_for_source(module_source) { |
70 | None => None, | 70 | None => None, |
71 | Some(module_id) => Some(ModuleDescriptor { | 71 | Some(module_id) => Some(Module { |
72 | tree: module_tree, | 72 | tree: module_tree, |
73 | source_root_id, | 73 | source_root_id, |
74 | module_id, | 74 | module_id, |
@@ -81,9 +81,9 @@ impl ModuleDescriptor { | |||
81 | db: &impl HirDatabase, | 81 | db: &impl HirDatabase, |
82 | source_root_id: SourceRootId, | 82 | source_root_id: SourceRootId, |
83 | module_id: ModuleId, | 83 | module_id: ModuleId, |
84 | ) -> Cancelable<ModuleDescriptor> { | 84 | ) -> Cancelable<Module> { |
85 | let module_tree = db.module_tree(source_root_id)?; | 85 | let module_tree = db.module_tree(source_root_id)?; |
86 | let res = ModuleDescriptor { | 86 | let res = Module { |
87 | tree: module_tree, | 87 | tree: module_tree, |
88 | source_root_id, | 88 | source_root_id, |
89 | module_id, | 89 | module_id, |
@@ -105,18 +105,18 @@ impl ModuleDescriptor { | |||
105 | } | 105 | } |
106 | 106 | ||
107 | /// Parent module. Returns `None` if this is a root module. | 107 | /// Parent module. Returns `None` if this is a root module. |
108 | pub fn parent(&self) -> Option<ModuleDescriptor> { | 108 | pub fn parent(&self) -> Option<Module> { |
109 | let parent_id = self.module_id.parent(&self.tree)?; | 109 | let parent_id = self.module_id.parent(&self.tree)?; |
110 | Some(ModuleDescriptor { | 110 | Some(Module { |
111 | module_id: parent_id, | 111 | module_id: parent_id, |
112 | ..self.clone() | 112 | ..self.clone() |
113 | }) | 113 | }) |
114 | } | 114 | } |
115 | 115 | ||
116 | /// The root of the tree this module is part of | 116 | /// The root of the tree this module is part of |
117 | pub fn crate_root(&self) -> ModuleDescriptor { | 117 | pub fn crate_root(&self) -> Module { |
118 | let root_id = self.module_id.crate_root(&self.tree); | 118 | let root_id = self.module_id.crate_root(&self.tree); |
119 | ModuleDescriptor { | 119 | Module { |
120 | module_id: root_id, | 120 | module_id: root_id, |
121 | ..self.clone() | 121 | ..self.clone() |
122 | } | 122 | } |
@@ -138,9 +138,9 @@ impl ModuleDescriptor { | |||
138 | } | 138 | } |
139 | 139 | ||
140 | /// Finds a child module with the specified name. | 140 | /// Finds a child module with the specified name. |
141 | pub fn child(&self, name: &str) -> Option<ModuleDescriptor> { | 141 | pub fn child(&self, name: &str) -> Option<Module> { |
142 | let child_id = self.module_id.child(&self.tree, name)?; | 142 | let child_id = self.module_id.child(&self.tree, name)?; |
143 | Some(ModuleDescriptor { | 143 | Some(Module { |
144 | module_id: child_id, | 144 | module_id: child_id, |
145 | ..self.clone() | 145 | ..self.clone() |
146 | }) | 146 | }) |
@@ -168,7 +168,7 @@ impl ModuleDescriptor { | |||
168 | let segments = path.segments; | 168 | let segments = path.segments; |
169 | for name in segments.iter() { | 169 | for name in segments.iter() { |
170 | let module = match db.id_maps().def_loc(curr) { | 170 | let module = match db.id_maps().def_loc(curr) { |
171 | DefLoc::Module { id, source_root } => ModuleDescriptor::new(db, source_root, id)?, | 171 | DefLoc::Module { id, source_root } => Module::new(db, source_root, id)?, |
172 | _ => return Ok(None), | 172 | _ => return Ok(None), |
173 | }; | 173 | }; |
174 | let scope = module.scope(db)?; | 174 | let scope = module.scope(db)?; |