diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-01-25 12:34:10 +0000 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-01-25 12:34:10 +0000 |
commit | 021e691997efc35c983808ee3470a060a3ec3e96 (patch) | |
tree | a3f49352542d3c6803e318cd2f155cc4543062c5 /crates/ra_ide_api/src | |
parent | 04ce89313369a1606b057b3be1368d72b8a5cd63 (diff) | |
parent | 08c12e424d5d3fb4e11f081a07b9c265dc7a96b6 (diff) |
Merge #639
639: Update salsa r=matklad a=matklad
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_ide_api/src')
-rw-r--r-- | crates/ra_ide_api/src/db.rs | 56 | ||||
-rw-r--r-- | crates/ra_ide_api/src/imp.rs | 39 | ||||
-rw-r--r-- | crates/ra_ide_api/src/status.rs | 2 |
3 files changed, 22 insertions, 75 deletions
diff --git a/crates/ra_ide_api/src/db.rs b/crates/ra_ide_api/src/db.rs index 11305613c..f0190ae51 100644 --- a/crates/ra_ide_api/src/db.rs +++ b/crates/ra_ide_api/src/db.rs | |||
@@ -7,6 +7,13 @@ use ra_db::{ | |||
7 | 7 | ||
8 | use crate::{symbol_index, LineIndex}; | 8 | use crate::{symbol_index, LineIndex}; |
9 | 9 | ||
10 | #[salsa::database( | ||
11 | ra_db::FilesDatabase, | ||
12 | ra_db::SyntaxDatabase, | ||
13 | LineIndexDatabase, | ||
14 | symbol_index::SymbolsDatabase, | ||
15 | hir::db::HirDatabase | ||
16 | )] | ||
10 | #[derive(Debug)] | 17 | #[derive(Debug)] |
11 | pub(crate) struct RootDatabase { | 18 | pub(crate) struct RootDatabase { |
12 | runtime: salsa::Runtime<RootDatabase>, | 19 | runtime: salsa::Runtime<RootDatabase>, |
@@ -64,52 +71,3 @@ fn line_index(db: &impl ra_db::FilesDatabase, file_id: FileId) -> Arc<LineIndex> | |||
64 | let text = db.file_text(file_id); | 71 | let text = db.file_text(file_id); |
65 | Arc::new(LineIndex::new(&*text)) | 72 | Arc::new(LineIndex::new(&*text)) |
66 | } | 73 | } |
67 | |||
68 | salsa::database_storage! { | ||
69 | pub(crate) struct RootDatabaseStorage for RootDatabase { | ||
70 | impl ra_db::FilesDatabase { | ||
71 | fn file_text() for ra_db::FileTextQuery; | ||
72 | fn file_relative_path() for ra_db::FileRelativePathQuery; | ||
73 | fn file_source_root() for ra_db::FileSourceRootQuery; | ||
74 | fn source_root() for ra_db::SourceRootQuery; | ||
75 | fn source_root_crates() for ra_db::SourceRootCratesQuery; | ||
76 | fn local_roots() for ra_db::LocalRootsQuery; | ||
77 | fn library_roots() for ra_db::LibraryRootsQuery; | ||
78 | fn crate_graph() for ra_db::CrateGraphQuery; | ||
79 | } | ||
80 | impl ra_db::SyntaxDatabase { | ||
81 | fn source_file() for ra_db::SourceFileQuery; | ||
82 | } | ||
83 | impl LineIndexDatabase { | ||
84 | fn line_index() for LineIndexQuery; | ||
85 | } | ||
86 | impl symbol_index::SymbolsDatabase { | ||
87 | fn file_symbols() for symbol_index::FileSymbolsQuery; | ||
88 | fn library_symbols() for symbol_index::LibrarySymbolsQuery; | ||
89 | } | ||
90 | impl hir::db::HirDatabase { | ||
91 | fn hir_source_file() for hir::db::HirSourceFileQuery; | ||
92 | fn expand_macro_invocation() for hir::db::ExpandMacroInvocationQuery; | ||
93 | fn module_tree() for hir::db::ModuleTreeQuery; | ||
94 | fn fn_scopes() for hir::db::FnScopesQuery; | ||
95 | fn file_items() for hir::db::FileItemsQuery; | ||
96 | fn file_item() for hir::db::FileItemQuery; | ||
97 | fn lower_module() for hir::db::LowerModuleQuery; | ||
98 | fn lower_module_module() for hir::db::LowerModuleModuleQuery; | ||
99 | fn lower_module_source_map() for hir::db::LowerModuleSourceMapQuery; | ||
100 | fn item_map() for hir::db::ItemMapQuery; | ||
101 | fn submodules() for hir::db::SubmodulesQuery; | ||
102 | fn infer() for hir::db::InferQuery; | ||
103 | fn type_for_def() for hir::db::TypeForDefQuery; | ||
104 | fn type_for_field() for hir::db::TypeForFieldQuery; | ||
105 | fn struct_data() for hir::db::StructDataQuery; | ||
106 | fn enum_data() for hir::db::EnumDataQuery; | ||
107 | fn impls_in_module() for hir::db::ImplsInModuleQuery; | ||
108 | fn impls_in_crate() for hir::db::ImplsInCrateQuery; | ||
109 | fn body_hir() for hir::db::BodyHirQuery; | ||
110 | fn body_syntax_mapping() for hir::db::BodySyntaxMappingQuery; | ||
111 | fn fn_signature() for hir::db::FnSignatureQuery; | ||
112 | fn generic_params() for hir::db::GenericParamsQuery; | ||
113 | } | ||
114 | } | ||
115 | } | ||
diff --git a/crates/ra_ide_api/src/imp.rs b/crates/ra_ide_api/src/imp.rs index ddd9354ec..8ecb8b17c 100644 --- a/crates/ra_ide_api/src/imp.rs +++ b/crates/ra_ide_api/src/imp.rs | |||
@@ -5,7 +5,7 @@ use hir::{ | |||
5 | }; | 5 | }; |
6 | use ra_db::{ | 6 | use ra_db::{ |
7 | FilesDatabase, SourceRoot, SourceRootId, SyntaxDatabase, | 7 | FilesDatabase, SourceRoot, SourceRootId, SyntaxDatabase, |
8 | salsa::{self, Database}, | 8 | salsa::Database, |
9 | }; | 9 | }; |
10 | use ra_ide_api_light::{self, assists, LocalEdit, Severity}; | 10 | use ra_ide_api_light::{self, assists, LocalEdit, Severity}; |
11 | use ra_syntax::{ | 11 | use ra_syntax::{ |
@@ -18,7 +18,7 @@ use crate::{ | |||
18 | AnalysisChange, | 18 | AnalysisChange, |
19 | CrateId, db, Diagnostic, FileId, FilePosition, FileRange, FileSystemEdit, | 19 | CrateId, db, Diagnostic, FileId, FilePosition, FileRange, FileSystemEdit, |
20 | Query, RootChange, SourceChange, SourceFileEdit, | 20 | Query, RootChange, SourceChange, SourceFileEdit, |
21 | symbol_index::{FileSymbol, LibrarySymbolsQuery}, | 21 | symbol_index::{FileSymbol, SymbolsDatabase}, |
22 | }; | 22 | }; |
23 | 23 | ||
24 | impl db::RootDatabase { | 24 | impl db::RootDatabase { |
@@ -28,59 +28,48 @@ impl db::RootDatabase { | |||
28 | if !change.new_roots.is_empty() { | 28 | if !change.new_roots.is_empty() { |
29 | let mut local_roots = Vec::clone(&self.local_roots()); | 29 | let mut local_roots = Vec::clone(&self.local_roots()); |
30 | for (root_id, is_local) in change.new_roots { | 30 | for (root_id, is_local) in change.new_roots { |
31 | self.query_mut(ra_db::SourceRootQuery) | 31 | self.set_source_root(root_id, Default::default()); |
32 | .set(root_id, Default::default()); | ||
33 | if is_local { | 32 | if is_local { |
34 | local_roots.push(root_id); | 33 | local_roots.push(root_id); |
35 | } | 34 | } |
36 | } | 35 | } |
37 | self.query_mut(ra_db::LocalRootsQuery) | 36 | self.set_local_roots(Arc::new(local_roots)); |
38 | .set((), Arc::new(local_roots)); | ||
39 | } | 37 | } |
40 | 38 | ||
41 | for (root_id, root_change) in change.roots_changed { | 39 | for (root_id, root_change) in change.roots_changed { |
42 | self.apply_root_change(root_id, root_change); | 40 | self.apply_root_change(root_id, root_change); |
43 | } | 41 | } |
44 | for (file_id, text) in change.files_changed { | 42 | for (file_id, text) in change.files_changed { |
45 | self.query_mut(ra_db::FileTextQuery).set(file_id, text) | 43 | self.set_file_text(file_id, text) |
46 | } | 44 | } |
47 | if !change.libraries_added.is_empty() { | 45 | if !change.libraries_added.is_empty() { |
48 | let mut libraries = Vec::clone(&self.library_roots()); | 46 | let mut libraries = Vec::clone(&self.library_roots()); |
49 | for library in change.libraries_added { | 47 | for library in change.libraries_added { |
50 | libraries.push(library.root_id); | 48 | libraries.push(library.root_id); |
51 | self.query_mut(ra_db::SourceRootQuery) | 49 | self.set_source_root(library.root_id, Default::default()); |
52 | .set(library.root_id, Default::default()); | 50 | self.set_constant_library_symbols(library.root_id, Arc::new(library.symbol_index)); |
53 | self.query_mut(LibrarySymbolsQuery) | ||
54 | .set_constant(library.root_id, Arc::new(library.symbol_index)); | ||
55 | self.apply_root_change(library.root_id, library.root_change); | 51 | self.apply_root_change(library.root_id, library.root_change); |
56 | } | 52 | } |
57 | self.query_mut(ra_db::LibraryRootsQuery) | 53 | self.set_library_roots(Arc::new(libraries)); |
58 | .set((), Arc::new(libraries)); | ||
59 | } | 54 | } |
60 | if let Some(crate_graph) = change.crate_graph { | 55 | if let Some(crate_graph) = change.crate_graph { |
61 | self.query_mut(ra_db::CrateGraphQuery) | 56 | self.set_crate_graph(Arc::new(crate_graph)) |
62 | .set((), Arc::new(crate_graph)) | ||
63 | } | 57 | } |
64 | } | 58 | } |
65 | 59 | ||
66 | fn apply_root_change(&mut self, root_id: SourceRootId, root_change: RootChange) { | 60 | fn apply_root_change(&mut self, root_id: SourceRootId, root_change: RootChange) { |
67 | let mut source_root = SourceRoot::clone(&self.source_root(root_id)); | 61 | let mut source_root = SourceRoot::clone(&self.source_root(root_id)); |
68 | for add_file in root_change.added { | 62 | for add_file in root_change.added { |
69 | self.query_mut(ra_db::FileTextQuery) | 63 | self.set_file_text(add_file.file_id, add_file.text); |
70 | .set(add_file.file_id, add_file.text); | 64 | self.set_file_relative_path(add_file.file_id, add_file.path.clone()); |
71 | self.query_mut(ra_db::FileRelativePathQuery) | 65 | self.set_file_source_root(add_file.file_id, root_id); |
72 | .set(add_file.file_id, add_file.path.clone()); | ||
73 | self.query_mut(ra_db::FileSourceRootQuery) | ||
74 | .set(add_file.file_id, root_id); | ||
75 | source_root.files.insert(add_file.path, add_file.file_id); | 66 | source_root.files.insert(add_file.path, add_file.file_id); |
76 | } | 67 | } |
77 | for remove_file in root_change.removed { | 68 | for remove_file in root_change.removed { |
78 | self.query_mut(ra_db::FileTextQuery) | 69 | self.set_file_text(remove_file.file_id, Default::default()); |
79 | .set(remove_file.file_id, Default::default()); | ||
80 | source_root.files.remove(&remove_file.path); | 70 | source_root.files.remove(&remove_file.path); |
81 | } | 71 | } |
82 | self.query_mut(ra_db::SourceRootQuery) | 72 | self.set_source_root(root_id, Arc::new(source_root)); |
83 | .set(root_id, Arc::new(source_root)); | ||
84 | } | 73 | } |
85 | 74 | ||
86 | #[allow(unused)] | 75 | #[allow(unused)] |
diff --git a/crates/ra_ide_api/src/status.rs b/crates/ra_ide_api/src/status.rs index 5c14cbdeb..d499dd878 100644 --- a/crates/ra_ide_api/src/status.rs +++ b/crates/ra_ide_api/src/status.rs | |||
@@ -6,7 +6,7 @@ use ra_db::{ | |||
6 | use crate::db::RootDatabase; | 6 | use crate::db::RootDatabase; |
7 | 7 | ||
8 | pub(crate) fn status(db: &RootDatabase) -> String { | 8 | pub(crate) fn status(db: &RootDatabase) -> String { |
9 | let n_parsed_files = db.query(SourceFileQuery).keys::<Vec<_>>().len(); | 9 | let n_parsed_files = db.query(SourceFileQuery).entries::<Vec<_>>().len(); |
10 | let n_defs = { | 10 | let n_defs = { |
11 | let interner: &hir::HirInterner = db.as_ref(); | 11 | let interner: &hir::HirInterner = db.as_ref(); |
12 | interner.len() | 12 | interner.len() |