From a2ca03d10b093ea20d7db8bfd78aa1e787482cc0 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 17 Jan 2019 14:11:00 +0300 Subject: :arrow_up: salsa --- crates/ra_db/Cargo.toml | 2 +- crates/ra_db/src/input.rs | 65 ++++++++++++++++++----------------------------- crates/ra_db/src/lib.rs | 10 +++----- 3 files changed, 30 insertions(+), 47 deletions(-) (limited to 'crates/ra_db') diff --git a/crates/ra_db/Cargo.toml b/crates/ra_db/Cargo.toml index 21d987688..bb1b5eae7 100644 --- a/crates/ra_db/Cargo.toml +++ b/crates/ra_db/Cargo.toml @@ -6,7 +6,7 @@ authors = ["Aleksey Kladov "] [dependencies] relative-path = "0.4.0" -salsa = "0.9.2" +salsa = "0.10.0-alpha1" rustc-hash = "1.0" parking_lot = "0.7.0" ra_arena = { path = "../ra_arena" } diff --git a/crates/ra_db/src/input.rs b/crates/ra_db/src/input.rs index 2b761ea0c..b5d63e820 100644 --- a/crates/ra_db/src/input.rs +++ b/crates/ra_db/src/input.rs @@ -146,46 +146,31 @@ impl CrateGraph { } } -salsa::query_group! { - pub trait FilesDatabase: salsa::Database { - /// Text of the file. - fn file_text(file_id: FileId) -> Arc { - type FileTextQuery; - storage input; - } - /// Path to a file, relative to the root of its source root. - fn file_relative_path(file_id: FileId) -> RelativePathBuf { - type FileRelativePathQuery; - storage input; - } - /// Source root of the file. - fn file_source_root(file_id: FileId) -> SourceRootId { - type FileSourceRootQuery; - storage input; - } - /// Contents of the source root. - fn source_root(id: SourceRootId) -> Arc { - type SourceRootQuery; - storage input; - } - /// The set of "local" (that is, from the current workspace) roots. - /// Files in local roots are assumed to change frequently. - fn local_roots() -> Arc> { - type LocalRootsQuery; - storage input; - } - /// The set of roots for crates.io libraries. - /// Files in libraries are assumed to never change. - fn library_roots() -> Arc> { - type LibraryRootsQuery; - storage input; - } - /// The crate graph. - fn crate_graph() -> Arc { - type CrateGraphQuery; - storage input; - } - } +#[salsa::query_group] +pub trait FilesDatabase: salsa::Database { + /// Text of the file. + #[salsa::input] + fn file_text(&self, file_id: FileId) -> Arc; + /// Path to a file, relative to the root of its source root. + #[salsa::input] + fn file_relative_path(&self, file_id: FileId) -> RelativePathBuf; + /// Source root of the file. + #[salsa::input] + fn file_source_root(&self, file_id: FileId) -> SourceRootId; + /// Contents of the source root. + #[salsa::input] + fn source_root(&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; } #[cfg(test)] diff --git a/crates/ra_db/src/lib.rs b/crates/ra_db/src/lib.rs index 89113e7a6..dbeb9ec71 100644 --- a/crates/ra_db/src/lib.rs +++ b/crates/ra_db/src/lib.rs @@ -9,6 +9,7 @@ use std::panic; use ra_syntax::{TextUnit, TextRange, SourceFile, TreeArc}; +pub use ::salsa as salsa; pub use crate::{ cancellation::Canceled, syntax_ptr::LocalSyntaxPtr, @@ -51,12 +52,9 @@ pub trait BaseDatabase: salsa::Database + panic::RefUnwindSafe { } } -salsa::query_group! { - pub trait SyntaxDatabase: crate::input::FilesDatabase + BaseDatabase { - fn source_file(file_id: FileId) -> TreeArc { - type SourceFileQuery; - } - } +#[salsa::query_group] +pub trait SyntaxDatabase: crate::input::FilesDatabase + BaseDatabase { + fn source_file(&self, file_id: FileId) -> TreeArc; } fn source_file(db: &impl SyntaxDatabase, file_id: FileId) -> TreeArc { -- cgit v1.2.3