aboutsummaryrefslogtreecommitdiff
path: root/crates/rust-analyzer/src/global_state.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/rust-analyzer/src/global_state.rs')
-rw-r--r--crates/rust-analyzer/src/global_state.rs36
1 files changed, 3 insertions, 33 deletions
diff --git a/crates/rust-analyzer/src/global_state.rs b/crates/rust-analyzer/src/global_state.rs
index a9a1d09fd..7533bb319 100644
--- a/crates/rust-analyzer/src/global_state.rs
+++ b/crates/rust-analyzer/src/global_state.rs
@@ -12,8 +12,6 @@ use parking_lot::RwLock;
12use ra_db::{CrateId, VfsPath}; 12use ra_db::{CrateId, VfsPath};
13use ra_ide::{Analysis, AnalysisChange, AnalysisHost, FileId}; 13use ra_ide::{Analysis, AnalysisChange, AnalysisHost, FileId};
14use ra_project_model::{CargoWorkspace, ProcMacroClient, ProjectWorkspace, Target}; 14use ra_project_model::{CargoWorkspace, ProcMacroClient, ProjectWorkspace, Target};
15use stdx::format_to;
16use vfs::loader::Handle as _;
17 15
18use crate::{ 16use crate::{
19 config::Config, 17 config::Config,
@@ -83,15 +81,15 @@ pub(crate) struct GlobalStateSnapshot {
83 pub(crate) check_fixes: CheckFixes, 81 pub(crate) check_fixes: CheckFixes,
84 pub(crate) latest_requests: Arc<RwLock<LatestRequests>>, 82 pub(crate) latest_requests: Arc<RwLock<LatestRequests>>,
85 vfs: Arc<RwLock<(vfs::Vfs, FxHashMap<FileId, LineEndings>)>>, 83 vfs: Arc<RwLock<(vfs::Vfs, FxHashMap<FileId, LineEndings>)>>,
86 workspaces: Arc<Vec<ProjectWorkspace>>, 84 pub(crate) workspaces: Arc<Vec<ProjectWorkspace>>,
87} 85}
88 86
89impl GlobalState { 87impl GlobalState {
90 pub(crate) fn new(sender: Sender<lsp_server::Message>, config: Config) -> GlobalState { 88 pub(crate) fn new(sender: Sender<lsp_server::Message>, config: Config) -> GlobalState {
91 let loader = { 89 let loader = {
92 let (sender, receiver) = unbounded::<vfs::loader::Message>(); 90 let (sender, receiver) = unbounded::<vfs::loader::Message>();
93 let handle = 91 let handle: vfs_notify::NotifyHandle =
94 vfs_notify::NotifyHandle::spawn(Box::new(move |msg| sender.send(msg).unwrap())); 92 vfs::loader::Handle::spawn(Box::new(move |msg| sender.send(msg).unwrap()));
95 let handle = Box::new(handle) as Box<dyn vfs::loader::Handle>; 93 let handle = Box::new(handle) as Box<dyn vfs::loader::Handle>;
96 Handle { handle, receiver } 94 Handle { handle, receiver }
97 }; 95 };
@@ -171,14 +169,6 @@ impl GlobalState {
171 } 169 }
172 } 170 }
173 171
174 pub(crate) fn maybe_collect_garbage(&mut self) {
175 self.analysis_host.maybe_collect_garbage()
176 }
177
178 pub(crate) fn collect_garbage(&mut self) {
179 self.analysis_host.collect_garbage()
180 }
181
182 pub(crate) fn send(&mut self, message: lsp_server::Message) { 172 pub(crate) fn send(&mut self, message: lsp_server::Message) {
183 self.sender.send(message).unwrap() 173 self.sender.send(message).unwrap()
184 } 174 }
@@ -242,26 +232,6 @@ impl GlobalStateSnapshot {
242 ProjectWorkspace::Json { .. } => None, 232 ProjectWorkspace::Json { .. } => None,
243 }) 233 })
244 } 234 }
245
246 pub(crate) fn status(&self) -> String {
247 let mut buf = String::new();
248 if self.workspaces.is_empty() {
249 buf.push_str("no workspaces\n")
250 } else {
251 buf.push_str("workspaces:\n");
252 for w in self.workspaces.iter() {
253 format_to!(buf, "{} packages loaded\n", w.n_packages());
254 }
255 }
256 buf.push_str("\nanalysis:\n");
257 buf.push_str(
258 &self
259 .analysis
260 .status()
261 .unwrap_or_else(|_| "Analysis retrieval was cancelled".to_owned()),
262 );
263 buf
264 }
265} 235}
266 236
267pub(crate) fn file_id_to_url(vfs: &vfs::Vfs, id: FileId) -> Url { 237pub(crate) fn file_id_to_url(vfs: &vfs::Vfs, id: FileId) -> Url {