diff options
author | Aleksey Kladov <[email protected]> | 2019-01-26 08:09:39 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-01-26 08:09:39 +0000 |
commit | be1a005ebd02298feb8d272278354411d16acdee (patch) | |
tree | adfa44d2e47ca780a6125981055c5b47ab202977 /crates/ra_db | |
parent | 2f270a51d266f30c03549ce85876c164e0203cd1 (diff) |
fold syntax database into files database
Diffstat (limited to 'crates/ra_db')
-rw-r--r-- | crates/ra_db/src/lib.rs | 13 |
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 | ||
23 | pub trait BaseDatabase: salsa::Database + panic::RefUnwindSafe { | 23 | pub 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)] |
67 | pub trait FilesDatabase: salsa::Database { | 67 | pub 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)] | 107 | fn source_file(db: &impl FilesDatabase, file_id: FileId) -> TreeArc<SourceFile> { |
106 | pub trait SyntaxDatabase: FilesDatabase + BaseDatabase { | ||
107 | fn source_file(&self, file_id: FileId) -> TreeArc<SourceFile>; | ||
108 | } | ||
109 | |||
110 | fn 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 | } |