From e98d8cd255ab5c2fee873a58af6c2c3ad561dab4 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 2 Sep 2018 16:36:03 +0300 Subject: nail down runnables --- crates/libanalysis/src/imp.rs | 6 ++++-- crates/libanalysis/src/lib.rs | 7 +++++-- crates/libanalysis/tests/tests.rs | 4 ++-- 3 files changed, 11 insertions(+), 6 deletions(-) (limited to 'crates/libanalysis') 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 { .collect() } - pub fn crate_root(&self, id: FileId) -> Vec { + pub fn crate_for(&self, id: FileId) -> Vec { let module_map = &self.data.module_map; let crate_graph = &self.data.crate_graph; let mut res = Vec::new(); @@ -177,7 +177,9 @@ impl AnalysisImpl { } res } - + pub fn crate_root(&self, crate_id: CrateId) -> FileId { + self.data.crate_graph.crate_roots[&crate_id] + } pub fn approximately_resolve_symbol( &self, 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 { pub fn parent_module(&self, file_id: FileId) -> Vec<(FileId, FileSymbol)> { self.imp.parent_module(file_id) } - pub fn crate_root(&self, file_id: FileId) -> Vec { - self.imp.crate_root(file_id) + pub fn crate_for(&self, file_id: FileId) -> Vec { + self.imp.crate_for(file_id) + } + pub fn crate_root(&self, crate_id: CrateId) -> FileId { + self.imp.crate_root(crate_id) } pub fn runnables(&self, file_id: FileId) -> Vec { 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() { (1, "/lib.rs"), (2, "/foo.rs"), ])); - assert!(snap.crate_root(FileId(2)).is_empty()); + assert!(snap.crate_for(FileId(2)).is_empty()); let crate_graph = CrateGraph { crate_roots: { @@ -142,7 +142,7 @@ fn test_resolve_crate_root() { (2, "/foo.rs"), ])); assert_eq!( - snap.crate_root(FileId(2)), + snap.crate_for(FileId(2)), vec![CrateId(1)], ); } -- cgit v1.2.3