From 42370610ce03c1bb5893d9e29c2c215482e8d8ca Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 4 Nov 2019 22:28:47 +0300 Subject: Restore assists tests --- crates/ra_assists/src/test_db.rs | 43 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 crates/ra_assists/src/test_db.rs (limited to 'crates/ra_assists/src/test_db.rs') diff --git a/crates/ra_assists/src/test_db.rs b/crates/ra_assists/src/test_db.rs new file mode 100644 index 000000000..7b196561a --- /dev/null +++ b/crates/ra_assists/src/test_db.rs @@ -0,0 +1,43 @@ +use std::sync::Arc; + +use ra_db::{salsa, CrateId, FileId, FileLoader, FileLoaderDelegate, RelativePath}; + +#[salsa::database( + ra_db::SourceDatabaseExtStorage, + ra_db::SourceDatabaseStorage, + hir::db::InternDatabaseStorage, + hir::db::AstDatabaseStorage, + hir::db::DefDatabaseStorage, + hir::db::DefDatabase2Storage, + hir::db::HirDatabaseStorage +)] +#[derive(Debug, Default)] +pub struct TestDB { + runtime: salsa::Runtime, +} + +impl salsa::Database for TestDB { + fn salsa_runtime(&self) -> &salsa::Runtime { + &self.runtime + } +} + +impl std::panic::RefUnwindSafe for TestDB {} + +impl FileLoader for TestDB { + fn file_text(&self, file_id: FileId) -> Arc { + FileLoaderDelegate(self).file_text(file_id) + } + fn resolve_relative_path( + &self, + anchor: FileId, + relative_path: &RelativePath, + ) -> Option { + FileLoaderDelegate(self).resolve_relative_path(anchor, relative_path) + } + fn relevant_crates(&self, file_id: FileId) -> Arc> { + FileLoaderDelegate(self).relevant_crates(file_id) + } +} + +impl hir::debug::HirDebugHelper for TestDB {} -- cgit v1.2.3 From 50364bd47815f4f9174d46ae33f44f7f56545b2d Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 4 Nov 2019 22:33:21 +0300 Subject: Appease the linter by dummy doc comments --- crates/ra_assists/src/test_db.rs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'crates/ra_assists/src/test_db.rs') diff --git a/crates/ra_assists/src/test_db.rs b/crates/ra_assists/src/test_db.rs index 7b196561a..5be7383ed 100644 --- a/crates/ra_assists/src/test_db.rs +++ b/crates/ra_assists/src/test_db.rs @@ -1,3 +1,5 @@ +//! Database used for testing `ra_assists`. + use std::sync::Arc; use ra_db::{salsa, CrateId, FileId, FileLoader, FileLoaderDelegate, RelativePath}; -- cgit v1.2.3