diff options
author | Aleksey Kladov <[email protected]> | 2018-10-25 15:40:24 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-10-25 15:40:24 +0100 |
commit | e0eb33605a917d2e7289debe0c915e75286b834f (patch) | |
tree | ea35a9250c22fdc201daad5ae971a214f1c23e70 /crates/ra_lsp_server | |
parent | 75d9cbd7c22b09a0bc2731731228c95ae60573c3 (diff) |
Encapsulate CrateGraph a bit
Diffstat (limited to 'crates/ra_lsp_server')
-rw-r--r-- | crates/ra_lsp_server/src/server_world.rs | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/crates/ra_lsp_server/src/server_world.rs b/crates/ra_lsp_server/src/server_world.rs index 555de66ff..25986e230 100644 --- a/crates/ra_lsp_server/src/server_world.rs +++ b/crates/ra_lsp_server/src/server_world.rs | |||
@@ -2,11 +2,10 @@ use std::{ | |||
2 | fs, | 2 | fs, |
3 | path::{Path, PathBuf}, | 3 | path::{Path, PathBuf}, |
4 | sync::Arc, | 4 | sync::Arc, |
5 | collections::BTreeMap, | ||
6 | }; | 5 | }; |
7 | 6 | ||
8 | use languageserver_types::Url; | 7 | use languageserver_types::Url; |
9 | use ra_analysis::{Analysis, AnalysisHost, AnalysisChange, CrateGraph, CrateId, FileId, FileResolver, LibraryData}; | 8 | use ra_analysis::{Analysis, AnalysisHost, AnalysisChange, CrateGraph, FileId, FileResolver, LibraryData}; |
10 | use rustc_hash::FxHashMap; | 9 | use rustc_hash::FxHashMap; |
11 | 10 | ||
12 | use crate::{ | 11 | use crate::{ |
@@ -149,7 +148,7 @@ impl ServerWorldState { | |||
149 | Ok(file_id) | 148 | Ok(file_id) |
150 | } | 149 | } |
151 | pub fn set_workspaces(&mut self, ws: Vec<CargoWorkspace>) { | 150 | pub fn set_workspaces(&mut self, ws: Vec<CargoWorkspace>) { |
152 | let mut crate_roots = BTreeMap::default(); | 151 | let mut crate_graph = CrateGraph::new(); |
153 | ws.iter() | 152 | ws.iter() |
154 | .flat_map(|ws| { | 153 | .flat_map(|ws| { |
155 | ws.packages() | 154 | ws.packages() |
@@ -158,11 +157,9 @@ impl ServerWorldState { | |||
158 | }) | 157 | }) |
159 | .for_each(|root| { | 158 | .for_each(|root| { |
160 | if let Some(file_id) = self.path_map.get_id(root) { | 159 | if let Some(file_id) = self.path_map.get_id(root) { |
161 | let crate_id = CrateId(crate_roots.len() as u32); | 160 | crate_graph.add_crate_root(file_id); |
162 | crate_roots.insert(crate_id, file_id); | ||
163 | } | 161 | } |
164 | }); | 162 | }); |
165 | let crate_graph = CrateGraph { crate_roots }; | ||
166 | self.workspaces = Arc::new(ws); | 163 | self.workspaces = Arc::new(ws); |
167 | let mut change = AnalysisChange::new(); | 164 | let mut change = AnalysisChange::new(); |
168 | change.set_crate_graph(crate_graph); | 165 | change.set_crate_graph(crate_graph); |