]> git.lizzy.rs Git - rust.git/blobdiff - crates/ra_lsp_server/src/server_world.rs
automatically collect garbage
[rust.git] / crates / ra_lsp_server / src / server_world.rs
index c24ded9f97160c7892e9235ac50414eaa9743e27..c2167c5d80342c69a2eb283accdfd45f9c4a0eb0 100644 (file)
@@ -231,6 +231,14 @@ pub fn snapshot(&self) -> ServerWorld {
             vfs: Arc::clone(&self.vfs),
         }
     }
+
+    pub fn maybe_collect_garbage(&mut self) {
+        self.analysis_host.maybe_collect_garbage()
+    }
+
+    pub fn collect_garbage(&mut self) {
+        self.analysis_host.collect_garbage()
+    }
 }
 
 impl ServerWorld {
@@ -264,4 +272,19 @@ pub fn path_to_uri(&self, root: SourceRootId, path: &RelativePathBuf) -> Result<
             .map_err(|_| format_err!("can't convert path to url: {}", path.display()))?;
         Ok(url)
     }
+
+    pub fn status(&self) -> String {
+        let mut res = String::new();
+        if self.workspaces.is_empty() {
+            res.push_str("no workspaces\n")
+        } else {
+            res.push_str("workspaces:\n");
+            for w in self.workspaces.iter() {
+                res += &format!("{} packages loaded\n", w.cargo.packages().count());
+            }
+        }
+        res.push_str("\nanalysis:\n");
+        res.push_str(&self.analysis.status());
+        res
+    }
 }