From be1a005ebd02298feb8d272278354411d16acdee Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 26 Jan 2019 11:09:39 +0300 Subject: fold syntax database into files database --- crates/ra_db/src/lib.rs | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'crates/ra_db/src') diff --git a/crates/ra_db/src/lib.rs b/crates/ra_db/src/lib.rs index 3a0aa7d24..4bfc3f9ae 100644 --- a/crates/ra_db/src/lib.rs +++ b/crates/ra_db/src/lib.rs @@ -20,7 +20,7 @@ pub use crate::{ loc2id::LocationIntener, }; -pub trait BaseDatabase: salsa::Database + panic::RefUnwindSafe { +pub trait CheckCanceled: salsa::Database + panic::RefUnwindSafe { /// Aborts current query if there are pending changes. /// /// rust-analyzer needs to be able to answer semantic questions about the @@ -64,10 +64,12 @@ pub struct FileRange { } #[salsa::query_group(FilesDatabaseStorage)] -pub trait FilesDatabase: salsa::Database { +pub trait FilesDatabase: salsa::Database + CheckCanceled { /// Text of the file. #[salsa::input] fn file_text(&self, file_id: FileId) -> Arc; + // Parses the file into the syntax tree. + fn source_file(&self, file_id: FileId) -> TreeArc; /// Path to a file, relative to the root of its source root. #[salsa::input] fn file_relative_path(&self, file_id: FileId) -> RelativePathBuf; @@ -102,12 +104,7 @@ fn source_root_crates(db: &impl FilesDatabase, id: SourceRootId) -> Arc TreeArc; -} - -fn source_file(db: &impl SyntaxDatabase, file_id: FileId) -> TreeArc { +fn source_file(db: &impl FilesDatabase, file_id: FileId) -> TreeArc { let text = db.file_text(file_id); SourceFile::parse(&*text) } -- cgit v1.2.3 From 3223de59765cae816099e8684a2caf13bc69bb2e Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 26 Jan 2019 11:17:05 +0300 Subject: move ide queries to ide db --- crates/ra_db/src/lib.rs | 8 -------- 1 file changed, 8 deletions(-) (limited to 'crates/ra_db/src') diff --git a/crates/ra_db/src/lib.rs b/crates/ra_db/src/lib.rs index 4bfc3f9ae..cab47dcac 100644 --- a/crates/ra_db/src/lib.rs +++ b/crates/ra_db/src/lib.rs @@ -80,14 +80,6 @@ pub trait FilesDatabase: salsa::Database + CheckCanceled { #[salsa::input] fn source_root(&self, id: SourceRootId) -> Arc; fn source_root_crates(&self, id: SourceRootId) -> Arc>; - /// The set of "local" (that is, from the current workspace) roots. - /// Files in local roots are assumed to change frequently. - #[salsa::input] - fn local_roots(&self) -> Arc>; - /// The set of roots for crates.io libraries. - /// Files in libraries are assumed to never change. - #[salsa::input] - fn library_roots(&self) -> Arc>; /// The crate graph. #[salsa::input] fn crate_graph(&self) -> Arc; -- cgit v1.2.3 From 4711cbcace33e34d43f880d30c2778c843240f27 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 26 Jan 2019 11:20:30 +0300 Subject: rename FilesDatabase -> SourceDatabase --- crates/ra_db/src/lib.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'crates/ra_db/src') diff --git a/crates/ra_db/src/lib.rs b/crates/ra_db/src/lib.rs index cab47dcac..2664dc69a 100644 --- a/crates/ra_db/src/lib.rs +++ b/crates/ra_db/src/lib.rs @@ -63,8 +63,10 @@ pub struct FileRange { pub range: TextRange, } -#[salsa::query_group(FilesDatabaseStorage)] -pub trait FilesDatabase: salsa::Database + CheckCanceled { +/// Database which stores all significant input facts: source code and project +/// model. Everything else in rust-analyzer is derived from these queries. +#[salsa::query_group(SourceDatabaseStorage)] +pub trait SourceDatabase: salsa::Database + CheckCanceled { /// Text of the file. #[salsa::input] fn file_text(&self, file_id: FileId) -> Arc; @@ -85,7 +87,7 @@ pub trait FilesDatabase: salsa::Database + CheckCanceled { fn crate_graph(&self) -> Arc; } -fn source_root_crates(db: &impl FilesDatabase, id: SourceRootId) -> Arc> { +fn source_root_crates(db: &impl SourceDatabase, id: SourceRootId) -> Arc> { let root = db.source_root(id); let graph = db.crate_graph(); let res = root @@ -96,7 +98,7 @@ fn source_root_crates(db: &impl FilesDatabase, id: SourceRootId) -> Arc TreeArc { +fn source_file(db: &impl SourceDatabase, file_id: FileId) -> TreeArc { let text = db.file_text(file_id); SourceFile::parse(&*text) } -- cgit v1.2.3