Exclude special files

This commit is contained in:
Kirill Bulatov 2020-09-04 15:13:31 +03:00
parent 897a4c702e
commit 486c5c3285
2 changed files with 5 additions and 3 deletions

View file

@ -172,17 +172,22 @@ impl<T: SourceDatabaseExt> FileLoader for FileLoaderDelegate<&'_ T> {
Some(("mod", Some("rs"))) | Some(("lib", Some("rs"))) => { Some(("mod", Some("rs"))) | Some(("lib", Some("rs"))) => {
module_files.list_files_with_extensions(module_file, None) module_files.list_files_with_extensions(module_file, None)
} }
// TODO kb for `src/bin/foo.rs`, we need to check for modules in `src/bin/`
Some((directory_with_module_name, Some("rs"))) => module_files Some((directory_with_module_name, Some("rs"))) => module_files
.list_files_with_extensions( .list_files_with_extensions(
module_file, module_file,
Some(&format!("../{}/", directory_with_module_name)), Some(&format!("../{}/", directory_with_module_name)),
), ),
// TODO kb also consider the case when there's no `../module_name.rs`, but `../module_name/mod.rs`
_ => Vec::new(), _ => Vec::new(),
}; };
possible_submodule_files possible_submodule_files
.into_iter() .into_iter()
.filter(|(_, extension)| extension == &Some("rs")) .filter(|(_, extension)| extension == &Some("rs"))
.filter(|(file_name, _)| file_name != &"mod")
.filter(|(file_name, _)| file_name != &"lib")
.filter(|(file_name, _)| file_name != &"main")
.map(|(file_name, _)| file_name.to_owned()) .map(|(file_name, _)| file_name.to_owned())
.collect() .collect()
} }

View file

@ -117,9 +117,6 @@ impl<'a> CompletionContext<'a> {
.to_module_def(position.file_id) .to_module_def(position.file_id)
.and_then(|current_module| { .and_then(|current_module| {
let definition_source = current_module.definition_source(db); let definition_source = current_module.definition_source(db);
if !matches!(definition_source.value, ModuleSource::SourceFile(_)) {
return None;
}
let module_definition_source_file = definition_source.file_id.original_file(db); let module_definition_source_file = definition_source.file_id.original_file(db);
let mod_declaration_candidates = let mod_declaration_candidates =
db.possible_sudmobule_names(module_definition_source_file); db.possible_sudmobule_names(module_definition_source_file);