aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_analysis/src/imp.rs15
-rw-r--r--crates/ra_analysis/src/lib.rs6
-rw-r--r--crates/ra_analysis/src/mock_analysis.rs2
-rw-r--r--crates/ra_hir/src/mock.rs13
-rw-r--r--crates/ra_lsp_server/src/server_world.rs3
5 files changed, 26 insertions, 13 deletions
diff --git a/crates/ra_analysis/src/imp.rs b/crates/ra_analysis/src/imp.rs
index 46169d863..9e441ca79 100644
--- a/crates/ra_analysis/src/imp.rs
+++ b/crates/ra_analysis/src/imp.rs
@@ -43,10 +43,19 @@ impl AnalysisHostImpl {
43 pub fn apply_change(&mut self, change: AnalysisChange) { 43 pub fn apply_change(&mut self, change: AnalysisChange) {
44 log::info!("apply_change {:?}", change); 44 log::info!("apply_change {:?}", change);
45 // self.gc_syntax_trees(); 45 // self.gc_syntax_trees();
46 for root_id in change.new_roots { 46 if !change.new_roots.is_empty() {
47 let mut local_roots = Vec::clone(&self.db.local_roots());
48 for (root_id, is_local) in change.new_roots {
49 self.db
50 .query_mut(ra_db::SourceRootQuery)
51 .set(root_id, Default::default());
52 if is_local {
53 local_roots.push(root_id);
54 }
55 }
47 self.db 56 self.db
48 .query_mut(ra_db::SourceRootQuery) 57 .query_mut(ra_db::LocalRootsQuery)
49 .set(root_id, Default::default()); 58 .set((), Arc::new(local_roots));
50 } 59 }
51 60
52 for (root_id, root_change) in change.roots_changed { 61 for (root_id, root_change) in change.roots_changed {
diff --git a/crates/ra_analysis/src/lib.rs b/crates/ra_analysis/src/lib.rs
index 0db3c3479..a1d462528 100644
--- a/crates/ra_analysis/src/lib.rs
+++ b/crates/ra_analysis/src/lib.rs
@@ -44,7 +44,7 @@ pub use ra_db::{
44 44
45#[derive(Default)] 45#[derive(Default)]
46pub struct AnalysisChange { 46pub struct AnalysisChange {
47 new_roots: Vec<SourceRootId>, 47 new_roots: Vec<(SourceRootId, bool)>,
48 roots_changed: FxHashMap<SourceRootId, RootChange>, 48 roots_changed: FxHashMap<SourceRootId, RootChange>,
49 files_changed: Vec<(FileId, Arc<String>)>, 49 files_changed: Vec<(FileId, Arc<String>)>,
50 libraries_added: Vec<LibraryData>, 50 libraries_added: Vec<LibraryData>,
@@ -95,8 +95,8 @@ impl AnalysisChange {
95 pub fn new() -> AnalysisChange { 95 pub fn new() -> AnalysisChange {
96 AnalysisChange::default() 96 AnalysisChange::default()
97 } 97 }
98 pub fn add_root(&mut self, root_id: SourceRootId) { 98 pub fn add_root(&mut self, root_id: SourceRootId, is_local: bool) {
99 self.new_roots.push(root_id); 99 self.new_roots.push((root_id, is_local));
100 } 100 }
101 pub fn add_file( 101 pub fn add_file(
102 &mut self, 102 &mut self,
diff --git a/crates/ra_analysis/src/mock_analysis.rs b/crates/ra_analysis/src/mock_analysis.rs
index 0c042e672..7cbdfb953 100644
--- a/crates/ra_analysis/src/mock_analysis.rs
+++ b/crates/ra_analysis/src/mock_analysis.rs
@@ -80,7 +80,7 @@ impl MockAnalysis {
80 let mut file_map = FileMap::default(); 80 let mut file_map = FileMap::default();
81 let source_root = SourceRootId(0); 81 let source_root = SourceRootId(0);
82 let mut change = AnalysisChange::new(); 82 let mut change = AnalysisChange::new();
83 change.add_root(source_root); 83 change.add_root(source_root, true);
84 for (path, contents) in self.files.into_iter() { 84 for (path, contents) in self.files.into_iter() {
85 assert!(path.starts_with('/')); 85 assert!(path.starts_with('/'));
86 let path = RelativePathBuf::from_path(&path[1..]).unwrap(); 86 let path = RelativePathBuf::from_path(&path[1..]).unwrap();
diff --git a/crates/ra_hir/src/mock.rs b/crates/ra_hir/src/mock.rs
index 54260101c..9423e6571 100644
--- a/crates/ra_hir/src/mock.rs
+++ b/crates/ra_hir/src/mock.rs
@@ -2,12 +2,14 @@ use std::sync::Arc;
2 2
3use parking_lot::Mutex; 3use parking_lot::Mutex;
4use salsa::{self, Database}; 4use salsa::{self, Database};
5use ra_db::{LocationIntener, BaseDatabase, FilePosition, FileId, WORKSPACE, CrateGraph, SourceRoot}; 5use ra_db::{LocationIntener, BaseDatabase, FilePosition, FileId, CrateGraph, SourceRoot, SourceRootId};
6use relative_path::RelativePathBuf; 6use relative_path::RelativePathBuf;
7use test_utils::{parse_fixture, CURSOR_MARKER, extract_offset}; 7use test_utils::{parse_fixture, CURSOR_MARKER, extract_offset};
8 8
9use crate::{db, DefId, DefLoc}; 9use crate::{db, DefId, DefLoc};
10 10
11const WORKSPACE: SourceRootId = SourceRootId(0);
12
11#[derive(Debug)] 13#[derive(Debug)]
12pub(crate) struct MockDatabase { 14pub(crate) struct MockDatabase {
13 events: Mutex<Option<Vec<salsa::Event<MockDatabase>>>>, 15 events: Mutex<Option<Vec<salsa::Event<MockDatabase>>>>,
@@ -106,11 +108,11 @@ impl Default for MockDatabase {
106 runtime: salsa::Runtime::default(), 108 runtime: salsa::Runtime::default(),
107 id_maps: Default::default(), 109 id_maps: Default::default(),
108 }; 110 };
109 db.query_mut(ra_db::SourceRootQuery)
110 .set(ra_db::WORKSPACE, Default::default());
111 db.query_mut(ra_db::CrateGraphQuery) 111 db.query_mut(ra_db::CrateGraphQuery)
112 .set((), Default::default()); 112 .set((), Default::default());
113 db.query_mut(ra_db::LibrariesQuery) 113 db.query_mut(ra_db::LocalRootsQuery)
114 .set((), Default::default());
115 db.query_mut(ra_db::LibraryRootsQuery)
114 .set((), Default::default()); 116 .set((), Default::default());
115 db 117 db
116 } 118 }
@@ -163,7 +165,8 @@ salsa::database_storage! {
163 fn file_relative_path() for ra_db::FileRelativePathQuery; 165 fn file_relative_path() for ra_db::FileRelativePathQuery;
164 fn file_source_root() for ra_db::FileSourceRootQuery; 166 fn file_source_root() for ra_db::FileSourceRootQuery;
165 fn source_root() for ra_db::SourceRootQuery; 167 fn source_root() for ra_db::SourceRootQuery;
166 fn libraries() for ra_db::LibrariesQuery; 168 fn local_roots() for ra_db::LocalRootsQuery;
169 fn library_roots() for ra_db::LibraryRootsQuery;
167 fn crate_graph() for ra_db::CrateGraphQuery; 170 fn crate_graph() for ra_db::CrateGraphQuery;
168 } 171 }
169 impl ra_db::SyntaxDatabase { 172 impl ra_db::SyntaxDatabase {
diff --git a/crates/ra_lsp_server/src/server_world.rs b/crates/ra_lsp_server/src/server_world.rs
index bdb4c513f..785877c4b 100644
--- a/crates/ra_lsp_server/src/server_world.rs
+++ b/crates/ra_lsp_server/src/server_world.rs
@@ -48,7 +48,8 @@ impl ServerWorldState {
48 let roots_to_scan = roots.len(); 48 let roots_to_scan = roots.len();
49 let (mut vfs, roots) = Vfs::new(roots); 49 let (mut vfs, roots) = Vfs::new(roots);
50 for r in roots { 50 for r in roots {
51 change.add_root(SourceRootId(r.0)); 51 let is_local = vfs.root2path(r).starts_with(&root);
52 change.add_root(SourceRootId(r.0), is_local);
52 } 53 }
53 54
54 let mut crate_graph = CrateGraph::default(); 55 let mut crate_graph = CrateGraph::default();