aboutsummaryrefslogtreecommitdiff
path: root/crates/server/src/server_world.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-09-02 14:36:03 +0100
committerAleksey Kladov <[email protected]>2018-09-02 14:36:03 +0100
commite98d8cd255ab5c2fee873a58af6c2c3ad561dab4 (patch)
tree04869b8fe93e724d8aa266177e48644051331ab9 /crates/server/src/server_world.rs
parent1329dd4e287c137ec0a90abeec0272275b2b2c8d (diff)
nail down runnables
Diffstat (limited to 'crates/server/src/server_world.rs')
-rw-r--r--crates/server/src/server_world.rs17
1 files changed, 16 insertions, 1 deletions
diff --git a/crates/server/src/server_world.rs b/crates/server/src/server_world.rs
index 4d5c50428..f78b56cf8 100644
--- a/crates/server/src/server_world.rs
+++ b/crates/server/src/server_world.rs
@@ -6,7 +6,7 @@ use std::{
6}; 6};
7 7
8use languageserver_types::Url; 8use languageserver_types::Url;
9use libanalysis::{FileId, AnalysisHost, Analysis}; 9use libanalysis::{FileId, AnalysisHost, Analysis, CrateGraph, CrateId};
10 10
11use { 11use {
12 Result, 12 Result,
@@ -95,7 +95,22 @@ impl ServerWorldState {
95 Ok(file_id) 95 Ok(file_id)
96 } 96 }
97 pub fn set_workspaces(&mut self, ws: Vec<CargoWorkspace>) { 97 pub fn set_workspaces(&mut self, ws: Vec<CargoWorkspace>) {
98 let mut crate_roots = HashMap::new();
99 ws.iter()
100 .flat_map(|ws| {
101 ws.packages()
102 .flat_map(move |pkg| pkg.targets(ws))
103 .map(move |tgt| tgt.root(ws))
104 })
105 .for_each(|root| {
106 if let Some(file_id) = self.path_map.get_id(root) {
107 let crate_id = CrateId(crate_roots.len() as u32);
108 crate_roots.insert(crate_id, file_id);
109 }
110 });
111 let crate_graph = CrateGraph { crate_roots };
98 self.workspaces = Arc::new(ws); 112 self.workspaces = Arc::new(ws);
113 self.analysis_host.set_crate_graph(crate_graph);
99 } 114 }
100 pub fn snapshot(&self) -> ServerWorld { 115 pub fn snapshot(&self) -> ServerWorld {
101 ServerWorld { 116 ServerWorld {