diff options
Diffstat (limited to 'crates/ra_db/src/lib.rs')
-rw-r--r-- | crates/ra_db/src/lib.rs | 28 |
1 files changed, 6 insertions, 22 deletions
diff --git a/crates/ra_db/src/lib.rs b/crates/ra_db/src/lib.rs index 80ddb6058..875290259 100644 --- a/crates/ra_db/src/lib.rs +++ b/crates/ra_db/src/lib.rs | |||
@@ -12,12 +12,13 @@ use rustc_hash::FxHashSet; | |||
12 | pub use crate::{ | 12 | pub use crate::{ |
13 | cancellation::Canceled, | 13 | cancellation::Canceled, |
14 | input::{ | 14 | input::{ |
15 | CrateData, CrateGraph, CrateId, CrateName, Dependency, Edition, Env, ExternSource, | 15 | CrateData, CrateGraph, CrateId, CrateName, Dependency, Edition, Env, FileId, ProcMacroId, |
16 | ExternSourceId, FileId, ProcMacroId, SourceRoot, SourceRootId, | 16 | SourceRoot, SourceRootId, |
17 | }, | 17 | }, |
18 | }; | 18 | }; |
19 | pub use relative_path::{RelativePath, RelativePathBuf}; | 19 | pub use relative_path::{RelativePath, RelativePathBuf}; |
20 | pub use salsa; | 20 | pub use salsa; |
21 | pub use vfs::{file_set::FileSet, AbsPathBuf, VfsPath}; | ||
21 | 22 | ||
22 | #[macro_export] | 23 | #[macro_export] |
23 | macro_rules! impl_intern_key { | 24 | macro_rules! impl_intern_key { |
@@ -125,8 +126,6 @@ pub trait SourceDatabaseExt: SourceDatabase { | |||
125 | #[salsa::input] | 126 | #[salsa::input] |
126 | fn file_text(&self, file_id: FileId) -> Arc<String>; | 127 | fn file_text(&self, file_id: FileId) -> Arc<String>; |
127 | /// Path to a file, relative to the root of its source root. | 128 | /// Path to a file, relative to the root of its source root. |
128 | #[salsa::input] | ||
129 | fn file_relative_path(&self, file_id: FileId) -> RelativePathBuf; | ||
130 | /// Source root of the file. | 129 | /// Source root of the file. |
131 | #[salsa::input] | 130 | #[salsa::input] |
132 | fn file_source_root(&self, file_id: FileId) -> SourceRootId; | 131 | fn file_source_root(&self, file_id: FileId) -> SourceRootId; |
@@ -161,24 +160,9 @@ impl<T: SourceDatabaseExt> FileLoader for FileLoaderDelegate<&'_ T> { | |||
161 | } | 160 | } |
162 | fn resolve_path(&self, anchor: FileId, path: &str) -> Option<FileId> { | 161 | fn resolve_path(&self, anchor: FileId, path: &str) -> Option<FileId> { |
163 | // FIXME: this *somehow* should be platform agnostic... | 162 | // FIXME: this *somehow* should be platform agnostic... |
164 | if std::path::Path::new(path).is_absolute() { | 163 | let source_root = self.0.file_source_root(anchor); |
165 | let krate = *self.relevant_crates(anchor).iter().next()?; | 164 | let source_root = self.0.source_root(source_root); |
166 | let (extern_source_id, relative_file) = | 165 | source_root.file_set.resolve_path(anchor, path) |
167 | self.0.crate_graph()[krate].extern_source.extern_path(path.as_ref())?; | ||
168 | |||
169 | let source_root = self.0.source_root(SourceRootId(extern_source_id.0)); | ||
170 | source_root.file_by_relative_path(&relative_file) | ||
171 | } else { | ||
172 | let rel_path = { | ||
173 | let mut rel_path = self.0.file_relative_path(anchor); | ||
174 | assert!(rel_path.pop()); | ||
175 | rel_path.push(path); | ||
176 | rel_path.normalize() | ||
177 | }; | ||
178 | let source_root = self.0.file_source_root(anchor); | ||
179 | let source_root = self.0.source_root(source_root); | ||
180 | source_root.file_by_relative_path(&rel_path) | ||
181 | } | ||
182 | } | 166 | } |
183 | 167 | ||
184 | fn relevant_crates(&self, file_id: FileId) -> Arc<FxHashSet<CrateId>> { | 168 | fn relevant_crates(&self, file_id: FileId) -> Arc<FxHashSet<CrateId>> { |