aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_api
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-01-17 11:11:00 +0000
committerAleksey Kladov <[email protected]>2019-01-17 11:11:00 +0000
commita2ca03d10b093ea20d7db8bfd78aa1e787482cc0 (patch)
tree0723f5b15899902811d027587a46698016d21d54 /crates/ra_ide_api
parent454cc313589fb17de92d6f3dbf576a5ea5f4adf2 (diff)
:arrow_up: salsa
Diffstat (limited to 'crates/ra_ide_api')
-rw-r--r--crates/ra_ide_api/Cargo.toml1
-rw-r--r--crates/ra_ide_api/src/db.rs19
-rw-r--r--crates/ra_ide_api/src/imp.rs9
-rw-r--r--crates/ra_ide_api/src/lib.rs6
-rw-r--r--crates/ra_ide_api/src/symbol_index.rs21
5 files changed, 27 insertions, 29 deletions
diff --git a/crates/ra_ide_api/Cargo.toml b/crates/ra_ide_api/Cargo.toml
index 022cbd5a3..702c11932 100644
--- a/crates/ra_ide_api/Cargo.toml
+++ b/crates/ra_ide_api/Cargo.toml
@@ -10,7 +10,6 @@ log = "0.4.5"
10relative-path = "0.4.0" 10relative-path = "0.4.0"
11rayon = "1.0.2" 11rayon = "1.0.2"
12fst = "0.3.1" 12fst = "0.3.1"
13salsa = "0.9.2"
14rustc-hash = "1.0" 13rustc-hash = "1.0"
15parking_lot = "0.7.0" 14parking_lot = "0.7.0"
16unicase = "2.2.0" 15unicase = "2.2.0"
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 @@
1use std::{fmt, sync::Arc}; 1use std::{fmt, sync::Arc};
2 2
3use salsa::{self, Database}; 3use ra_db::{
4use ra_db::{LocationIntener, BaseDatabase, FileId, Canceled}; 4 LocationIntener, BaseDatabase, FileId, Canceled,
5 salsa::{self, Database},
6};
5 7
6use crate::{symbol_index, LineIndex}; 8use crate::{symbol_index, LineIndex};
7 9
@@ -73,12 +75,9 @@ impl AsRef<LocationIntener<hir::MacroCallLoc, hir::MacroCallId>> for RootDatabas
73 } 75 }
74} 76}
75 77
76salsa::query_group! { 78#[salsa::query_group]
77 pub(crate) trait LineIndexDatabase: ra_db::FilesDatabase + BaseDatabase { 79pub(crate) trait LineIndexDatabase: ra_db::FilesDatabase + BaseDatabase {
78 fn line_index(file_id: FileId) -> Arc<LineIndex> { 80 fn line_index(&self, file_id: FileId) -> Arc<LineIndex>;
79 type LineIndexQuery;
80 }
81 }
82} 81}
83 82
84fn line_index(db: &impl ra_db::FilesDatabase, file_id: FileId) -> Arc<LineIndex> { 83fn line_index(db: &impl ra_db::FilesDatabase, file_id: FileId) -> Arc<LineIndex> {
@@ -109,10 +108,10 @@ salsa::database_storage! {
109 } 108 }
110 impl hir::db::HirDatabase { 109 impl hir::db::HirDatabase {
111 fn hir_source_file() for hir::db::HirSourceFileQuery; 110 fn hir_source_file() for hir::db::HirSourceFileQuery;
112 fn expand_macro_invocation() for hir::db::ExpandMacroCallQuery; 111 fn expand_macro_invocation() for hir::db::ExpandMacroInvocationQuery;
113 fn module_tree() for hir::db::ModuleTreeQuery; 112 fn module_tree() for hir::db::ModuleTreeQuery;
114 fn fn_scopes() for hir::db::FnScopesQuery; 113 fn fn_scopes() for hir::db::FnScopesQuery;
115 fn file_items() for hir::db::SourceFileItemsQuery; 114 fn file_items() for hir::db::FileItemsQuery;
116 fn file_item() for hir::db::FileItemQuery; 115 fn file_item() for hir::db::FileItemQuery;
117 fn input_module_items() for hir::db::InputModuleItemsQuery; 116 fn input_module_items() for hir::db::InputModuleItemsQuery;
118 fn item_map() for hir::db::ItemMapQuery; 117 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 @@
1use std::sync::Arc; 1use std::sync::Arc;
2 2
3use salsa::Database;
4
5use hir::{ 3use hir::{
6 self, Problem, source_binder, 4 self, Problem, source_binder,
7}; 5};
8use ra_db::{FilesDatabase, SourceRoot, SourceRootId, SyntaxDatabase}; 6use ra_db::{
7 FilesDatabase, SourceRoot, SourceRootId, SyntaxDatabase,
8 salsa::{self, Database},
9};
9use ra_ide_api_light::{self, assists, LocalEdit, Severity}; 10use ra_ide_api_light::{self, assists, LocalEdit, Severity};
10use ra_syntax::{ 11use ra_syntax::{
11 TextRange, AstNode, SourceFile, 12 TextRange, AstNode, SourceFile,
@@ -89,7 +90,7 @@ impl db::RootDatabase {
89 fn gc_syntax_trees(&mut self) { 90 fn gc_syntax_trees(&mut self) {
90 self.query(ra_db::SourceFileQuery) 91 self.query(ra_db::SourceFileQuery)
91 .sweep(salsa::SweepStrategy::default().discard_values()); 92 .sweep(salsa::SweepStrategy::default().discard_values());
92 self.query(hir::db::SourceFileItemsQuery) 93 self.query(hir::db::FileItemsQuery)
93 .sweep(salsa::SweepStrategy::default().discard_values()); 94 .sweep(salsa::SweepStrategy::default().discard_values());
94 self.query(hir::db::FileItemQuery) 95 self.query(hir::db::FileItemQuery)
95 .sweep(salsa::SweepStrategy::default().discard_values()); 96 .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};
28 28
29use ra_syntax::{SourceFile, TreeArc, TextRange, TextUnit}; 29use ra_syntax::{SourceFile, TreeArc, TextRange, TextUnit};
30use ra_text_edit::TextEdit; 30use ra_text_edit::TextEdit;
31use ra_db::{SyntaxDatabase, FilesDatabase, BaseDatabase}; 31use ra_db::{
32 SyntaxDatabase, FilesDatabase, BaseDatabase,
33 salsa::{self, ParallelDatabase},
34};
32use rayon::prelude::*; 35use rayon::prelude::*;
33use relative_path::RelativePathBuf; 36use relative_path::RelativePathBuf;
34use rustc_hash::FxHashMap; 37use rustc_hash::FxHashMap;
35use salsa::ParallelDatabase;
36 38
37use crate::{ 39use crate::{
38 symbol_index::{FileSymbol, SymbolIndex}, 40 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::{
32 SyntaxKind::{self, *}, 32 SyntaxKind::{self, *},
33 ast::{self, NameOwner}, 33 ast::{self, NameOwner},
34}; 34};
35use ra_db::{SourceRootId, FilesDatabase, LocalSyntaxPtr}; 35use ra_db::{
36use salsa::ParallelDatabase; 36 SourceRootId, FilesDatabase, LocalSyntaxPtr,
37 salsa::{self, ParallelDatabase},
38};
37use rayon::prelude::*; 39use rayon::prelude::*;
38 40
39use crate::{ 41use crate::{
@@ -41,16 +43,11 @@ use crate::{
41 db::RootDatabase, 43 db::RootDatabase,
42}; 44};
43 45
44salsa::query_group! { 46#[salsa::query_group]
45 pub(crate) trait SymbolsDatabase: hir::db::HirDatabase { 47pub(crate) trait SymbolsDatabase: hir::db::HirDatabase {
46 fn file_symbols(file_id: FileId) -> Arc<SymbolIndex> { 48 fn file_symbols(&self, file_id: FileId) -> Arc<SymbolIndex>;
47 type FileSymbolsQuery; 49 #[salsa::input]
48 } 50 fn library_symbols(&self, id: SourceRootId) -> Arc<SymbolIndex>;
49 fn library_symbols(id: SourceRootId) -> Arc<SymbolIndex> {
50 type LibrarySymbolsQuery;
51 storage input;
52 }
53 }
54} 51}
55 52
56fn file_symbols(db: &impl SymbolsDatabase, file_id: FileId) -> Arc<SymbolIndex> { 53fn file_symbols(db: &impl SymbolsDatabase, file_id: FileId) -> Arc<SymbolIndex> {