aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_api/src
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-01-25 12:25:01 +0000
committerAleksey Kladov <[email protected]>2019-01-25 12:25:01 +0000
commit08c12e424d5d3fb4e11f081a07b9c265dc7a96b6 (patch)
tree9ae3e23ac30d71f503673623f10b5eeaed1d9fef /crates/ra_ide_api/src
parent8cf092d5de113fc218b84421a2db4449a370ccb6 (diff)
use set methods
Diffstat (limited to 'crates/ra_ide_api/src')
-rw-r--r--crates/ra_ide_api/src/imp.rs39
1 files changed, 14 insertions, 25 deletions
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};
6use ra_db::{ 6use ra_db::{
7 FilesDatabase, SourceRoot, SourceRootId, SyntaxDatabase, 7 FilesDatabase, SourceRoot, SourceRootId, SyntaxDatabase,
8 salsa::{self, Database}, 8 salsa::Database,
9}; 9};
10use ra_ide_api_light::{self, assists, LocalEdit, Severity}; 10use ra_ide_api_light::{self, assists, LocalEdit, Severity};
11use ra_syntax::{ 11use 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
24impl db::RootDatabase { 24impl 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)]