aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorKirill Bulatov <[email protected]>2020-09-04 13:13:31 +0100
committerKirill Bulatov <[email protected]>2020-09-09 23:42:20 +0100
commit486c5c3285682408b125613475a34a0bc9a2c097 (patch)
tree8928b836c589c783ad1f426218a134292926cffe /crates
parent897a4c702e3d6fa9156ea0bc34af9d397fae3440 (diff)
Exclude special files
Diffstat (limited to 'crates')
-rw-r--r--crates/base_db/src/lib.rs5
-rw-r--r--crates/ide/src/completion/completion_context.rs3
2 files changed, 5 insertions, 3 deletions
diff --git a/crates/base_db/src/lib.rs b/crates/base_db/src/lib.rs
index 55ef9fc24..c72e254f4 100644
--- a/crates/base_db/src/lib.rs
+++ b/crates/base_db/src/lib.rs
@@ -172,17 +172,22 @@ impl<T: SourceDatabaseExt> FileLoader for FileLoaderDelegate<&'_ T> {
172 Some(("mod", Some("rs"))) | Some(("lib", Some("rs"))) => { 172 Some(("mod", Some("rs"))) | Some(("lib", Some("rs"))) => {
173 module_files.list_files_with_extensions(module_file, None) 173 module_files.list_files_with_extensions(module_file, None)
174 } 174 }
175 // TODO kb for `src/bin/foo.rs`, we need to check for modules in `src/bin/`
175 Some((directory_with_module_name, Some("rs"))) => module_files 176 Some((directory_with_module_name, Some("rs"))) => module_files
176 .list_files_with_extensions( 177 .list_files_with_extensions(
177 module_file, 178 module_file,
178 Some(&format!("../{}/", directory_with_module_name)), 179 Some(&format!("../{}/", directory_with_module_name)),
179 ), 180 ),
181 // TODO kb also consider the case when there's no `../module_name.rs`, but `../module_name/mod.rs`
180 _ => Vec::new(), 182 _ => Vec::new(),
181 }; 183 };
182 184
183 possible_submodule_files 185 possible_submodule_files
184 .into_iter() 186 .into_iter()
185 .filter(|(_, extension)| extension == &Some("rs")) 187 .filter(|(_, extension)| extension == &Some("rs"))
188 .filter(|(file_name, _)| file_name != &"mod")
189 .filter(|(file_name, _)| file_name != &"lib")
190 .filter(|(file_name, _)| file_name != &"main")
186 .map(|(file_name, _)| file_name.to_owned()) 191 .map(|(file_name, _)| file_name.to_owned())
187 .collect() 192 .collect()
188 } 193 }
diff --git a/crates/ide/src/completion/completion_context.rs b/crates/ide/src/completion/completion_context.rs
index b4c6eeb35..74cd16e0a 100644
--- a/crates/ide/src/completion/completion_context.rs
+++ b/crates/ide/src/completion/completion_context.rs
@@ -117,9 +117,6 @@ impl<'a> CompletionContext<'a> {
117 .to_module_def(position.file_id) 117 .to_module_def(position.file_id)
118 .and_then(|current_module| { 118 .and_then(|current_module| {
119 let definition_source = current_module.definition_source(db); 119 let definition_source = current_module.definition_source(db);
120 if !matches!(definition_source.value, ModuleSource::SourceFile(_)) {
121 return None;
122 }
123 let module_definition_source_file = definition_source.file_id.original_file(db); 120 let module_definition_source_file = definition_source.file_id.original_file(db);
124 let mod_declaration_candidates = 121 let mod_declaration_candidates =
125 db.possible_sudmobule_names(module_definition_source_file); 122 db.possible_sudmobule_names(module_definition_source_file);