aboutsummaryrefslogtreecommitdiff
path: root/crates/base_db
diff options
context:
space:
mode:
authorKirill Bulatov <[email protected]>2020-09-04 00:25:00 +0100
committerKirill Bulatov <[email protected]>2020-09-09 23:42:20 +0100
commit8aa740dab46f138cacdf6391d46c87d6df810161 (patch)
tree09e2067cc9480dd500fdd648123ae9076ae0d4d8 /crates/base_db
parent0de71f7bc9482c9d1ef7e9d36ec5d6c5fd378781 (diff)
Happy path implemented
Diffstat (limited to 'crates/base_db')
-rw-r--r--crates/base_db/src/lib.rs16
1 files changed, 12 insertions, 4 deletions
diff --git a/crates/base_db/src/lib.rs b/crates/base_db/src/lib.rs
index 1bc4690c9..3e0b6637d 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 possible_sudmobules(&self, module_file: FileId) -> Vec<(FileId, String)>; 99 fn possible_sudmobule_names(&self, module_file: FileId) -> Vec<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,11 +166,11 @@ 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 possible_sudmobules(&self, module_file: FileId) -> Vec<(FileId, String)> { 169 fn possible_sudmobule_names(&self, module_file: FileId) -> Vec<String> {
170 fn possible_sudmobules_opt( 170 fn possible_sudmobules_opt(
171 module_files: &FileSet, 171 module_files: &FileSet,
172 module_file: FileId, 172 module_file: FileId,
173 ) -> Option<Vec<(FileId, String)>> { 173 ) -> Option<Vec<FileId>> {
174 match module_files.file_name_and_extension(module_file)? { 174 match module_files.file_name_and_extension(module_file)? {
175 ("mod", Some("rs")) | ("lib", Some("rs")) => { 175 ("mod", Some("rs")) | ("lib", Some("rs")) => {
176 module_files.list_files(module_file, None) 176 module_files.list_files(module_file, None)
@@ -181,8 +181,16 @@ impl<T: SourceDatabaseExt> FileLoader for FileLoaderDelegate<&'_ T> {
181 } 181 }
182 } 182 }
183 183
184 possible_sudmobules_opt(&self.source_root(module_file).file_set, module_file) 184 let module_files = &self.source_root(module_file).file_set;
185 possible_sudmobules_opt(module_files, module_file)
185 .unwrap_or_default() 186 .unwrap_or_default()
187 .into_iter()
188 .filter_map(|submodule_file| module_files.file_name_and_extension(submodule_file))
189 .map(|(file_name, extension)| match extension {
190 Some(extension) => format!("{}.{}", file_name, extension),
191 None => file_name.to_owned(),
192 })
193 .collect()
186 } 194 }
187} 195}
188 196