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_ide_api/src/db.rs | 19 +++++++++---------- crates/ra_ide_api/src/imp.rs | 9 +++++---- crates/ra_ide_api/src/lib.rs | 6 ++++-- crates/ra_ide_api/src/symbol_index.rs | 21 +++++++++------------ 4 files changed, 27 insertions(+), 28 deletions(-) (limited to 'crates/ra_ide_api/src') diff --git a/crates/ra_ide_api/src/db.rs b/crates/ra_ide_api/src/db.rs index 60f84675d..36778b955 100644 --- a/crates/ra_ide_api/src/db.rs +++ b/crates/ra_ide_api/src/db.rs @@ -1,7 +1,9 @@ use std::{fmt, sync::Arc}; -use salsa::{self, Database}; -use ra_db::{LocationIntener, BaseDatabase, FileId, Canceled}; +use ra_db::{ + LocationIntener, BaseDatabase, FileId, Canceled, + salsa::{self, Database}, +}; use crate::{symbol_index, LineIndex}; @@ -73,12 +75,9 @@ impl AsRef> for RootDatabas } } -salsa::query_group! { - pub(crate) trait LineIndexDatabase: ra_db::FilesDatabase + BaseDatabase { - fn line_index(file_id: FileId) -> Arc { - type LineIndexQuery; - } - } +#[salsa::query_group] +pub(crate) trait LineIndexDatabase: ra_db::FilesDatabase + BaseDatabase { + fn line_index(&self, file_id: FileId) -> Arc; } fn line_index(db: &impl ra_db::FilesDatabase, file_id: FileId) -> Arc { @@ -109,10 +108,10 @@ salsa::database_storage! { } impl hir::db::HirDatabase { fn hir_source_file() for hir::db::HirSourceFileQuery; - fn expand_macro_invocation() for hir::db::ExpandMacroCallQuery; + fn expand_macro_invocation() for hir::db::ExpandMacroInvocationQuery; fn module_tree() for hir::db::ModuleTreeQuery; fn fn_scopes() for hir::db::FnScopesQuery; - fn file_items() for hir::db::SourceFileItemsQuery; + fn file_items() for hir::db::FileItemsQuery; fn file_item() for hir::db::FileItemQuery; fn input_module_items() for hir::db::InputModuleItemsQuery; fn item_map() for hir::db::ItemMapQuery; diff --git a/crates/ra_ide_api/src/imp.rs b/crates/ra_ide_api/src/imp.rs index 61771ed40..28e497965 100644 --- a/crates/ra_ide_api/src/imp.rs +++ b/crates/ra_ide_api/src/imp.rs @@ -1,11 +1,12 @@ use std::sync::Arc; -use salsa::Database; - use hir::{ self, Problem, source_binder, }; -use ra_db::{FilesDatabase, SourceRoot, SourceRootId, SyntaxDatabase}; +use ra_db::{ + FilesDatabase, SourceRoot, SourceRootId, SyntaxDatabase, + salsa::{self, Database}, +}; use ra_ide_api_light::{self, assists, LocalEdit, Severity}; use ra_syntax::{ TextRange, AstNode, SourceFile, @@ -89,7 +90,7 @@ impl db::RootDatabase { fn gc_syntax_trees(&mut self) { self.query(ra_db::SourceFileQuery) .sweep(salsa::SweepStrategy::default().discard_values()); - self.query(hir::db::SourceFileItemsQuery) + self.query(hir::db::FileItemsQuery) .sweep(salsa::SweepStrategy::default().discard_values()); self.query(hir::db::FileItemQuery) .sweep(salsa::SweepStrategy::default().discard_values()); diff --git a/crates/ra_ide_api/src/lib.rs b/crates/ra_ide_api/src/lib.rs index 3a0d2dbbe..7b47d7b6d 100644 --- a/crates/ra_ide_api/src/lib.rs +++ b/crates/ra_ide_api/src/lib.rs @@ -28,11 +28,13 @@ use std::{fmt, sync::Arc}; use ra_syntax::{SourceFile, TreeArc, TextRange, TextUnit}; use ra_text_edit::TextEdit; -use ra_db::{SyntaxDatabase, FilesDatabase, BaseDatabase}; +use ra_db::{ + SyntaxDatabase, FilesDatabase, BaseDatabase, + salsa::{self, ParallelDatabase}, +}; use rayon::prelude::*; use relative_path::RelativePathBuf; use rustc_hash::FxHashMap; -use salsa::ParallelDatabase; use crate::{ symbol_index::{FileSymbol, SymbolIndex}, diff --git a/crates/ra_ide_api/src/symbol_index.rs b/crates/ra_ide_api/src/symbol_index.rs index 74165d68f..bfa2f3469 100644 --- a/crates/ra_ide_api/src/symbol_index.rs +++ b/crates/ra_ide_api/src/symbol_index.rs @@ -32,8 +32,10 @@ use ra_syntax::{ SyntaxKind::{self, *}, ast::{self, NameOwner}, }; -use ra_db::{SourceRootId, FilesDatabase, LocalSyntaxPtr}; -use salsa::ParallelDatabase; +use ra_db::{ + SourceRootId, FilesDatabase, LocalSyntaxPtr, + salsa::{self, ParallelDatabase}, +}; use rayon::prelude::*; use crate::{ @@ -41,16 +43,11 @@ use crate::{ db::RootDatabase, }; -salsa::query_group! { - pub(crate) trait SymbolsDatabase: hir::db::HirDatabase { - fn file_symbols(file_id: FileId) -> Arc { - type FileSymbolsQuery; - } - fn library_symbols(id: SourceRootId) -> Arc { - type LibrarySymbolsQuery; - storage input; - } - } +#[salsa::query_group] +pub(crate) trait SymbolsDatabase: hir::db::HirDatabase { + fn file_symbols(&self, file_id: FileId) -> Arc; + #[salsa::input] + fn library_symbols(&self, id: SourceRootId) -> Arc; } fn file_symbols(db: &impl SymbolsDatabase, file_id: FileId) -> Arc { -- cgit v1.2.3