From e98d8cd255ab5c2fee873a58af6c2c3ad561dab4 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 2 Sep 2018 16:36:03 +0300 Subject: nail down runnables --- crates/server/src/server_world.rs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'crates/server/src/server_world.rs') 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::{ }; use languageserver_types::Url; -use libanalysis::{FileId, AnalysisHost, Analysis}; +use libanalysis::{FileId, AnalysisHost, Analysis, CrateGraph, CrateId}; use { Result, @@ -95,7 +95,22 @@ impl ServerWorldState { Ok(file_id) } pub fn set_workspaces(&mut self, ws: Vec) { + let mut crate_roots = HashMap::new(); + ws.iter() + .flat_map(|ws| { + ws.packages() + .flat_map(move |pkg| pkg.targets(ws)) + .map(move |tgt| tgt.root(ws)) + }) + .for_each(|root| { + if let Some(file_id) = self.path_map.get_id(root) { + let crate_id = CrateId(crate_roots.len() as u32); + crate_roots.insert(crate_id, file_id); + } + }); + let crate_graph = CrateGraph { crate_roots }; self.workspaces = Arc::new(ws); + self.analysis_host.set_crate_graph(crate_graph); } pub fn snapshot(&self) -> ServerWorld { ServerWorld { -- cgit v1.2.3