diff options
Diffstat (limited to 'crates/base_db')
-rw-r--r-- | crates/base_db/src/lib.rs | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/crates/base_db/src/lib.rs b/crates/base_db/src/lib.rs index 71e85c6ac..37a8432bd 100644 --- a/crates/base_db/src/lib.rs +++ b/crates/base_db/src/lib.rs | |||
@@ -96,7 +96,7 @@ pub trait FileLoader { | |||
96 | /// `#[path = "C://no/way"]` | 96 | /// `#[path = "C://no/way"]` |
97 | fn resolve_path(&self, anchor: FileId, path: &str) -> Option<FileId>; | 97 | fn resolve_path(&self, anchor: FileId, path: &str) -> Option<FileId>; |
98 | fn relevant_crates(&self, file_id: FileId) -> Arc<FxHashSet<CrateId>>; | 98 | fn relevant_crates(&self, file_id: FileId) -> Arc<FxHashSet<CrateId>>; |
99 | fn list_some_random_files_todo(&self, anchor: FileId) -> Vec<(FileId, String)>; | 99 | fn possible_sudmobules(&self, module_file: FileId) -> Vec<(FileId, String)>; |
100 | } | 100 | } |
101 | 101 | ||
102 | /// Database which stores all significant input facts: source code and project | 102 | /// Database which stores all significant input facts: source code and project |
@@ -166,8 +166,25 @@ impl<T: SourceDatabaseExt> FileLoader for FileLoaderDelegate<&'_ T> { | |||
166 | self.0.source_root_crates(source_root) | 166 | self.0.source_root_crates(source_root) |
167 | } | 167 | } |
168 | 168 | ||
169 | fn list_some_random_files_todo(&self, anchor: FileId) -> Vec<(FileId, String)> { | 169 | fn possible_sudmobules(&self, module_file: FileId) -> Vec<(FileId, String)> { |
170 | self.source_root(anchor).file_set.list_some_random_files_todo(anchor) | 170 | fn possible_sudmobules_opt( |
171 | module_files: &FileSet, | ||
172 | module_file: FileId, | ||
173 | ) -> Option<Vec<(FileId, String)>> { | ||
174 | // TODO kb resolve path thinks that the input is a file... | ||
175 | let directory_with_module_file = module_files.resolve_path(module_file, "/../")?; | ||
176 | let directory_with_applicable_modules = | ||
177 | match module_files.file_name_and_extension(module_file)? { | ||
178 | ("mod", "rs") | ("lib", "rs") => Some(directory_with_module_file), | ||
179 | (directory_with_module_name, "rs") => module_files | ||
180 | .resolve_path(directory_with_module_file, directory_with_module_name), | ||
181 | _ => None, | ||
182 | }?; | ||
183 | Some(module_files.list_files(directory_with_applicable_modules)) | ||
184 | } | ||
185 | |||
186 | possible_sudmobules_opt(&self.source_root(module_file).file_set, module_file) | ||
187 | .unwrap_or_default() | ||
171 | } | 188 | } |
172 | } | 189 | } |
173 | 190 | ||