diff options
Diffstat (limited to 'crates/ra_analysis/src/imp.rs')
-rw-r--r-- | crates/ra_analysis/src/imp.rs | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/crates/ra_analysis/src/imp.rs b/crates/ra_analysis/src/imp.rs index 83a0dc445..f142b6c43 100644 --- a/crates/ra_analysis/src/imp.rs +++ b/crates/ra_analysis/src/imp.rs | |||
@@ -16,7 +16,8 @@ use relative_path::RelativePath; | |||
16 | use rustc_hash::FxHashSet; | 16 | use rustc_hash::FxHashSet; |
17 | 17 | ||
18 | use crate::{ | 18 | use crate::{ |
19 | descriptors::module::{ModuleTree, Problem}, | 19 | db::SyntaxDatabase, |
20 | descriptors::module::{ModulesDatabase, ModuleTree, Problem}, | ||
20 | descriptors::{FnDescriptor}, | 21 | descriptors::{FnDescriptor}, |
21 | roots::{ReadonlySourceRoot, SourceRoot, WritableSourceRoot}, | 22 | roots::{ReadonlySourceRoot, SourceRoot, WritableSourceRoot}, |
22 | CrateGraph, CrateId, Diagnostic, FileId, FileResolver, FileSystemEdit, Position, | 23 | CrateGraph, CrateId, Diagnostic, FileId, FileResolver, FileSystemEdit, Position, |
@@ -143,10 +144,10 @@ impl AnalysisImpl { | |||
143 | .unwrap() | 144 | .unwrap() |
144 | } | 145 | } |
145 | pub fn file_syntax(&self, file_id: FileId) -> File { | 146 | pub fn file_syntax(&self, file_id: FileId) -> File { |
146 | self.root(file_id).syntax(file_id) | 147 | self.root(file_id).db().file_syntax(file_id) |
147 | } | 148 | } |
148 | pub fn file_line_index(&self, file_id: FileId) -> Arc<LineIndex> { | 149 | pub fn file_line_index(&self, file_id: FileId) -> Arc<LineIndex> { |
149 | self.root(file_id).lines(file_id) | 150 | self.root(file_id).db().file_lines(file_id) |
150 | } | 151 | } |
151 | pub fn world_symbols(&self, query: Query) -> Cancelable<Vec<(FileId, FileSymbol)>> { | 152 | pub fn world_symbols(&self, query: Query) -> Cancelable<Vec<(FileId, FileSymbol)>> { |
152 | let mut buf = Vec::new(); | 153 | let mut buf = Vec::new(); |
@@ -161,14 +162,14 @@ impl AnalysisImpl { | |||
161 | } | 162 | } |
162 | pub fn parent_module(&self, file_id: FileId) -> Cancelable<Vec<(FileId, FileSymbol)>> { | 163 | pub fn parent_module(&self, file_id: FileId) -> Cancelable<Vec<(FileId, FileSymbol)>> { |
163 | let root = self.root(file_id); | 164 | let root = self.root(file_id); |
164 | let module_tree = root.module_tree()?; | 165 | let module_tree = root.db().module_tree()?; |
165 | 166 | ||
166 | let res = module_tree.modules_for_file(file_id) | 167 | let res = module_tree.modules_for_file(file_id) |
167 | .into_iter() | 168 | .into_iter() |
168 | .filter_map(|module_id| { | 169 | .filter_map(|module_id| { |
169 | let link = module_id.parent_link(&module_tree)?; | 170 | let link = module_id.parent_link(&module_tree)?; |
170 | let file_id = link.owner(&module_tree).file_id(&module_tree); | 171 | let file_id = link.owner(&module_tree).file_id(&module_tree); |
171 | let syntax = root.syntax(file_id); | 172 | let syntax = root.db().file_syntax(file_id); |
172 | let decl = link.bind_source(&module_tree, syntax.ast()); | 173 | let decl = link.bind_source(&module_tree, syntax.ast()); |
173 | 174 | ||
174 | let sym = FileSymbol { | 175 | let sym = FileSymbol { |
@@ -182,7 +183,7 @@ impl AnalysisImpl { | |||
182 | Ok(res) | 183 | Ok(res) |
183 | } | 184 | } |
184 | pub fn crate_for(&self, file_id: FileId) -> Cancelable<Vec<CrateId>> { | 185 | pub fn crate_for(&self, file_id: FileId) -> Cancelable<Vec<CrateId>> { |
185 | let module_tree = self.root(file_id).module_tree()?; | 186 | let module_tree = self.root(file_id).db().module_tree()?; |
186 | let crate_graph = &self.data.crate_graph; | 187 | let crate_graph = &self.data.crate_graph; |
187 | let res = module_tree.modules_for_file(file_id) | 188 | let res = module_tree.modules_for_file(file_id) |
188 | .into_iter() | 189 | .into_iter() |
@@ -202,8 +203,8 @@ impl AnalysisImpl { | |||
202 | offset: TextUnit, | 203 | offset: TextUnit, |
203 | ) -> Cancelable<Vec<(FileId, FileSymbol)>> { | 204 | ) -> Cancelable<Vec<(FileId, FileSymbol)>> { |
204 | let root = self.root(file_id); | 205 | let root = self.root(file_id); |
205 | let module_tree = root.module_tree()?; | 206 | let module_tree = root.db().module_tree()?; |
206 | let file = root.syntax(file_id); | 207 | let file = root.db().file_syntax(file_id); |
207 | let syntax = file.syntax(); | 208 | let syntax = file.syntax(); |
208 | if let Some(name_ref) = find_node_at_offset::<ast::NameRef>(syntax, offset) { | 209 | if let Some(name_ref) = find_node_at_offset::<ast::NameRef>(syntax, offset) { |
209 | // First try to resolve the symbol locally | 210 | // First try to resolve the symbol locally |
@@ -253,7 +254,7 @@ impl AnalysisImpl { | |||
253 | 254 | ||
254 | pub fn find_all_refs(&self, file_id: FileId, offset: TextUnit) -> Vec<(FileId, TextRange)> { | 255 | pub fn find_all_refs(&self, file_id: FileId, offset: TextUnit) -> Vec<(FileId, TextRange)> { |
255 | let root = self.root(file_id); | 256 | let root = self.root(file_id); |
256 | let file = root.syntax(file_id); | 257 | let file = root.db().file_syntax(file_id); |
257 | let syntax = file.syntax(); | 258 | let syntax = file.syntax(); |
258 | 259 | ||
259 | let mut ret = vec![]; | 260 | let mut ret = vec![]; |
@@ -285,8 +286,8 @@ impl AnalysisImpl { | |||
285 | 286 | ||
286 | pub fn diagnostics(&self, file_id: FileId) -> Cancelable<Vec<Diagnostic>> { | 287 | pub fn diagnostics(&self, file_id: FileId) -> Cancelable<Vec<Diagnostic>> { |
287 | let root = self.root(file_id); | 288 | let root = self.root(file_id); |
288 | let module_tree = root.module_tree()?; | 289 | let module_tree = root.db().module_tree()?; |
289 | let syntax = root.syntax(file_id); | 290 | let syntax = root.db().file_syntax(file_id); |
290 | 291 | ||
291 | let mut res = ra_editor::diagnostics(&syntax) | 292 | let mut res = ra_editor::diagnostics(&syntax) |
292 | .into_iter() | 293 | .into_iter() |
@@ -376,7 +377,7 @@ impl AnalysisImpl { | |||
376 | offset: TextUnit, | 377 | offset: TextUnit, |
377 | ) -> Cancelable<Option<(FnDescriptor, Option<usize>)>> { | 378 | ) -> Cancelable<Option<(FnDescriptor, Option<usize>)>> { |
378 | let root = self.root(file_id); | 379 | let root = self.root(file_id); |
379 | let file = root.syntax(file_id); | 380 | let file = root.db().file_syntax(file_id); |
380 | let syntax = file.syntax(); | 381 | let syntax = file.syntax(); |
381 | 382 | ||
382 | // Find the calling expression and it's NameRef | 383 | // Find the calling expression and it's NameRef |