aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_db
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-01-26 08:09:39 +0000
committerAleksey Kladov <[email protected]>2019-01-26 08:09:39 +0000
commitbe1a005ebd02298feb8d272278354411d16acdee (patch)
treeadfa44d2e47ca780a6125981055c5b47ab202977 /crates/ra_db
parent2f270a51d266f30c03549ce85876c164e0203cd1 (diff)
fold syntax database into files database
Diffstat (limited to 'crates/ra_db')
-rw-r--r--crates/ra_db/src/lib.rs13
1 files changed, 5 insertions, 8 deletions
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::{
20 loc2id::LocationIntener, 20 loc2id::LocationIntener,
21}; 21};
22 22
23pub trait BaseDatabase: salsa::Database + panic::RefUnwindSafe { 23pub trait CheckCanceled: salsa::Database + panic::RefUnwindSafe {
24 /// Aborts current query if there are pending changes. 24 /// Aborts current query if there are pending changes.
25 /// 25 ///
26 /// rust-analyzer needs to be able to answer semantic questions about the 26 /// rust-analyzer needs to be able to answer semantic questions about the
@@ -64,10 +64,12 @@ pub struct FileRange {
64} 64}
65 65
66#[salsa::query_group(FilesDatabaseStorage)] 66#[salsa::query_group(FilesDatabaseStorage)]
67pub trait FilesDatabase: salsa::Database { 67pub trait FilesDatabase: salsa::Database + CheckCanceled {
68 /// Text of the file. 68 /// Text of the file.
69 #[salsa::input] 69 #[salsa::input]
70 fn file_text(&self, file_id: FileId) -> Arc<String>; 70 fn file_text(&self, file_id: FileId) -> Arc<String>;
71 // Parses the file into the syntax tree.
72 fn source_file(&self, file_id: FileId) -> TreeArc<SourceFile>;
71 /// Path to a file, relative to the root of its source root. 73 /// Path to a file, relative to the root of its source root.
72 #[salsa::input] 74 #[salsa::input]
73 fn file_relative_path(&self, file_id: FileId) -> RelativePathBuf; 75 fn file_relative_path(&self, file_id: FileId) -> RelativePathBuf;
@@ -102,12 +104,7 @@ fn source_root_crates(db: &impl FilesDatabase, id: SourceRootId) -> Arc<Vec<Crat
102 Arc::new(res) 104 Arc::new(res)
103} 105}
104 106
105#[salsa::query_group(SyntaxDatabaseStorage)] 107fn source_file(db: &impl FilesDatabase, file_id: FileId) -> TreeArc<SourceFile> {
106pub trait SyntaxDatabase: FilesDatabase + BaseDatabase {
107 fn source_file(&self, file_id: FileId) -> TreeArc<SourceFile>;
108}
109
110fn source_file(db: &impl SyntaxDatabase, file_id: FileId) -> TreeArc<SourceFile> {
111 let text = db.file_text(file_id); 108 let text = db.file_text(file_id);
112 SourceFile::parse(&*text) 109 SourceFile::parse(&*text)
113} 110}