aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2019-06-24 10:35:51 +0100
committerbors[bot] <26634292+bors[bot]@users.noreply.github.com>2019-06-24 10:35:51 +0100
commitb34f65bcedadf2bb8fb738711a01be9c825c98c9 (patch)
treed28eb50d564dac058dea473e72940cccd5ae981c
parent7d79be32801036c39507fe96f87ed316e3934662 (diff)
parent8109ebb101ec19ffc8e003171bda8f7c53bb79e4 (diff)
Merge #1433
1433: Add SourceRoot::is_library, in preparation for salsa's durability r=matklad a=matklad Co-authored-by: Aleksey Kladov <[email protected]>
-rw-r--r--crates/ra_db/src/input.rs14
-rw-r--r--crates/ra_ide_api/src/change.rs3
2 files changed, 16 insertions, 1 deletions
diff --git a/crates/ra_db/src/input.rs b/crates/ra_db/src/input.rs
index a5f4e489f..c103503bd 100644
--- a/crates/ra_db/src/input.rs
+++ b/crates/ra_db/src/input.rs
@@ -31,9 +31,23 @@ pub struct SourceRootId(pub u32);
31 31
32#[derive(Default, Clone, Debug, PartialEq, Eq)] 32#[derive(Default, Clone, Debug, PartialEq, Eq)]
33pub struct SourceRoot { 33pub struct SourceRoot {
34 /// Sysroot or crates.io library.
35 ///
36 /// Libraries are considered mostly immutable, this assumption is used to
37 /// optimize salsa's query structure
38 pub is_library: bool,
34 pub files: FxHashMap<RelativePathBuf, FileId>, 39 pub files: FxHashMap<RelativePathBuf, FileId>,
35} 40}
36 41
42impl SourceRoot {
43 pub fn new() -> SourceRoot {
44 Default::default()
45 }
46 pub fn new_library() -> SourceRoot {
47 SourceRoot { is_library: true, ..SourceRoot::new() }
48 }
49}
50
37/// `CrateGraph` is a bit of information which turns a set of text files into a 51/// `CrateGraph` is a bit of information which turns a set of text files into a
38/// number of Rust crates. Each crate is defined by the `FileId` of its root module, 52/// number of Rust crates. Each crate is defined by the `FileId` of its root module,
39/// the set of cfg flags (not yet implemented) and the set of dependencies. Note 53/// the set of cfg flags (not yet implemented) and the set of dependencies. Note
diff --git a/crates/ra_ide_api/src/change.rs b/crates/ra_ide_api/src/change.rs
index 895b1e966..8d9918d16 100644
--- a/crates/ra_ide_api/src/change.rs
+++ b/crates/ra_ide_api/src/change.rs
@@ -163,7 +163,8 @@ impl RootDatabase {
163 if !change.new_roots.is_empty() { 163 if !change.new_roots.is_empty() {
164 let mut local_roots = Vec::clone(&self.local_roots()); 164 let mut local_roots = Vec::clone(&self.local_roots());
165 for (root_id, is_local) in change.new_roots { 165 for (root_id, is_local) in change.new_roots {
166 self.set_source_root(root_id, Default::default()); 166 let root = if is_local { SourceRoot::new() } else { SourceRoot::new_library() };
167 self.set_source_root(root_id, Arc::new(root));
167 if is_local { 168 if is_local {
168 local_roots.push(root_id); 169 local_roots.push(root_id);
169 } 170 }