diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-12-09 16:07:33 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2020-12-09 16:07:33 +0000 |
commit | 99118eeccdf6564876bbe6ec0672b04ffcbe3442 (patch) | |
tree | 08f0fd7d99ad22a3d1db782482b66548e99ba8b2 /crates/base_db | |
parent | 42be522c80cf0cc2d49b60f3c1d66afdc51fcbbb (diff) | |
parent | 6e24321e4579d25686982002ed18f321db23cb9f (diff) |
Merge #6784
6784: Introduce anchored_path r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/base_db')
-rw-r--r-- | crates/base_db/src/lib.rs | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/crates/base_db/src/lib.rs b/crates/base_db/src/lib.rs index 5571af495..595f28ada 100644 --- a/crates/base_db/src/lib.rs +++ b/crates/base_db/src/lib.rs | |||
@@ -18,7 +18,7 @@ pub use crate::{ | |||
18 | }, | 18 | }, |
19 | }; | 19 | }; |
20 | pub use salsa; | 20 | pub use salsa; |
21 | pub use vfs::{file_set::FileSet, FileId, VfsPath}; | 21 | pub use vfs::{file_set::FileSet, AnchoredPath, AnchoredPathBuf, FileId, VfsPath}; |
22 | 22 | ||
23 | #[macro_export] | 23 | #[macro_export] |
24 | macro_rules! impl_intern_key { | 24 | macro_rules! impl_intern_key { |
@@ -91,12 +91,7 @@ pub const DEFAULT_LRU_CAP: usize = 128; | |||
91 | pub trait FileLoader { | 91 | pub trait FileLoader { |
92 | /// Text of the file. | 92 | /// Text of the file. |
93 | fn file_text(&self, file_id: FileId) -> Arc<String>; | 93 | fn file_text(&self, file_id: FileId) -> Arc<String>; |
94 | /// Note that we intentionally accept a `&str` and not a `&Path` here. This | 94 | fn resolve_path(&self, path: AnchoredPath) -> Option<FileId>; |
95 | /// method exists to handle `#[path = "/some/path.rs"] mod foo;` and such, | ||
96 | /// so the input is guaranteed to be utf-8 string. One might be tempted to | ||
97 | /// introduce some kind of "utf-8 path with / separators", but that's a bad idea. Behold | ||
98 | /// `#[path = "C://no/way"]` | ||
99 | fn resolve_path(&self, anchor: FileId, path: &str) -> Option<FileId>; | ||
100 | fn relevant_crates(&self, file_id: FileId) -> Arc<FxHashSet<CrateId>>; | 95 | fn relevant_crates(&self, file_id: FileId) -> Arc<FxHashSet<CrateId>>; |
101 | } | 96 | } |
102 | 97 | ||
@@ -155,11 +150,11 @@ impl<T: SourceDatabaseExt> FileLoader for FileLoaderDelegate<&'_ T> { | |||
155 | fn file_text(&self, file_id: FileId) -> Arc<String> { | 150 | fn file_text(&self, file_id: FileId) -> Arc<String> { |
156 | SourceDatabaseExt::file_text(self.0, file_id) | 151 | SourceDatabaseExt::file_text(self.0, file_id) |
157 | } | 152 | } |
158 | fn resolve_path(&self, anchor: FileId, path: &str) -> Option<FileId> { | 153 | fn resolve_path(&self, path: AnchoredPath) -> Option<FileId> { |
159 | // FIXME: this *somehow* should be platform agnostic... | 154 | // FIXME: this *somehow* should be platform agnostic... |
160 | let source_root = self.0.file_source_root(anchor); | 155 | let source_root = self.0.file_source_root(path.anchor); |
161 | let source_root = self.0.source_root(source_root); | 156 | let source_root = self.0.source_root(source_root); |
162 | source_root.file_set.resolve_path(anchor, path) | 157 | source_root.file_set.resolve_path(path) |
163 | } | 158 | } |
164 | 159 | ||
165 | fn relevant_crates(&self, file_id: FileId) -> Arc<FxHashSet<CrateId>> { | 160 | fn relevant_crates(&self, file_id: FileId) -> Arc<FxHashSet<CrateId>> { |