diff options
Diffstat (limited to 'crates/ra_analysis/src/roots.rs')
-rw-r--r-- | crates/ra_analysis/src/roots.rs | 24 |
1 files changed, 5 insertions, 19 deletions
diff --git a/crates/ra_analysis/src/roots.rs b/crates/ra_analysis/src/roots.rs index 15081f555..aa0243720 100644 --- a/crates/ra_analysis/src/roots.rs +++ b/crates/ra_analysis/src/roots.rs | |||
@@ -17,9 +17,7 @@ use crate::{ | |||
17 | 17 | ||
18 | pub(crate) trait SourceRoot { | 18 | pub(crate) trait SourceRoot { |
19 | fn contains(&self, file_id: FileId) -> bool; | 19 | fn contains(&self, file_id: FileId) -> bool; |
20 | fn module_tree(&self) -> Cancelable<Arc<ModuleTree>>; | 20 | fn db(&self) -> &db::RootDatabase; |
21 | fn lines(&self, file_id: FileId) -> Arc<LineIndex>; | ||
22 | fn syntax(&self, file_id: FileId) -> File; | ||
23 | fn symbols(&self, acc: &mut Vec<Arc<SymbolIndex>>) -> Cancelable<()>; | 21 | fn symbols(&self, acc: &mut Vec<Arc<SymbolIndex>>) -> Cancelable<()>; |
24 | } | 22 | } |
25 | 23 | ||
@@ -63,17 +61,11 @@ impl WritableSourceRoot { | |||
63 | } | 61 | } |
64 | 62 | ||
65 | impl SourceRoot for WritableSourceRoot { | 63 | impl SourceRoot for WritableSourceRoot { |
66 | fn module_tree(&self) -> Cancelable<Arc<ModuleTree>> { | ||
67 | self.db.module_tree() | ||
68 | } | ||
69 | fn contains(&self, file_id: FileId) -> bool { | 64 | fn contains(&self, file_id: FileId) -> bool { |
70 | self.db.file_set().files.contains(&file_id) | 65 | self.db.file_set().files.contains(&file_id) |
71 | } | 66 | } |
72 | fn lines(&self, file_id: FileId) -> Arc<LineIndex> { | 67 | fn db(&self) -> &db::RootDatabase { |
73 | self.db.file_lines(file_id) | 68 | &self.db |
74 | } | ||
75 | fn syntax(&self, file_id: FileId) -> File { | ||
76 | self.db.file_syntax(file_id) | ||
77 | } | 69 | } |
78 | fn symbols<'a>(&'a self, acc: &mut Vec<Arc<SymbolIndex>>) -> Cancelable<()> { | 70 | fn symbols<'a>(&'a self, acc: &mut Vec<Arc<SymbolIndex>>) -> Cancelable<()> { |
79 | for &file_id in self.db.file_set().files.iter() { | 71 | for &file_id in self.db.file_set().files.iter() { |
@@ -114,17 +106,11 @@ impl ReadonlySourceRoot { | |||
114 | } | 106 | } |
115 | 107 | ||
116 | impl SourceRoot for ReadonlySourceRoot { | 108 | impl SourceRoot for ReadonlySourceRoot { |
117 | fn module_tree(&self) -> Cancelable<Arc<ModuleTree>> { | ||
118 | self.db.module_tree() | ||
119 | } | ||
120 | fn contains(&self, file_id: FileId) -> bool { | 109 | fn contains(&self, file_id: FileId) -> bool { |
121 | self.db.file_set().files.contains(&file_id) | 110 | self.db.file_set().files.contains(&file_id) |
122 | } | 111 | } |
123 | fn lines(&self, file_id: FileId) -> Arc<LineIndex> { | 112 | fn db(&self) -> &db::RootDatabase { |
124 | self.db.file_lines(file_id) | 113 | &self.db |
125 | } | ||
126 | fn syntax(&self, file_id: FileId) -> File { | ||
127 | self.db.file_syntax(file_id) | ||
128 | } | 114 | } |
129 | fn symbols(&self, acc: &mut Vec<Arc<SymbolIndex>>) -> Cancelable<()> { | 115 | fn symbols(&self, acc: &mut Vec<Arc<SymbolIndex>>) -> Cancelable<()> { |
130 | acc.push(Arc::clone(&self.symbol_index)); | 116 | acc.push(Arc::clone(&self.symbol_index)); |