⬆️ salsa

This commit is contained in:
Aleksey Kladov 2019-01-25 23:27:16 +03:00
parent d65dca6bb3
commit 1fd18f020d
10 changed files with 29 additions and 28 deletions

14
Cargo.lock generated
View file

@ -726,7 +726,7 @@ dependencies = [
"ra_syntax 0.1.0", "ra_syntax 0.1.0",
"relative-path 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "relative-path 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"salsa 0.10.0-alpha3 (registry+https://github.com/rust-lang/crates.io-index)", "salsa 0.10.0-alpha4 (registry+https://github.com/rust-lang/crates.io-index)",
"test_utils 0.1.0", "test_utils 0.1.0",
] ]
@ -746,7 +746,6 @@ dependencies = [
"ra_syntax 0.1.0", "ra_syntax 0.1.0",
"relative-path 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "relative-path 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"salsa 0.10.0-alpha3 (registry+https://github.com/rust-lang/crates.io-index)",
"test_utils 0.1.0", "test_utils 0.1.0",
] ]
@ -768,7 +767,6 @@ dependencies = [
"rayon 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "rayon 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
"relative-path 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "relative-path 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"salsa 0.10.0-alpha3 (registry+https://github.com/rust-lang/crates.io-index)",
"test_utils 0.1.0", "test_utils 0.1.0",
"unicase 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "unicase 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
@ -1091,7 +1089,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "salsa" name = "salsa"
version = "0.10.0-alpha3" version = "0.10.0-alpha4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"derive-new 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", "derive-new 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1100,13 +1098,13 @@ dependencies = [
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"salsa-macros 0.10.0-alpha3 (registry+https://github.com/rust-lang/crates.io-index)", "salsa-macros 0.10.0-alpha4 (registry+https://github.com/rust-lang/crates.io-index)",
"smallvec 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]] [[package]]
name = "salsa-macros" name = "salsa-macros"
version = "0.10.0-alpha3" version = "0.10.0-alpha4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1697,8 +1695,8 @@ dependencies = [
"checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a"
"checksum rusty-fork 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9591f190d2852720b679c21f66ad929f9f1d7bb09d1193c26167586029d8489c" "checksum rusty-fork 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9591f190d2852720b679c21f66ad929f9f1d7bb09d1193c26167586029d8489c"
"checksum ryu 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "eb9e9b8cde282a9fe6a42dd4681319bfb63f121b8a8ee9439c6f4107e58a46f7" "checksum ryu 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "eb9e9b8cde282a9fe6a42dd4681319bfb63f121b8a8ee9439c6f4107e58a46f7"
"checksum salsa 0.10.0-alpha3 (registry+https://github.com/rust-lang/crates.io-index)" = "135c0977b23f8a9dc16744dd5495989110e3763ba5ea41e386741c7f8901e285" "checksum salsa 0.10.0-alpha4 (registry+https://github.com/rust-lang/crates.io-index)" = "3f442595eae948da8fbb2aa1e13940d9d2d70031753a27a5d1434f91b706ff12"
"checksum salsa-macros 0.10.0-alpha3 (registry+https://github.com/rust-lang/crates.io-index)" = "c9c93b5efed7281334c4bed8470b278076d1ccd6a60da59a15cd0d57792afff8" "checksum salsa-macros 0.10.0-alpha4 (registry+https://github.com/rust-lang/crates.io-index)" = "2e6c1a1bee4eb44881438e80c1a26db1c3b957b6cc51765615d429019babdec2"
"checksum same-file 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8f20c4be53a8a1ff4c1f1b2bd14570d2f634628709752f0702ecdd2b3f9a5267" "checksum same-file 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8f20c4be53a8a1ff4c1f1b2bd14570d2f634628709752f0702ecdd2b3f9a5267"
"checksum scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27" "checksum scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27"
"checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403"

View file

@ -6,9 +6,10 @@ authors = ["Aleksey Kladov <aleksey.kladov@gmail.com>"]
[dependencies] [dependencies]
relative-path = "0.4.0" relative-path = "0.4.0"
salsa = "0.10.0-alpha3" salsa = "0.10.0-alpha4"
rustc-hash = "1.0" rustc-hash = "1.0"
parking_lot = "0.7.0" parking_lot = "0.7.0"
ra_arena = { path = "../ra_arena" } ra_arena = { path = "../ra_arena" }
ra_syntax = { path = "../ra_syntax" } ra_syntax = { path = "../ra_syntax" }
test_utils = { path = "../test_utils" } test_utils = { path = "../test_utils" }

View file

@ -63,7 +63,7 @@ pub struct FileRange {
pub range: TextRange, pub range: TextRange,
} }
#[salsa::query_group] #[salsa::query_group(FilesDatabaseStorage)]
pub trait FilesDatabase: salsa::Database { pub trait FilesDatabase: salsa::Database {
/// Text of the file. /// Text of the file.
#[salsa::input] #[salsa::input]
@ -102,7 +102,7 @@ fn source_root_crates(db: &impl FilesDatabase, id: SourceRootId) -> Arc<Vec<Crat
Arc::new(res) Arc::new(res)
} }
#[salsa::query_group] #[salsa::query_group(SyntaxDatabaseStorage)]
pub trait SyntaxDatabase: FilesDatabase + BaseDatabase { pub trait SyntaxDatabase: FilesDatabase + BaseDatabase {
fn source_file(&self, file_id: FileId) -> TreeArc<SourceFile>; fn source_file(&self, file_id: FileId) -> TreeArc<SourceFile>;
} }

View file

@ -12,7 +12,6 @@ rustc-hash = "1.0"
parking_lot = "0.7.0" parking_lot = "0.7.0"
ena = "0.11" ena = "0.11"
join_to_string = "0.1.3" join_to_string = "0.1.3"
salsa = "0.10.0-alpha3"
ra_syntax = { path = "../ra_syntax" } ra_syntax = { path = "../ra_syntax" }
ra_arena = { path = "../ra_arena" } ra_arena = { path = "../ra_arena" }

View file

@ -18,7 +18,7 @@ use crate::{
generics::{GenericParams, GenericDef}, generics::{GenericParams, GenericDef},
}; };
#[salsa::query_group] #[salsa::query_group(HirDatabaseStorage)]
pub trait HirDatabase: SyntaxDatabase + AsRef<HirInterner> { pub trait HirDatabase: SyntaxDatabase + AsRef<HirInterner> {
#[salsa::invoke(HirFileId::hir_source_file)] #[salsa::invoke(HirFileId::hir_source_file)]
fn hir_source_file(&self, file_id: HirFileId) -> TreeArc<SourceFile>; fn hir_source_file(&self, file_id: HirFileId) -> TreeArc<SourceFile>;

View file

@ -2,7 +2,7 @@ use std::{sync::Arc, panic};
use parking_lot::Mutex; use parking_lot::Mutex;
use ra_db::{ use ra_db::{
BaseDatabase, FilePosition, FileId, CrateGraph, SourceRoot, SourceRootId, FilesDatabase, BaseDatabase, FilePosition, FileId, CrateGraph, SourceRoot, SourceRootId, FilesDatabase, salsa,
}; };
use relative_path::RelativePathBuf; use relative_path::RelativePathBuf;
use test_utils::{parse_fixture, CURSOR_MARKER, extract_offset}; use test_utils::{parse_fixture, CURSOR_MARKER, extract_offset};
@ -11,7 +11,11 @@ use crate::{db, HirInterner};
pub const WORKSPACE: SourceRootId = SourceRootId(0); pub const WORKSPACE: SourceRootId = SourceRootId(0);
#[salsa::database(ra_db::FilesDatabase, ra_db::SyntaxDatabase, db::HirDatabase)] #[salsa::database(
ra_db::FilesDatabaseStorage,
ra_db::SyntaxDatabaseStorage,
db::HirDatabaseStorage
)]
#[derive(Debug)] #[derive(Debug)]
pub(crate) struct MockDatabase { pub(crate) struct MockDatabase {
events: Mutex<Option<Vec<salsa::Event<MockDatabase>>>>, events: Mutex<Option<Vec<salsa::Event<MockDatabase>>>>,

View file

@ -14,7 +14,6 @@ fst = "0.3.1"
rustc-hash = "1.0" rustc-hash = "1.0"
parking_lot = "0.7.0" parking_lot = "0.7.0"
unicase = "2.2.0" unicase = "2.2.0"
salsa = "0.10.0-alpha3"
ra_syntax = { path = "../ra_syntax" } ra_syntax = { path = "../ra_syntax" }
ra_ide_api_light = { path = "../ra_ide_api_light" } ra_ide_api_light = { path = "../ra_ide_api_light" }

View file

@ -8,11 +8,11 @@ use ra_db::{
use crate::{symbol_index, LineIndex}; use crate::{symbol_index, LineIndex};
#[salsa::database( #[salsa::database(
ra_db::FilesDatabase, ra_db::FilesDatabaseStorage,
ra_db::SyntaxDatabase, ra_db::SyntaxDatabaseStorage,
LineIndexDatabase, LineIndexDatabaseStorage,
symbol_index::SymbolsDatabase, symbol_index::SymbolsDatabaseStorage,
hir::db::HirDatabase hir::db::HirDatabaseStorage
)] )]
#[derive(Debug)] #[derive(Debug)]
pub(crate) struct RootDatabase { pub(crate) struct RootDatabase {
@ -62,7 +62,7 @@ impl AsRef<hir::HirInterner> for RootDatabase {
} }
} }
#[salsa::query_group] #[salsa::query_group(LineIndexDatabaseStorage)]
pub(crate) trait LineIndexDatabase: ra_db::FilesDatabase + BaseDatabase { pub(crate) trait LineIndexDatabase: ra_db::FilesDatabase + BaseDatabase {
fn line_index(&self, file_id: FileId) -> Arc<LineIndex>; fn line_index(&self, file_id: FileId) -> Arc<LineIndex>;
} }

