diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-10-14 14:26:42 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2019-10-14 14:26:42 +0100 |
commit | 8e3864fd580fb93e8ce92e4b4e6ac51050e54047 (patch) | |
tree | 7cc9565b1e81ec069297167e935d062b7dc4bc06 | |
parent | e182825170e346abb84240b84458b49b73783dca (diff) | |
parent | abf2179c0b606730acadc61451739baecfa33a5d (diff) |
Merge #2008
2008: Prepare SourceDatabase API for lazy file loading r=matklad a=matklad
Co-authored-by: Aleksey Kladov <[email protected]>
-rw-r--r-- | crates/ra_cli/src/analysis_bench.rs | 2 | ||||
-rw-r--r-- | crates/ra_cli/src/analysis_stats.rs | 2 | ||||
-rw-r--r-- | crates/ra_db/src/input.rs | 2 | ||||
-rw-r--r-- | crates/ra_db/src/lib.rs | 94 | ||||
-rw-r--r-- | crates/ra_hir/src/from_source.rs | 10 | ||||
-rw-r--r-- | crates/ra_hir/src/ids.rs | 35 | ||||
-rw-r--r-- | crates/ra_hir/src/mock.rs | 23 | ||||
-rw-r--r-- | crates/ra_hir/src/nameres/tests/incremental.rs | 2 | ||||
-rw-r--r-- | crates/ra_ide_api/src/change.rs | 2 | ||||
-rw-r--r-- | crates/ra_ide_api/src/db.rs | 21 | ||||
-rw-r--r-- | crates/ra_ide_api/src/diagnostics.rs | 2 | ||||
-rw-r--r-- | crates/ra_ide_api/src/lib.rs | 10 | ||||
-rw-r--r-- | crates/ra_ide_api/src/references.rs | 2 | ||||
-rw-r--r-- | crates/ra_ide_api/src/symbol_index.rs | 2 |
14 files changed, 121 insertions, 88 deletions
diff --git a/crates/ra_cli/src/analysis_bench.rs b/crates/ra_cli/src/analysis_bench.rs index 727f1e62b..8bbe5d9e8 100644 --- a/crates/ra_cli/src/analysis_bench.rs +++ b/crates/ra_cli/src/analysis_bench.rs | |||
@@ -8,7 +8,7 @@ use std::{ | |||
8 | 8 | ||
9 | use ra_db::{ | 9 | use ra_db::{ |
10 | salsa::{Database, Durability}, | 10 | salsa::{Database, Durability}, |
11 | FileId, SourceDatabase, | 11 | FileId, SourceDatabaseExt, |
12 | }; | 12 | }; |
13 | use ra_ide_api::{Analysis, AnalysisChange, AnalysisHost, FilePosition, LineCol}; | 13 | use ra_ide_api::{Analysis, AnalysisChange, AnalysisHost, FilePosition, LineCol}; |
14 | 14 | ||
diff --git a/crates/ra_cli/src/analysis_stats.rs b/crates/ra_cli/src/analysis_stats.rs index fe4f57dcd..35c867dce 100644 --- a/crates/ra_cli/src/analysis_stats.rs +++ b/crates/ra_cli/src/analysis_stats.rs | |||
@@ -2,7 +2,7 @@ | |||
2 | 2 | ||
3 | use std::{collections::HashSet, fmt::Write, path::Path, time::Instant}; | 3 | use std::{collections::HashSet, fmt::Write, path::Path, time::Instant}; |
4 | 4 | ||
5 | use ra_db::SourceDatabase; | 5 | use ra_db::SourceDatabaseExt; |
6 | use ra_hir::{AssocItem, Crate, HasBodySource, HasSource, HirDisplay, ModuleDef, Ty, TypeWalk}; | 6 | use ra_hir::{AssocItem, Crate, HasBodySource, HasSource, HirDisplay, ModuleDef, Ty, TypeWalk}; |
7 | use ra_syntax::AstNode; | 7 | use ra_syntax::AstNode; |
8 | 8 | ||
diff --git a/crates/ra_db/src/input.rs b/crates/ra_db/src/input.rs index cae51b02c..eafa95921 100644 --- a/crates/ra_db/src/input.rs +++ b/crates/ra_db/src/input.rs | |||
@@ -57,7 +57,7 @@ impl SourceRoot { | |||
57 | pub fn walk(&self) -> impl Iterator<Item = FileId> + '_ { | 57 | pub fn walk(&self) -> impl Iterator<Item = FileId> + '_ { |
58 | self.files.values().copied() | 58 | self.files.values().copied() |
59 | } | 59 | } |
60 | pub(crate) fn file_by_relative_path(&self, path: &RelativePath) -> Option<FileId> { | 60 | pub fn file_by_relative_path(&self, path: &RelativePath) -> Option<FileId> { |
61 | self.files.get(path).copied() | 61 | self.files.get(path).copied() |
62 | } | 62 | } |
63 | } | 63 | } |
diff --git a/crates/ra_db/src/lib.rs b/crates/ra_db/src/lib.rs index 4d3a9c036..fc5d6d396 100644 --- a/crates/ra_db/src/lib.rs +++ b/crates/ra_db/src/lib.rs | |||
@@ -64,21 +64,39 @@ pub struct FileRange { | |||
64 | 64 | ||
65 | pub const DEFAULT_LRU_CAP: usize = 128; | 65 | pub const DEFAULT_LRU_CAP: usize = 128; |
66 | 66 | ||
67 | /// Database which stores all significant input facts: source code and project | 67 | pub trait FileLoader { |
68 | /// model. Everything else in rust-analyzer is derived from these queries. | ||
69 | #[salsa::query_group(SourceDatabaseStorage)] | ||
70 | pub trait SourceDatabase: CheckCanceled + std::fmt::Debug { | ||
71 | /// Text of the file. | 68 | /// Text of the file. |
72 | #[salsa::input] | ||
73 | fn file_text(&self, file_id: FileId) -> Arc<String>; | 69 | fn file_text(&self, file_id: FileId) -> Arc<String>; |
74 | |||
75 | #[salsa::transparent] | ||
76 | fn resolve_relative_path(&self, anchor: FileId, relative_path: &RelativePath) | 70 | fn resolve_relative_path(&self, anchor: FileId, relative_path: &RelativePath) |
77 | -> Option<FileId>; | 71 | -> Option<FileId>; |
72 | fn relevant_crates(&self, file_id: FileId) -> Arc<Vec<CrateId>>; | ||
73 | } | ||
78 | 74 | ||
75 | /// Database which stores all significant input facts: source code and project | ||
76 | /// model. Everything else in rust-analyzer is derived from these queries. | ||
77 | #[salsa::query_group(SourceDatabaseStorage)] | ||
78 | pub trait SourceDatabase: CheckCanceled + FileLoader + std::fmt::Debug { | ||
79 | // Parses the file into the syntax tree. | 79 | // Parses the file into the syntax tree. |
80 | #[salsa::invoke(parse_query)] | 80 | #[salsa::invoke(parse_query)] |
81 | fn parse(&self, file_id: FileId) -> Parse<ast::SourceFile>; | 81 | fn parse(&self, file_id: FileId) -> Parse<ast::SourceFile>; |
82 | |||
83 | /// The crate graph. | ||
84 | #[salsa::input] | ||
85 | fn crate_graph(&self) -> Arc<CrateGraph>; | ||
86 | } | ||
87 | |||
88 | fn parse_query(db: &impl SourceDatabase, file_id: FileId) -> Parse<ast::SourceFile> { | ||
89 | let _p = profile("parse_query"); | ||
90 | let text = db.file_text(file_id); | ||
91 | SourceFile::parse(&*text) | ||
92 | } | ||
93 | |||
94 | /// We don't want to give HIR knowledge of source roots, hence we extract these | ||
95 | /// methods into a separate DB. | ||
96 | #[salsa::query_group(SourceDatabaseExtStorage)] | ||
97 | pub trait SourceDatabaseExt: SourceDatabase { | ||
98 | #[salsa::input] | ||
99 | fn file_text(&self, file_id: FileId) -> Arc<String>; | ||
82 | /// Path to a file, relative to the root of its source root. | 100 | /// Path to a file, relative to the root of its source root. |
83 | #[salsa::input] | 101 | #[salsa::input] |
84 | fn file_relative_path(&self, file_id: FileId) -> RelativePathBuf; | 102 | fn file_relative_path(&self, file_id: FileId) -> RelativePathBuf; |
@@ -88,40 +106,48 @@ pub trait SourceDatabase: CheckCanceled + std::fmt::Debug { | |||
88 | /// Contents of the source root. | 106 | /// Contents of the source root. |
89 | #[salsa::input] | 107 | #[salsa::input] |
90 | fn source_root(&self, id: SourceRootId) -> Arc<SourceRoot>; | 108 | fn source_root(&self, id: SourceRootId) -> Arc<SourceRoot>; |
91 | fn source_root_crates(&self, id: SourceRootId) -> Arc<Vec<CrateId>>; | ||
92 | /// The crate graph. | ||
93 | #[salsa::input] | ||
94 | fn crate_graph(&self) -> Arc<CrateGraph>; | ||
95 | } | ||
96 | 109 | ||
97 | fn resolve_relative_path( | 110 | fn source_root_crates(&self, id: SourceRootId) -> Arc<Vec<CrateId>>; |
98 | db: &impl SourceDatabase, | ||
99 | anchor: FileId, | ||
100 | relative_path: &RelativePath, | ||
101 | ) -> Option<FileId> { | ||
102 | let path = { | ||
103 | let mut path = db.file_relative_path(anchor); | ||
104 | // Workaround for relative path API: turn `lib.rs` into ``. | ||
105 | if !path.pop() { | ||
106 | path = RelativePathBuf::default(); | ||
107 | } | ||
108 | path.push(relative_path); | ||
109 | path.normalize() | ||
110 | }; | ||
111 | let source_root = db.file_source_root(anchor); | ||
112 | let source_root = db.source_root(source_root); | ||
113 | source_root.file_by_relative_path(&path) | ||
114 | } | 111 | } |
115 | 112 | ||
116 | fn source_root_crates(db: &impl SourceDatabase, id: SourceRootId) -> Arc<Vec<CrateId>> { | 113 | fn source_root_crates( |
114 | db: &(impl SourceDatabaseExt + SourceDatabase), | ||
115 | id: SourceRootId, | ||
116 | ) -> Arc<Vec<CrateId>> { | ||
117 | let root = db.source_root(id); | 117 | let root = db.source_root(id); |
118 | let graph = db.crate_graph(); | 118 | let graph = db.crate_graph(); |
119 | let res = root.walk().filter_map(|it| graph.crate_id_for_crate_root(it)).collect::<Vec<_>>(); | 119 | let res = root.walk().filter_map(|it| graph.crate_id_for_crate_root(it)).collect::<Vec<_>>(); |
120 | Arc::new(res) | 120 | Arc::new(res) |
121 | } | 121 | } |
122 | 122 | ||
123 | fn parse_query(db: &impl SourceDatabase, file_id: FileId) -> Parse<ast::SourceFile> { | 123 | /// Silly workaround for cyclic deps between the traits |
124 | let _p = profile("parse_query"); | 124 | pub struct FileLoaderDelegate<T>(pub T); |
125 | let text = db.file_text(file_id); | 125 | |
126 | SourceFile::parse(&*text) | 126 | impl<T: SourceDatabaseExt> FileLoader for FileLoaderDelegate<&'_ T> { |
127 | fn file_text(&self, file_id: FileId) -> Arc<String> { | ||
128 | SourceDatabaseExt::file_text(self.0, file_id) | ||
129 | } | ||
130 | fn resolve_relative_path( | ||
131 | &self, | ||
132 | anchor: FileId, | ||
133 | relative_path: &RelativePath, | ||
134 | ) -> Option<FileId> { | ||
135 | let path = { | ||
136 | let mut path = self.0.file_relative_path(anchor); | ||
137 | // Workaround for relative path API: turn `lib.rs` into ``. | ||
138 | if !path.pop() { | ||
139 | path = RelativePathBuf::default(); | ||
140 | } | ||
141 | path.push(relative_path); | ||
142 | path.normalize() | ||
143 | }; | ||
144 | let source_root = self.0.file_source_root(anchor); | ||
145 | let source_root = self.0.source_root(source_root); | ||
146 | source_root.file_by_relative_path(&path) | ||
147 | } | ||
148 | |||
149 | fn relevant_crates(&self, file_id: FileId) -> Arc<Vec<CrateId>> { | ||
150 | let source_root = self.0.file_source_root(file_id); | ||
151 | self.0.source_root_crates(source_root) | ||
152 | } | ||
127 | } | 153 | } |
diff --git a/crates/ra_hir/src/from_source.rs b/crates/ra_hir/src/from_source.rs index a012f33f7..f80d8eb5f 100644 --- a/crates/ra_hir/src/from_source.rs +++ b/crates/ra_hir/src/from_source.rs | |||
@@ -189,14 +189,14 @@ impl Module { | |||
189 | ModuleSource::SourceFile(_) => None, | 189 | ModuleSource::SourceFile(_) => None, |
190 | }; | 190 | }; |
191 | 191 | ||
192 | let source_root_id = db.file_source_root(src.file_id.original_file(db)); | 192 | db.relevant_crates(src.file_id.original_file(db)) |
193 | db.source_root_crates(source_root_id).iter().map(|&crate_id| Crate { crate_id }).find_map( | 193 | .iter() |
194 | |krate| { | 194 | .map(|&crate_id| Crate { crate_id }) |
195 | .find_map(|krate| { | ||
195 | let def_map = db.crate_def_map(krate); | 196 | let def_map = db.crate_def_map(krate); |
196 | let module_id = def_map.find_module_by_source(src.file_id, decl_id)?; | 197 | let module_id = def_map.find_module_by_source(src.file_id, decl_id)?; |
197 | Some(Module { krate, module_id }) | 198 | Some(Module { krate, module_id }) |
198 | }, | 199 | }) |
199 | ) | ||
200 | } | 200 | } |
201 | } | 201 | } |
202 | 202 | ||
diff --git a/crates/ra_hir/src/ids.rs b/crates/ra_hir/src/ids.rs index 85b022744..499dcafea 100644 --- a/crates/ra_hir/src/ids.rs +++ b/crates/ra_hir/src/ids.rs | |||
@@ -85,11 +85,7 @@ impl HirFileId { | |||
85 | // Note: | 85 | // Note: |
86 | // The final goal we would like to make all parse_macro success, | 86 | // The final goal we would like to make all parse_macro success, |
87 | // such that the following log will not call anyway. | 87 | // such that the following log will not call anyway. |
88 | log::warn!( | 88 | log::warn!("fail on macro_parse: (reason: {})", err,); |
89 | "fail on macro_parse: (reason: {}) {}", | ||
90 | err, | ||
91 | macro_call_id.debug_dump(db) | ||
92 | ); | ||
93 | }) | 89 | }) |
94 | .ok()?; | 90 | .ok()?; |
95 | match macro_file.macro_file_kind { | 91 | match macro_file.macro_file_kind { |
@@ -367,35 +363,6 @@ impl AstItemDef<ast::TypeAliasDef> for TypeAliasId { | |||
367 | } | 363 | } |
368 | } | 364 | } |
369 | 365 | ||
370 | impl MacroCallId { | ||
371 | pub fn debug_dump(self, db: &impl AstDatabase) -> String { | ||
372 | let loc = self.loc(db); | ||
373 | let node = loc.ast_id.to_node(db); | ||
374 | let syntax_str = { | ||
375 | let mut res = String::new(); | ||
376 | node.syntax().text().for_each_chunk(|chunk| { | ||
377 | if !res.is_empty() { | ||
378 | res.push(' ') | ||
379 | } | ||
380 | res.push_str(chunk) | ||
381 | }); | ||
382 | res | ||
383 | }; | ||
384 | |||
385 | // dump the file name | ||
386 | let file_id: HirFileId = self.loc(db).ast_id.file_id(); | ||
387 | let original = file_id.original_file(db); | ||
388 | let macro_rules = db.macro_def(loc.def); | ||
389 | |||
390 | format!( | ||
391 | "macro call [file: {:?}] : {}\nhas rules: {}", | ||
392 | db.file_relative_path(original), | ||
393 | syntax_str, | ||
394 | macro_rules.is_some() | ||
395 | ) | ||
396 | } | ||
397 | } | ||
398 | |||
399 | /// This exists just for Chalk, because Chalk just has a single `StructId` where | 366 | /// This exists just for Chalk, because Chalk just has a single `StructId` where |
400 | /// we have different kinds of ADTs, primitive types and special type | 367 | /// we have different kinds of ADTs, primitive types and special type |
401 | /// constructors like tuples and function pointers. | 368 | /// constructors like tuples and function pointers. |
diff --git a/crates/ra_hir/src/mock.rs b/crates/ra_hir/src/mock.rs index 827424983..0b278deb3 100644 --- a/crates/ra_hir/src/mock.rs +++ b/crates/ra_hir/src/mock.rs | |||
@@ -5,10 +5,10 @@ use std::{panic, sync::Arc}; | |||
5 | use parking_lot::Mutex; | 5 | use parking_lot::Mutex; |
6 | use ra_cfg::CfgOptions; | 6 | use ra_cfg::CfgOptions; |
7 | use ra_db::{ | 7 | use ra_db::{ |
8 | salsa, CrateGraph, CrateId, Edition, FileId, FilePosition, SourceDatabase, SourceRoot, | 8 | salsa, CrateGraph, CrateId, Edition, FileId, FileLoader, FileLoaderDelegate, FilePosition, |
9 | SourceRootId, | 9 | SourceDatabase, SourceDatabaseExt, SourceRoot, SourceRootId, |
10 | }; | 10 | }; |
11 | use relative_path::RelativePathBuf; | 11 | use relative_path::{RelativePath, RelativePathBuf}; |
12 | use rustc_hash::FxHashMap; | 12 | use rustc_hash::FxHashMap; |
13 | use test_utils::{extract_offset, parse_fixture, CURSOR_MARKER}; | 13 | use test_utils::{extract_offset, parse_fixture, CURSOR_MARKER}; |
14 | 14 | ||
@@ -17,6 +17,7 @@ use crate::{db, debug::HirDebugHelper, diagnostics::DiagnosticSink}; | |||
17 | pub const WORKSPACE: SourceRootId = SourceRootId(0); | 17 | pub const WORKSPACE: SourceRootId = SourceRootId(0); |
18 | 18 | ||
19 | #[salsa::database( | 19 | #[salsa::database( |
20 | ra_db::SourceDatabaseExtStorage, | ||
20 | ra_db::SourceDatabaseStorage, | 21 | ra_db::SourceDatabaseStorage, |
21 | db::InternDatabaseStorage, | 22 | db::InternDatabaseStorage, |
22 | db::AstDatabaseStorage, | 23 | db::AstDatabaseStorage, |
@@ -34,6 +35,22 @@ pub struct MockDatabase { | |||
34 | 35 | ||
35 | impl panic::RefUnwindSafe for MockDatabase {} | 36 | impl panic::RefUnwindSafe for MockDatabase {} |
36 | 37 | ||
38 | impl FileLoader for MockDatabase { | ||
39 | fn file_text(&self, file_id: FileId) -> Arc<String> { | ||
40 | FileLoaderDelegate(self).file_text(file_id) | ||
41 | } | ||
42 | fn resolve_relative_path( | ||
43 | &self, | ||
44 | anchor: FileId, | ||
45 | relative_path: &RelativePath, | ||
46 | ) -> Option<FileId> { | ||
47 | FileLoaderDelegate(self).resolve_relative_path(anchor, relative_path) | ||
48 | } | ||
49 | fn relevant_crates(&self, file_id: FileId) -> Arc<Vec<CrateId>> { | ||
50 | FileLoaderDelegate(self).relevant_crates(file_id) | ||
51 | } | ||
52 | } | ||
53 | |||
37 | impl HirDebugHelper for MockDatabase { | 54 | impl HirDebugHelper for MockDatabase { |
38 | fn crate_name(&self, krate: CrateId) -> Option<String> { | 55 | fn crate_name(&self, krate: CrateId) -> Option<String> { |
39 | self.crate_names.get(&krate).cloned() | 56 | self.crate_names.get(&krate).cloned() |
diff --git a/crates/ra_hir/src/nameres/tests/incremental.rs b/crates/ra_hir/src/nameres/tests/incremental.rs index c41862a0b..af9c39760 100644 --- a/crates/ra_hir/src/nameres/tests/incremental.rs +++ b/crates/ra_hir/src/nameres/tests/incremental.rs | |||
@@ -2,7 +2,7 @@ use super::*; | |||
2 | 2 | ||
3 | use std::sync::Arc; | 3 | use std::sync::Arc; |
4 | 4 | ||
5 | use ra_db::SourceDatabase; | 5 | use ra_db::{SourceDatabase, SourceDatabaseExt}; |
6 | 6 | ||
7 | fn check_def_map_is_not_recomputed(initial: &str, file_change: &str) { | 7 | fn check_def_map_is_not_recomputed(initial: &str, file_change: &str) { |
8 | let (mut db, pos) = MockDatabase::with_position(initial); | 8 | let (mut db, pos) = MockDatabase::with_position(initial); |
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 | ||
5 | use ra_db::{ | 5 | use 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 | }; |
9 | use ra_prof::{memory_usage, profile, Bytes}; | 9 | use ra_prof::{memory_usage, profile, Bytes}; |
10 | use ra_syntax::SourceFile; | 10 | use ra_syntax::SourceFile; |
diff --git a/crates/ra_ide_api/src/db.rs b/crates/ra_ide_api/src/db.rs index f9ee13573..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 | ||
5 | use ra_db::{ | 5 | use 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 | }; |
10 | use relative_path::RelativePath; | ||
9 | use rustc_hash::FxHashMap; | 11 | use rustc_hash::FxHashMap; |
10 | 12 | ||
11 | use crate::{ | 13 | use 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 | ||
37 | impl 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 | |||
34 | impl hir::debug::HirDebugHelper for RootDatabase { | 53 | impl 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() |
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 | ||
5 | use hir::diagnostics::{AstDiagnostic, Diagnostic as _, DiagnosticSink}; | 5 | use hir::diagnostics::{AstDiagnostic, Diagnostic as _, DiagnosticSink}; |
6 | use itertools::Itertools; | 6 | use itertools::Itertools; |
7 | use ra_db::SourceDatabase; | 7 | use ra_db::{SourceDatabase, SourceDatabaseExt}; |
8 | use ra_prof::profile; | 8 | use ra_prof::profile; |
9 | use ra_syntax::{ | 9 | use 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; | |||
52 | use ra_cfg::CfgOptions; | 52 | use ra_cfg::CfgOptions; |
53 | use ra_db::{ | 53 | use ra_db::{ |
54 | salsa::{self, ParallelDatabase}, | 54 | salsa::{self, ParallelDatabase}, |
55 | CheckCanceled, SourceDatabase, | 55 | CheckCanceled, FileLoader, SourceDatabase, |
56 | }; | 56 | }; |
57 | use ra_syntax::{SourceFile, TextRange, TextUnit}; | 57 | use ra_syntax::{SourceFile, TextRange, TextUnit}; |
58 | use ra_text_edit::TextEdit; | 58 | use 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 | ||
3 | use hir::{Either, ModuleSource}; | 3 | use hir::{Either, ModuleSource}; |
4 | use ra_db::SourceDatabase; | 4 | use ra_db::{SourceDatabase, SourceDatabaseExt}; |
5 | use ra_syntax::{algo::find_node_at_offset, ast, AstNode, SourceFile, SyntaxNode}; | 5 | use ra_syntax::{algo::find_node_at_offset, ast, AstNode, SourceFile, SyntaxNode}; |
6 | use relative_path::{RelativePath, RelativePathBuf}; | 6 | use 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::{ | |||
29 | use fst::{self, Streamer}; | 29 | use fst::{self, Streamer}; |
30 | use ra_db::{ | 30 | use ra_db::{ |
31 | salsa::{self, ParallelDatabase}, | 31 | salsa::{self, ParallelDatabase}, |
32 | SourceDatabase, SourceRootId, | 32 | SourceDatabaseExt, SourceRootId, |
33 | }; | 33 | }; |
34 | use ra_syntax::{ | 34 | use ra_syntax::{ |
35 | ast::{self, NameOwner}, | 35 | ast::{self, NameOwner}, |