From 9a7db8fa009c612168ef16f6ed72315b5406ed09 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 24 Oct 2018 17:25:10 +0300 Subject: simplify roots --- crates/ra_analysis/src/roots.rs | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) (limited to 'crates/ra_analysis/src/roots.rs') 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::{ pub(crate) trait SourceRoot { fn contains(&self, file_id: FileId) -> bool; - fn module_tree(&self) -> Cancelable>; - fn lines(&self, file_id: FileId) -> Arc; - fn syntax(&self, file_id: FileId) -> File; + fn db(&self) -> &db::RootDatabase; fn symbols(&self, acc: &mut Vec>) -> Cancelable<()>; } @@ -63,17 +61,11 @@ impl WritableSourceRoot { } impl SourceRoot for WritableSourceRoot { - fn module_tree(&self) -> Cancelable> { - self.db.module_tree() - } fn contains(&self, file_id: FileId) -> bool { self.db.file_set().files.contains(&file_id) } - fn lines(&self, file_id: FileId) -> Arc { - self.db.file_lines(file_id) - } - fn syntax(&self, file_id: FileId) -> File { - self.db.file_syntax(file_id) + fn db(&self) -> &db::RootDatabase { + &self.db } fn symbols<'a>(&'a self, acc: &mut Vec>) -> Cancelable<()> { for &file_id in self.db.file_set().files.iter() { @@ -114,17 +106,11 @@ impl ReadonlySourceRoot { } impl SourceRoot for ReadonlySourceRoot { - fn module_tree(&self) -> Cancelable> { - self.db.module_tree() - } fn contains(&self, file_id: FileId) -> bool { self.db.file_set().files.contains(&file_id) } - fn lines(&self, file_id: FileId) -> Arc { - self.db.file_lines(file_id) - } - fn syntax(&self, file_id: FileId) -> File { - self.db.file_syntax(file_id) + fn db(&self) -> &db::RootDatabase { + &self.db } fn symbols(&self, acc: &mut Vec>) -> Cancelable<()> { acc.push(Arc::clone(&self.symbol_index)); -- cgit v1.2.3