View file

@ -5,7 +5,7 @@ use hir::{
}; };
use ra_db::{ use ra_db::{
FilesDatabase, SourceRoot, SourceRootId, SyntaxDatabase, FilesDatabase, SourceRoot, SourceRootId, SyntaxDatabase,
salsa::Database, salsa::{Database, SweepStrategy},
}; };
use ra_ide_api_light::{self, assists, LocalEdit, Severity}; use ra_ide_api_light::{self, assists, LocalEdit, Severity};
use ra_syntax::{ use ra_syntax::{
@ -77,13 +77,13 @@ impl db::RootDatabase {
/// for some reason. Needs investigation. /// for some reason. Needs investigation.
pub(crate) fn collect_garbage(&mut self) { pub(crate) fn collect_garbage(&mut self) {
self.query(ra_db::SourceFileQuery) self.query(ra_db::SourceFileQuery)
.sweep(salsa::SweepStrategy::default().discard_values()); .sweep(SweepStrategy::default().discard_values());
self.query(hir::db::HirSourceFileQuery) self.query(hir::db::HirSourceFileQuery)
.sweep(salsa::SweepStrategy::default().discard_values()); .sweep(SweepStrategy::default().discard_values());
self.query(hir::db::FileItemsQuery) self.query(hir::db::FileItemsQuery)
.sweep(salsa::SweepStrategy::default().discard_values()); .sweep(SweepStrategy::default().discard_values());
self.query(hir::db::FileItemQuery) self.query(hir::db::FileItemQuery)
.sweep(salsa::SweepStrategy::default().discard_values()); .sweep(SweepStrategy::default().discard_values());
} }
} }

View file

@ -44,7 +44,7 @@ use crate::{
db::RootDatabase, db::RootDatabase,
}; };
#[salsa::query_group] #[salsa::query_group(SymbolsDatabaseStorage)]
pub(crate) trait SymbolsDatabase: hir::db::HirDatabase { pub(crate) trait SymbolsDatabase: hir::db::HirDatabase {
fn file_symbols(&self, file_id: FileId) -> Arc<SymbolIndex>; fn file_symbols(&self, file_id: FileId) -> Arc<SymbolIndex>;
#[salsa::input] #[salsa::input]