diff options
author | Aleksey Kladov <[email protected]> | 2018-09-02 12:46:15 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-09-02 12:46:15 +0100 |
commit | 80be61ed78e8410e013cb94879435d54a4907c30 (patch) | |
tree | 3ab33c902644a3aa14b490be8a7caa9120da7537 /crates/server/src/server_world.rs | |
parent | 7fad13de73ded5b8a332c5f50c18671d612bd1e3 (diff) |
project model
Diffstat (limited to 'crates/server/src/server_world.rs')
-rw-r--r-- | crates/server/src/server_world.rs | 10 |
1 files changed, 9 insertions, 1 deletions
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::{ | |||
2 | fs, | 2 | fs, |
3 | path::{PathBuf, Path}, | 3 | path::{PathBuf, Path}, |
4 | collections::HashMap, | 4 | collections::HashMap, |
5 | sync::Arc, | ||
5 | }; | 6 | }; |
6 | 7 | ||
7 | use languageserver_types::Url; | 8 | use languageserver_types::Url; |
@@ -11,10 +12,12 @@ use { | |||
11 | Result, | 12 | Result, |
12 | path_map::PathMap, | 13 | path_map::PathMap, |
13 | vfs::{FileEvent, FileEventKind}, | 14 | vfs::{FileEvent, FileEventKind}, |
15 | project_model::CargoWorkspace, | ||
14 | }; | 16 | }; |
15 | 17 | ||
16 | #[derive(Debug)] | 18 | #[derive(Debug)] |
17 | pub struct ServerWorldState { | 19 | pub struct ServerWorldState { |
20 | pub workspaces: Arc<Vec<CargoWorkspace>>, | ||
18 | pub analysis_host: AnalysisHost, | 21 | pub analysis_host: AnalysisHost, |
19 | pub path_map: PathMap, | 22 | pub path_map: PathMap, |
20 | pub mem_map: HashMap<FileId, Option<String>>, | 23 | pub mem_map: HashMap<FileId, Option<String>>, |
@@ -22,6 +25,7 @@ pub struct ServerWorldState { | |||
22 | 25 | ||
23 | #[derive(Clone)] | 26 | #[derive(Clone)] |
24 | pub struct ServerWorld { | 27 | pub struct ServerWorld { |
28 | pub workspaces: Arc<Vec<CargoWorkspace>>, | ||
25 | pub analysis: Analysis, | 29 | pub analysis: Analysis, |
26 | pub path_map: PathMap, | 30 | pub path_map: PathMap, |
27 | } | 31 | } |
@@ -29,6 +33,7 @@ pub struct ServerWorld { | |||
29 | impl ServerWorldState { | 33 | impl ServerWorldState { |
30 | pub fn new() -> ServerWorldState { | 34 | pub fn new() -> ServerWorldState { |
31 | ServerWorldState { | 35 | ServerWorldState { |
36 | workspaces: Arc::new(Vec::new()), | ||
32 | analysis_host: AnalysisHost::new(), | 37 | analysis_host: AnalysisHost::new(), |
33 | path_map: PathMap::new(), | 38 | path_map: PathMap::new(), |
34 | mem_map: HashMap::new(), | 39 | mem_map: HashMap::new(), |
@@ -89,9 +94,12 @@ impl ServerWorldState { | |||
89 | self.analysis_host.change_file(file_id, text); | 94 | self.analysis_host.change_file(file_id, text); |
90 | Ok(file_id) | 95 | Ok(file_id) |
91 | } | 96 | } |
92 | 97 | pub fn set_workspaces(&mut self, ws: Vec<CargoWorkspace>) { | |
98 | self.workspaces = Arc::new(ws); | ||
99 | } | ||
93 | pub fn snapshot(&self) -> ServerWorld { | 100 | pub fn snapshot(&self) -> ServerWorld { |
94 | ServerWorld { | 101 | ServerWorld { |
102 | workspaces: Arc::clone(&self.workspaces), | ||
95 | analysis: self.analysis_host.analysis(self.path_map.clone()), | 103 | analysis: self.analysis_host.analysis(self.path_map.clone()), |
96 | path_map: self.path_map.clone() | 104 | path_map: self.path_map.clone() |
97 | } | 105 | } |