]> git.lizzy.rs Git - rust.git/blobdiff - crates/ra_ide_db/src/change.rs
Remove relative_path dependency
[rust.git] / crates / ra_ide_db / src / change.rs
index 2504d7a338896f7d6d0cfc28ad54620c28185933..d1a255dcfcf7e32315163af728c5022382bb447d 100644 (file)
@@ -5,8 +5,7 @@
 
 use ra_db::{
     salsa::{Database, Durability, SweepStrategy},
-    CrateGraph, FileId, RelativePathBuf, SourceDatabase, SourceDatabaseExt, SourceRoot,
-    SourceRootId,
+    CrateGraph, FileId, SourceDatabase, SourceDatabaseExt, SourceRoot, SourceRootId,
 };
 use ra_prof::{memory_usage, profile, Bytes};
 use rustc_hash::FxHashSet;
@@ -57,14 +56,14 @@ pub fn set_crate_graph(&mut self, graph: CrateGraph) {
 #[derive(Debug)]
 struct AddFile {
     file_id: FileId,
-    path: RelativePathBuf,
+    path: String,
     text: Arc<String>,
 }
 
 #[derive(Debug)]
 struct RemoveFile {
     file_id: FileId,
-    path: RelativePathBuf,
+    path: String,
 }
 
 #[derive(Default)]
@@ -147,37 +146,46 @@ pub fn collect_garbage(&mut self) {
 
         let sweep = SweepStrategy::default().discard_values().sweep_all_revisions();
 
-        self.query(ra_db::ParseQuery).sweep(sweep);
-        self.query(hir::db::ParseMacroQuery).sweep(sweep);
+        ra_db::ParseQuery.in_db(self).sweep(sweep);
+        hir::db::ParseMacroQuery.in_db(self).sweep(sweep);
 
         // Macros do take significant space, but less then the syntax trees
         // self.query(hir::db::MacroDefQuery).sweep(sweep);
         // self.query(hir::db::MacroArgQuery).sweep(sweep);
         // self.query(hir::db::MacroExpandQuery).sweep(sweep);
 
-        self.query(hir::db::AstIdMapQuery).sweep(sweep);
+        hir::db::AstIdMapQuery.in_db(self).sweep(sweep);
 
-        self.query(hir::db::BodyWithSourceMapQuery).sweep(sweep);
+        hir::db::BodyWithSourceMapQuery.in_db(self).sweep(sweep);
 
-        self.query(hir::db::ExprScopesQuery).sweep(sweep);
-        self.query(hir::db::InferQueryQuery).sweep(sweep);
-        self.query(hir::db::BodyQuery).sweep(sweep);
+        hir::db::ExprScopesQuery.in_db(self).sweep(sweep);
+        hir::db::InferQueryQuery.in_db(self).sweep(sweep);
+        hir::db::BodyQuery.in_db(self).sweep(sweep);
     }
 
+    // Feature: Memory Usage
+    //
+    // Clears rust-analyzer's internal database and prints memory usage statistics.
+    //
+    // |===
+    // | Editor  | Action Name
+    //
+    // | VS Code | **Rust Analyzer: Memory Usage (Clears Database)**
+    // |===
     pub fn per_query_memory_usage(&mut self) -> Vec<(String, Bytes)> {
         let mut acc: Vec<(String, Bytes)> = vec![];
         let sweep = SweepStrategy::default().discard_values().sweep_all_revisions();
         macro_rules! sweep_each_query {
             ($($q:path)*) => {$(
                 let before = memory_usage().allocated;
-                self.query($q).sweep(sweep);
+                $q.in_db(self).sweep(sweep);
                 let after = memory_usage().allocated;
                 let q: $q = Default::default();
                 let name = format!("{:?}", q);
                 acc.push((name, before - after));
 
                 let before = memory_usage().allocated;
-                self.query($q).sweep(sweep.discard_everything());
+                $q.in_db(self).sweep(sweep.discard_everything());
                 let after = memory_usage().allocated;
                 let q: $q = Default::default();
                 let name = format!("{:?} (deps)", q);
@@ -252,7 +260,7 @@ macro_rules! sweep_each_query {
         // write.
         // We do this after collecting the non-interned queries to correctly attribute memory used
         // by interned data.
-        self.runtime.synthetic_write(Durability::HIGH);
+        self.salsa_runtime_mut().synthetic_write(Durability::HIGH);
 
         sweep_each_query![
             // AstDatabase