aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_api/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ide_api/src')
-rw-r--r--crates/ra_ide_api/src/change.rs2
-rw-r--r--crates/ra_ide_api/src/db.rs23
-rw-r--r--crates/ra_ide_api/src/diagnostics.rs2
-rw-r--r--crates/ra_ide_api/src/lib.rs10
-rw-r--r--crates/ra_ide_api/src/references.rs2
-rw-r--r--crates/ra_ide_api/src/symbol_index.rs2
6 files changed, 32 insertions, 9 deletions
diff --git a/crates/ra_ide_api/src/change.rs b/crates/ra_ide_api/src/change.rs
index 09913787b..050249c0e 100644
--- a/crates/ra_ide_api/src/change.rs
+++ b/crates/ra_ide_api/src/change.rs
@@ -4,7 +4,7 @@ use std::{fmt, sync::Arc, time};
4 4
5use ra_db::{ 5use ra_db::{
6 salsa::{Database, Durability, SweepStrategy}, 6 salsa::{Database, Durability, SweepStrategy},
7 CrateGraph, CrateId, FileId, SourceDatabase, SourceRoot, SourceRootId, 7 CrateGraph, CrateId, FileId, SourceDatabase, SourceDatabaseExt, SourceRoot, SourceRootId,
8}; 8};
9use ra_prof::{memory_usage, profile, Bytes}; 9use ra_prof::{memory_usage, profile, Bytes};
10use ra_syntax::SourceFile; 10use ra_syntax::SourceFile;
diff --git a/crates/ra_ide_api/src/db.rs b/crates/ra_ide_api/src/db.rs
index ea0714add..bbf04bcf7 100644
--- a/crates/ra_ide_api/src/db.rs
+++ b/crates/ra_ide_api/src/db.rs
@@ -4,8 +4,10 @@ use std::sync::Arc;
4 4
5use ra_db::{ 5use ra_db::{
6 salsa::{self, Database, Durability}, 6 salsa::{self, Database, Durability},
7 Canceled, CheckCanceled, CrateId, FileId, SourceDatabase, SourceRootId, 7 Canceled, CheckCanceled, CrateId, FileId, FileLoader, FileLoaderDelegate, SourceDatabase,
8 SourceDatabaseExt, SourceRootId,
8}; 9};
10use relative_path::RelativePath;
9use rustc_hash::FxHashMap; 11use rustc_hash::FxHashMap;
10 12
11use crate::{ 13use crate::{
@@ -15,6 +17,7 @@ use crate::{
15 17
16#[salsa::database( 18#[salsa::database(
17 ra_db::SourceDatabaseStorage, 19 ra_db::SourceDatabaseStorage,
20 ra_db::SourceDatabaseExtStorage,
18 LineIndexDatabaseStorage, 21 LineIndexDatabaseStorage,
19 symbol_index::SymbolsDatabaseStorage, 22 symbol_index::SymbolsDatabaseStorage,
20 hir::db::InternDatabaseStorage, 23 hir::db::InternDatabaseStorage,
@@ -31,6 +34,22 @@ pub(crate) struct RootDatabase {
31 pub(crate) last_gc_check: crate::wasm_shims::Instant, 34 pub(crate) last_gc_check: crate::wasm_shims::Instant,
32} 35}
33 36
37impl FileLoader for RootDatabase {
38 fn file_text(&self, file_id: FileId) -> Arc<String> {
39 FileLoaderDelegate(self).file_text(file_id)
40 }
41 fn resolve_relative_path(
42 &self,
43 anchor: FileId,
44 relative_path: &RelativePath,
45 ) -> Option<FileId> {
46 FileLoaderDelegate(self).resolve_relative_path(anchor, relative_path)
47 }
48 fn relevant_crates(&self, file_id: FileId) -> Arc<Vec<CrateId>> {
49 FileLoaderDelegate(self).relevant_crates(file_id)
50 }
51}
52
34impl hir::debug::HirDebugHelper for RootDatabase { 53impl hir::debug::HirDebugHelper for RootDatabase {
35 fn crate_name(&self, krate: CrateId) -> Option<String> { 54 fn crate_name(&self, krate: CrateId) -> Option<String> {
36 self.debug_data.crate_names.get(&krate).cloned() 55 self.debug_data.crate_names.get(&krate).cloned()
@@ -104,7 +123,7 @@ pub(crate) trait LineIndexDatabase: ra_db::SourceDatabase + CheckCanceled {
104 fn line_index(&self, file_id: FileId) -> Arc<LineIndex>; 123 fn line_index(&self, file_id: FileId) -> Arc<LineIndex>;
105} 124}
106 125
107fn line_index(db: &impl ra_db::SourceDatabase, file_id: FileId) -> Arc<LineIndex> { 126fn line_index(db: &impl LineIndexDatabase, file_id: FileId) -> Arc<LineIndex> {
108 let text = db.file_text(file_id); 127 let text = db.file_text(file_id);
109 Arc::new(LineIndex::new(&*text)) 128 Arc::new(LineIndex::new(&*text))
110} 129}
diff --git a/crates/ra_ide_api/src/diagnostics.rs b/crates/ra_ide_api/src/diagnostics.rs
index 65f061443..8743a3a79 100644
--- a/crates/ra_ide_api/src/diagnostics.rs
+++ b/crates/ra_ide_api/src/diagnostics.rs
@@ -4,7 +4,7 @@ use std::cell::RefCell;
4 4
5use hir::diagnostics::{AstDiagnostic, Diagnostic as _, DiagnosticSink}; 5use hir::diagnostics::{AstDiagnostic, Diagnostic as _, DiagnosticSink};
6use itertools::Itertools; 6use itertools::Itertools;
7use ra_db::SourceDatabase; 7use ra_db::{SourceDatabase, SourceDatabaseExt};
8use ra_prof::profile; 8use ra_prof::profile;
9use ra_syntax::{ 9use ra_syntax::{
10 algo, 10 algo,
diff --git a/crates/ra_ide_api/src/lib.rs b/crates/ra_ide_api/src/lib.rs
index 2d92fe1c5..f7fd42f65 100644
--- a/crates/ra_ide_api/src/lib.rs
+++ b/crates/ra_ide_api/src/lib.rs
@@ -52,7 +52,7 @@ use std::sync::Arc;
52use ra_cfg::CfgOptions; 52use ra_cfg::CfgOptions;
53use ra_db::{ 53use ra_db::{
54 salsa::{self, ParallelDatabase}, 54 salsa::{self, ParallelDatabase},
55 CheckCanceled, SourceDatabase, 55 CheckCanceled, FileLoader, SourceDatabase,
56}; 56};
57use ra_syntax::{SourceFile, TextRange, TextUnit}; 57use ra_syntax::{SourceFile, TextRange, TextUnit};
58use ra_text_edit::TextEdit; 58use ra_text_edit::TextEdit;
@@ -289,10 +289,14 @@ impl AnalysisHost {
289 pub fn per_query_memory_usage(&mut self) -> Vec<(String, ra_prof::Bytes)> { 289 pub fn per_query_memory_usage(&mut self) -> Vec<(String, ra_prof::Bytes)> {
290 self.db.per_query_memory_usage() 290 self.db.per_query_memory_usage()
291 } 291 }
292 pub fn raw_database(&self) -> &(impl hir::db::HirDatabase + salsa::Database) { 292 pub fn raw_database(
293 &self,
294 ) -> &(impl hir::db::HirDatabase + salsa::Database + ra_db::SourceDatabaseExt) {
293 &self.db 295 &self.db
294 } 296 }
295 pub fn raw_database_mut(&mut self) -> &mut (impl hir::db::HirDatabase + salsa::Database) { 297 pub fn raw_database_mut(
298 &mut self,
299 ) -> &mut (impl hir::db::HirDatabase + salsa::Database + ra_db::SourceDatabaseExt) {
296 &mut self.db 300 &mut self.db
297 } 301 }
298} 302}
diff --git a/crates/ra_ide_api/src/references.rs b/crates/ra_ide_api/src/references.rs
index c95c47bf1..4247c6d90 100644
--- a/crates/ra_ide_api/src/references.rs
+++ b/crates/ra_ide_api/src/references.rs
@@ -1,7 +1,7 @@
1//! FIXME: write short doc here 1//! FIXME: write short doc here
2 2
3use hir::{Either, ModuleSource}; 3use hir::{Either, ModuleSource};
4use ra_db::SourceDatabase; 4use ra_db::{SourceDatabase, SourceDatabaseExt};
5use ra_syntax::{algo::find_node_at_offset, ast, AstNode, SourceFile, SyntaxNode}; 5use ra_syntax::{algo::find_node_at_offset, ast, AstNode, SourceFile, SyntaxNode};
6use relative_path::{RelativePath, RelativePathBuf}; 6use relative_path::{RelativePath, RelativePathBuf};
7 7
diff --git a/crates/ra_ide_api/src/symbol_index.rs b/crates/ra_ide_api/src/symbol_index.rs
index 797e9926f..5729eb5b3 100644
--- a/crates/ra_ide_api/src/symbol_index.rs
+++ b/crates/ra_ide_api/src/symbol_index.rs
@@ -29,7 +29,7 @@ use std::{
29use fst::{self, Streamer}; 29use fst::{self, Streamer};
30use ra_db::{ 30use ra_db::{
31 salsa::{self, ParallelDatabase}, 31 salsa::{self, ParallelDatabase},
32 SourceDatabase, SourceRootId, 32 SourceDatabaseExt, SourceRootId,
33}; 33};
34use ra_syntax::{ 34use ra_syntax::{
35 ast::{self, NameOwner}, 35 ast::{self, NameOwner},