aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_db/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ide_db/src/lib.rs')
-rw-r--r--crates/ra_ide_db/src/lib.rs37
1 files changed, 6 insertions, 31 deletions
diff --git a/crates/ra_ide_db/src/lib.rs b/crates/ra_ide_db/src/lib.rs
index 1b74e6558..a808de4f1 100644
--- a/crates/ra_ide_db/src/lib.rs
+++ b/crates/ra_ide_db/src/lib.rs
@@ -16,10 +16,10 @@ use std::sync::Arc;
16use hir::db::{AstDatabase, DefDatabase}; 16use hir::db::{AstDatabase, DefDatabase};
17use ra_db::{ 17use ra_db::{
18 salsa::{self, Database, Durability}, 18 salsa::{self, Database, Durability},
19 Canceled, CheckCanceled, CrateId, FileId, FileLoader, FileLoaderDelegate, RelativePath, 19 Canceled, CheckCanceled, CrateId, FileId, FileLoader, FileLoaderDelegate, SourceDatabase,
20 SourceDatabase, SourceRootId, Upcast, 20 Upcast,
21}; 21};
22use rustc_hash::FxHashMap; 22use rustc_hash::FxHashSet;
23 23
24use crate::{line_index::LineIndex, symbol_index::SymbolsDatabase}; 24use crate::{line_index::LineIndex, symbol_index::SymbolsDatabase};
25 25
@@ -36,7 +36,6 @@ use crate::{line_index::LineIndex, symbol_index::SymbolsDatabase};
36#[derive(Debug)] 36#[derive(Debug)]
37pub struct RootDatabase { 37pub struct RootDatabase {
38 runtime: salsa::Runtime<RootDatabase>, 38 runtime: salsa::Runtime<RootDatabase>,
39 pub(crate) debug_data: Arc<DebugData>,
40 pub last_gc: crate::wasm_shims::Instant, 39 pub last_gc: crate::wasm_shims::Instant,
41 pub last_gc_check: crate::wasm_shims::Instant, 40 pub last_gc_check: crate::wasm_shims::Instant,
42} 41}
@@ -57,23 +56,12 @@ impl FileLoader for RootDatabase {
57 fn file_text(&self, file_id: FileId) -> Arc<String> { 56 fn file_text(&self, file_id: FileId) -> Arc<String> {
58 FileLoaderDelegate(self).file_text(file_id) 57 FileLoaderDelegate(self).file_text(file_id)
59 } 58 }
60 fn resolve_relative_path( 59 fn resolve_path(&self, anchor: FileId, path: &str) -> Option<FileId> {
61 &self, 60 FileLoaderDelegate(self).resolve_path(anchor, path)
62 anchor: FileId,
63 relative_path: &RelativePath,
64 ) -> Option<FileId> {
65 FileLoaderDelegate(self).resolve_relative_path(anchor, relative_path)
66 } 61 }
67 fn relevant_crates(&self, file_id: FileId) -> Arc<Vec<CrateId>> { 62 fn relevant_crates(&self, file_id: FileId) -> Arc<FxHashSet<CrateId>> {
68 FileLoaderDelegate(self).relevant_crates(file_id) 63 FileLoaderDelegate(self).relevant_crates(file_id)
69 } 64 }
70 fn resolve_extern_path(
71 &self,
72 extern_id: ra_db::ExternSourceId,
73 relative_path: &RelativePath,
74 ) -> Option<FileId> {
75 FileLoaderDelegate(self).resolve_extern_path(extern_id, relative_path)
76 }
77} 65}
78 66
79impl salsa::Database for RootDatabase { 67impl salsa::Database for RootDatabase {
@@ -109,7 +97,6 @@ impl RootDatabase {
109 runtime: salsa::Runtime::default(), 97 runtime: salsa::Runtime::default(),
110 last_gc: crate::wasm_shims::Instant::now(), 98 last_gc: crate::wasm_shims::Instant::now(),
111 last_gc_check: crate::wasm_shims::Instant::now(), 99 last_gc_check: crate::wasm_shims::Instant::now(),
112 debug_data: Default::default(),
113 }; 100 };
114 db.set_crate_graph_with_durability(Default::default(), Durability::HIGH); 101 db.set_crate_graph_with_durability(Default::default(), Durability::HIGH);
115 db.set_local_roots_with_durability(Default::default(), Durability::HIGH); 102 db.set_local_roots_with_durability(Default::default(), Durability::HIGH);
@@ -132,7 +119,6 @@ impl salsa::ParallelDatabase for RootDatabase {
132 runtime: self.runtime.snapshot(self), 119 runtime: self.runtime.snapshot(self),
133 last_gc: self.last_gc, 120 last_gc: self.last_gc,
134 last_gc_check: self.last_gc_check, 121 last_gc_check: self.last_gc_check,
135 debug_data: Arc::clone(&self.debug_data),
136 }) 122 })
137 } 123 }
138} 124}
@@ -146,14 +132,3 @@ fn line_index(db: &impl LineIndexDatabase, file_id: FileId) -> Arc<LineIndex> {
146 let text = db.file_text(file_id); 132 let text = db.file_text(file_id);
147 Arc::new(LineIndex::new(&*text)) 133 Arc::new(LineIndex::new(&*text))
148} 134}
149
150#[derive(Debug, Default, Clone)]
151pub(crate) struct DebugData {
152 pub(crate) root_paths: FxHashMap<SourceRootId, String>,
153}
154
155impl DebugData {
156 pub(crate) fn merge(&mut self, other: DebugData) {
157 self.root_paths.extend(other.root_paths.into_iter());
158 }
159}