From 80be61ed78e8410e013cb94879435d54a4907c30 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 2 Sep 2018 14:46:15 +0300 Subject: project model --- crates/server/src/server_world.rs | 10 +++++++++- 1 file changed, 9 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 d99ef661e..4d5c50428 100644 --- a/crates/server/src/server_world.rs +++ b/crates/server/src/server_world.rs @@ -2,6 +2,7 @@ use std::{ fs, path::{PathBuf, Path}, collections::HashMap, + sync::Arc, }; use languageserver_types::Url; @@ -11,10 +12,12 @@ use { Result, path_map::PathMap, vfs::{FileEvent, FileEventKind}, + project_model::CargoWorkspace, }; #[derive(Debug)] pub struct ServerWorldState { + pub workspaces: Arc>, pub analysis_host: AnalysisHost, pub path_map: PathMap, pub mem_map: HashMap>, @@ -22,6 +25,7 @@ pub struct ServerWorldState { #[derive(Clone)] pub struct ServerWorld { + pub workspaces: Arc>, pub analysis: Analysis, pub path_map: PathMap, } @@ -29,6 +33,7 @@ pub struct ServerWorld { impl ServerWorldState { pub fn new() -> ServerWorldState { ServerWorldState { + workspaces: Arc::new(Vec::new()), analysis_host: AnalysisHost::new(), path_map: PathMap::new(), mem_map: HashMap::new(), @@ -89,9 +94,12 @@ impl ServerWorldState { self.analysis_host.change_file(file_id, text); Ok(file_id) } - + pub fn set_workspaces(&mut self, ws: Vec) { + self.workspaces = Arc::new(ws); + } pub fn snapshot(&self) -> ServerWorld { ServerWorld { + workspaces: Arc::clone(&self.workspaces), analysis: self.analysis_host.analysis(self.path_map.clone()), path_map: self.path_map.clone() } -- cgit v1.2.3