aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_db/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_db/src/lib.rs')
-rw-r--r--crates/ra_db/src/lib.rs26
1 files changed, 13 insertions, 13 deletions
diff --git a/crates/ra_db/src/lib.rs b/crates/ra_db/src/lib.rs
index fd4280de2..2e63cb46e 100644
--- a/crates/ra_db/src/lib.rs
+++ b/crates/ra_db/src/lib.rs
@@ -89,8 +89,7 @@ pub const DEFAULT_LRU_CAP: usize = 128;
89pub trait FileLoader { 89pub trait FileLoader {
90 /// Text of the file. 90 /// Text of the file.
91 fn file_text(&self, file_id: FileId) -> Arc<String>; 91 fn file_text(&self, file_id: FileId) -> Arc<String>;
92 fn resolve_relative_path(&self, anchor: FileId, relative_path: &RelativePath) 92 fn resolve_path(&self, anchor: FileId, path: &str) -> Option<FileId>;
93 -> Option<FileId>;
94 fn relevant_crates(&self, file_id: FileId) -> Arc<Vec<CrateId>>; 93 fn relevant_crates(&self, file_id: FileId) -> Arc<Vec<CrateId>>;
95 94
96 fn resolve_extern_path( 95 fn resolve_extern_path(
@@ -155,20 +154,21 @@ impl<T: SourceDatabaseExt> FileLoader for FileLoaderDelegate<&'_ T> {
155 fn file_text(&self, file_id: FileId) -> Arc<String> { 154 fn file_text(&self, file_id: FileId) -> Arc<String> {
156 SourceDatabaseExt::file_text(self.0, file_id) 155 SourceDatabaseExt::file_text(self.0, file_id)
157 } 156 }
158 fn resolve_relative_path( 157 /// Note that we intentionally accept a `&str` and not a `&Path` here. This
159 &self, 158 /// method exists to handle `#[path = "/some/path.rs"] mod foo;` and such,
160 anchor: FileId, 159 /// so the input is guaranteed to be utf-8 string. We might introduce
161 relative_path: &RelativePath, 160 /// `struct StrPath(str)` for clarity some day, but it's a bit messy, so we
162 ) -> Option<FileId> { 161 /// get by with a `&str` for the time being.
163 let path = { 162 fn resolve_path(&self, anchor: FileId, path: &str) -> Option<FileId> {
164 let mut path = self.0.file_relative_path(anchor); 163 let rel_path = {
165 assert!(path.pop()); 164 let mut rel_path = self.0.file_relative_path(anchor);
166 path.push(relative_path); 165 assert!(rel_path.pop());
167 path.normalize() 166 rel_path.push(path);
167 rel_path.normalize()
168 }; 168 };
169 let source_root = self.0.file_source_root(anchor); 169 let source_root = self.0.file_source_root(anchor);
170 let source_root = self.0.source_root(source_root); 170 let source_root = self.0.source_root(source_root);
171 source_root.file_by_relative_path(&path) 171 source_root.file_by_relative_path(&rel_path)
172 } 172 }
173 173
174 fn relevant_crates(&self, file_id: FileId) -> Arc<Vec<CrateId>> { 174 fn relevant_crates(&self, file_id: FileId) -> Arc<Vec<CrateId>> {