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 +++++-- 2 files changed, 9 insertions(+), 4 deletions(-) (limited to 'crates/libanalysis/src') 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); -- cgit v1.2.3