aboutsummaryrefslogtreecommitdiff
path: root/crates/libanalysis
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-09-02 14:36:03 +0100
committerAleksey Kladov <[email protected]>2018-09-02 14:36:03 +0100
commite98d8cd255ab5c2fee873a58af6c2c3ad561dab4 (patch)
tree04869b8fe93e724d8aa266177e48644051331ab9 /crates/libanalysis
parent1329dd4e287c137ec0a90abeec0272275b2b2c8d (diff)
nail down runnables
Diffstat (limited to 'crates/libanalysis')
-rw-r--r--crates/libanalysis/src/imp.rs6
-rw-r--r--crates/libanalysis/src/lib.rs7
-rw-r--r--crates/libanalysis/tests/tests.rs4
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}