diff options
Diffstat (limited to 'crates/libanalysis')
-rw-r--r-- | crates/libanalysis/src/imp.rs | 6 | ||||
-rw-r--r-- | crates/libanalysis/src/lib.rs | 7 | ||||
-rw-r--r-- | crates/libanalysis/tests/tests.rs | 4 |
3 files changed, 11 insertions, 6 deletions
diff --git a/crates/libanalysis/src/imp.rs b/crates/libanalysis/src/imp.rs index f1d72da15..b80ce1ab5 100644 --- a/crates/libanalysis/src/imp.rs +++ b/crates/libanalysis/src/imp.rs | |||
@@ -151,7 +151,7 @@ impl AnalysisImpl { | |||
151 | .collect() | 151 | .collect() |
152 | } | 152 | } |
153 | 153 | ||
154 | pub fn crate_root(&self, id: FileId) -> Vec<CrateId> { | 154 | pub fn crate_for(&self, id: FileId) -> Vec<CrateId> { |
155 | let module_map = &self.data.module_map; | 155 | let module_map = &self.data.module_map; |
156 | let crate_graph = &self.data.crate_graph; | 156 | let crate_graph = &self.data.crate_graph; |
157 | let mut res = Vec::new(); | 157 | let mut res = Vec::new(); |
@@ -177,7 +177,9 @@ impl AnalysisImpl { | |||
177 | } | 177 | } |
178 | res | 178 | res |
179 | } | 179 | } |
180 | 180 | pub fn crate_root(&self, crate_id: CrateId) -> FileId { | |
181 | self.data.crate_graph.crate_roots[&crate_id] | ||
182 | } | ||
181 | pub fn approximately_resolve_symbol( | 183 | pub fn approximately_resolve_symbol( |
182 | &self, | 184 | &self, |
183 | id: FileId, | 185 | id: FileId, |
diff --git a/crates/libanalysis/src/lib.rs b/crates/libanalysis/src/lib.rs index 041abbb89..ba290f1e0 100644 --- a/crates/libanalysis/src/lib.rs +++ b/crates/libanalysis/src/lib.rs | |||
@@ -182,8 +182,11 @@ impl Analysis { | |||
182 | pub fn parent_module(&self, file_id: FileId) -> Vec<(FileId, FileSymbol)> { | 182 | pub fn parent_module(&self, file_id: FileId) -> Vec<(FileId, FileSymbol)> { |
183 | self.imp.parent_module(file_id) | 183 | self.imp.parent_module(file_id) |
184 | } | 184 | } |
185 | pub fn crate_root(&self, file_id: FileId) -> Vec<CrateId> { | 185 | pub fn crate_for(&self, file_id: FileId) -> Vec<CrateId> { |
186 | self.imp.crate_root(file_id) | 186 | self.imp.crate_for(file_id) |
187 | } | ||
188 | pub fn crate_root(&self, crate_id: CrateId) -> FileId { | ||
189 | self.imp.crate_root(crate_id) | ||
187 | } | 190 | } |
188 | pub fn runnables(&self, file_id: FileId) -> Vec<Runnable> { | 191 | pub fn runnables(&self, file_id: FileId) -> Vec<Runnable> { |
189 | let file = self.file_syntax(file_id); | 192 | let file = self.file_syntax(file_id); |
diff --git a/crates/libanalysis/tests/tests.rs b/crates/libanalysis/tests/tests.rs index c098c8e8c..4fae7c313 100644 --- a/crates/libanalysis/tests/tests.rs +++ b/crates/libanalysis/tests/tests.rs | |||
@@ -126,7 +126,7 @@ fn test_resolve_crate_root() { | |||
126 | (1, "/lib.rs"), | 126 | (1, "/lib.rs"), |
127 | (2, "/foo.rs"), | 127 | (2, "/foo.rs"), |
128 | ])); | 128 | ])); |
129 | assert!(snap.crate_root(FileId(2)).is_empty()); | 129 | assert!(snap.crate_for(FileId(2)).is_empty()); |
130 | 130 | ||
131 | let crate_graph = CrateGraph { | 131 | let crate_graph = CrateGraph { |
132 | crate_roots: { | 132 | crate_roots: { |
@@ -142,7 +142,7 @@ fn test_resolve_crate_root() { | |||
142 | (2, "/foo.rs"), | 142 | (2, "/foo.rs"), |
143 | ])); | 143 | ])); |
144 | assert_eq!( | 144 | assert_eq!( |
145 | snap.crate_root(FileId(2)), | 145 | snap.crate_for(FileId(2)), |
146 | vec![CrateId(1)], | 146 | vec![CrateId(1)], |
147 | ); | 147 | ); |
148 | } | 148 | } |