diff options
author | Aleksey Kladov <[email protected]> | 2018-10-08 11:18:47 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-10-15 19:20:20 +0100 |
commit | d783371b862c15d6d402d68e8edce4e37d63796c (patch) | |
tree | 927354d027fc6778aeb520ec0b74673d446e525d /crates/ra_analysis/src/roots.rs | |
parent | d8aee31a600a8a8a56ddee0ee2ff1c5d5ba2320b (diff) |
migrate modue map to salsa
Diffstat (limited to 'crates/ra_analysis/src/roots.rs')
-rw-r--r-- | crates/ra_analysis/src/roots.rs | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/crates/ra_analysis/src/roots.rs b/crates/ra_analysis/src/roots.rs index 7a7d1169e..908f49b0a 100644 --- a/crates/ra_analysis/src/roots.rs +++ b/crates/ra_analysis/src/roots.rs | |||
@@ -16,7 +16,8 @@ use crate::{ | |||
16 | imp::FileResolverImp, | 16 | imp::FileResolverImp, |
17 | symbol_index::SymbolIndex, | 17 | symbol_index::SymbolIndex, |
18 | descriptors::{ModuleDescriptor, ModuleTreeDescriptor}, | 18 | descriptors::{ModuleDescriptor, ModuleTreeDescriptor}, |
19 | db::{self, FilesDatabase, SyntaxDatabase} | 19 | db::{self, FilesDatabase, SyntaxDatabase}, |
20 | module_map::ModulesDatabase, | ||
20 | }; | 21 | }; |
21 | 22 | ||
22 | pub(crate) trait SourceRoot { | 23 | pub(crate) trait SourceRoot { |
@@ -53,17 +54,17 @@ impl WritableSourceRoot { | |||
53 | } | 54 | } |
54 | } | 55 | } |
55 | } | 56 | } |
56 | if let Some(resolver) = file_resolver { | 57 | let file_set = db.file_set(()); |
57 | let mut files: HashSet<FileId> = db.file_set(()) | 58 | let mut files: HashSet<FileId> = file_set |
58 | .files | 59 | .files |
59 | .clone(); | 60 | .clone(); |
60 | for file_id in removed { | 61 | for file_id in removed { |
61 | files.remove(&file_id); | 62 | files.remove(&file_id); |
62 | } | ||
63 | files.extend(changed); | ||
64 | db.query(db::FileSetQuery) | ||
65 | .set((), Arc::new(db::FileSet { files, resolver })) | ||
66 | } | 63 | } |
64 | files.extend(changed); | ||
65 | let resolver = file_resolver.unwrap_or_else(|| file_set.resolver.clone()); | ||
66 | db.query(db::FileSetQuery) | ||
67 | .set((), Arc::new(db::FileSet { files, resolver })); | ||
67 | // TODO: reconcile sasla's API with our needs | 68 | // TODO: reconcile sasla's API with our needs |
68 | // https://github.com/salsa-rs/salsa/issues/12 | 69 | // https://github.com/salsa-rs/salsa/issues/12 |
69 | self.clone() | 70 | self.clone() |
@@ -72,12 +73,13 @@ impl WritableSourceRoot { | |||
72 | 73 | ||
73 | impl SourceRoot for WritableSourceRoot { | 74 | impl SourceRoot for WritableSourceRoot { |
74 | fn module_tree(&self) -> Arc<ModuleTreeDescriptor> { | 75 | fn module_tree(&self) -> Arc<ModuleTreeDescriptor> { |
75 | unimplemented!() | 76 | self.db.read().module_tree(()) |
76 | //self.db.make_query(::module_map::module_tree) | ||
77 | } | 77 | } |
78 | |||
79 | fn contains(&self, file_id: FileId) -> bool { | 78 | fn contains(&self, file_id: FileId) -> bool { |
80 | self.db.read().file_set(()).files.contains(&file_id) | 79 | let db = self.db.read(); |
80 | let files = &db.file_set(()).files; | ||
81 | eprintln!("files = {:?}", files); | ||
82 | files.contains(&file_id) | ||
81 | } | 83 | } |
82 | fn lines(&self, file_id: FileId) -> Arc<LineIndex> { | 84 | fn lines(&self, file_id: FileId) -> Arc<LineIndex> { |
83 | self.db.read().file_lines(file_id) | 85 | self.db.read().file_lines(file_id) |