diff options
Diffstat (limited to 'crates/ra_analysis/src/imp.rs')
-rw-r--r-- | crates/ra_analysis/src/imp.rs | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/crates/ra_analysis/src/imp.rs b/crates/ra_analysis/src/imp.rs index 5988fb779..44e7aca44 100644 --- a/crates/ra_analysis/src/imp.rs +++ b/crates/ra_analysis/src/imp.rs | |||
@@ -105,39 +105,36 @@ impl db::RootDatabase { | |||
105 | &self, | 105 | &self, |
106 | position: FilePosition, | 106 | position: FilePosition, |
107 | ) -> Cancelable<Vec<NavigationTarget>> { | 107 | ) -> Cancelable<Vec<NavigationTarget>> { |
108 | let descr = match source_binder::module_from_position(self, position)? { | 108 | let module = match source_binder::module_from_position(self, position)? { |
109 | None => return Ok(Vec::new()), | 109 | None => return Ok(Vec::new()), |
110 | Some(it) => it, | 110 | Some(it) => it, |
111 | }; | 111 | }; |
112 | let (file_id, decl) = match descr.parent_link_source(self) { | 112 | let (file_id, ast_module) = module.source(self); |
113 | let ast_module = match ast_module { | ||
113 | None => return Ok(Vec::new()), | 114 | None => return Ok(Vec::new()), |
114 | Some(it) => it, | 115 | Some(it) => it, |
115 | }; | 116 | }; |
116 | let decl = decl.borrowed(); | 117 | let ast_module = ast_module.borrowed(); |
117 | let decl_name = decl.name().unwrap(); | 118 | let name = ast_module.name().unwrap(); |
118 | Ok(vec![NavigationTarget { | 119 | Ok(vec![NavigationTarget { |
119 | file_id, | 120 | file_id, |
120 | name: decl_name.text(), | 121 | name: name.text(), |
121 | range: decl_name.syntax().range(), | 122 | range: name.syntax().range(), |
122 | kind: MODULE, | 123 | kind: MODULE, |
123 | ptr: None, | 124 | ptr: None, |
124 | }]) | 125 | }]) |
125 | } | 126 | } |
126 | /// Returns `Vec` for the same reason as `parent_module` | 127 | /// Returns `Vec` for the same reason as `parent_module` |
127 | pub(crate) fn crate_for(&self, file_id: FileId) -> Cancelable<Vec<CrateId>> { | 128 | pub(crate) fn crate_for(&self, file_id: FileId) -> Cancelable<Vec<CrateId>> { |
128 | let descr = match source_binder::module_from_file_id(self, file_id)? { | 129 | let module = match source_binder::module_from_file_id(self, file_id)? { |
130 | Some(it) => it, | ||
129 | None => return Ok(Vec::new()), | 131 | None => return Ok(Vec::new()), |
132 | }; | ||
133 | let krate = match module.krate(self)? { | ||
130 | Some(it) => it, | 134 | Some(it) => it, |
135 | None => return Ok(Vec::new()), | ||
131 | }; | 136 | }; |
132 | let root = descr.crate_root(); | 137 | Ok(vec![krate.crate_id()]) |
133 | let file_id = root.file_id(); | ||
134 | |||
135 | let crate_graph = self.crate_graph(); | ||
136 | let crate_id = crate_graph.crate_id_for_crate_root(file_id); | ||
137 | Ok(crate_id.into_iter().collect()) | ||
138 | } | ||
139 | pub(crate) fn crate_root(&self, crate_id: CrateId) -> FileId { | ||
140 | self.crate_graph().crate_root(crate_id) | ||
141 | } | 138 | } |
142 | pub(crate) fn find_all_refs( | 139 | pub(crate) fn find_all_refs( |
143 | &self, | 140 | &self, |