diff options
author | Kirill Bulatov <[email protected]> | 2020-08-28 19:28:30 +0100 |
---|---|---|
committer | Kirill Bulatov <[email protected]> | 2020-09-09 23:42:20 +0100 |
commit | 4bed588001a1d6cd5c83a3eefc6ef77c439de40b (patch) | |
tree | 92552f2af9a6aefcd4fffc20d7cbd06d1bc74d3c /crates/ide/src/completion | |
parent | 5c336e266fe09ae9ae6e634513d441cbcde63696 (diff) |
First steps for mod<|> completion
Diffstat (limited to 'crates/ide/src/completion')
-rw-r--r-- | crates/ide/src/completion/completion_context.rs | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/crates/ide/src/completion/completion_context.rs b/crates/ide/src/completion/completion_context.rs index 47355d5dc..4d8b3670b 100644 --- a/crates/ide/src/completion/completion_context.rs +++ b/crates/ide/src/completion/completion_context.rs | |||
@@ -1,7 +1,7 @@ | |||
1 | //! FIXME: write short doc here | 1 | //! FIXME: write short doc here |
2 | 2 | ||
3 | use base_db::SourceDatabase; | 3 | use base_db::{FileLoader, SourceDatabase}; |
4 | use hir::{Semantics, SemanticsScope, Type}; | 4 | use hir::{ModuleSource, Semantics, SemanticsScope, Type}; |
5 | use ide_db::RootDatabase; | 5 | use ide_db::RootDatabase; |
6 | use syntax::{ | 6 | use syntax::{ |
7 | algo::{find_covering_element, find_node_at_offset}, | 7 | algo::{find_covering_element, find_node_at_offset}, |
@@ -112,6 +112,27 @@ impl<'a> CompletionContext<'a> { | |||
112 | }; | 112 | }; |
113 | let fake_ident_token = | 113 | let fake_ident_token = |
114 | file_with_fake_ident.syntax().token_at_offset(position.offset).right_biased().unwrap(); | 114 | file_with_fake_ident.syntax().token_at_offset(position.offset).right_biased().unwrap(); |
115 | { | ||
116 | let module_names_for_import = sema | ||
117 | .to_module_def(position.file_id) | ||
118 | .and_then(|current_module| { | ||
119 | let definition_source = current_module.definition_source(db); | ||
120 | if !matches!(definition_source.value, ModuleSource::SourceFile(_)) { | ||
121 | return None; | ||
122 | } | ||
123 | let definition_source_file = definition_source.file_id.original_file(db); | ||
124 | |||
125 | // TODO kb for all possible candidates | ||
126 | let zz = db.list_some_random_files_todo(definition_source_file); | ||
127 | dbg!(zz); | ||
128 | // TODO kb exlude existing children from the candidates | ||
129 | let existing_children = current_module.children(db).collect::<Vec<_>>(); | ||
130 | dbg!(existing_children); | ||
131 | None::<Vec<String>> | ||
132 | }) | ||
133 | .unwrap_or_default(); | ||
134 | dbg!(module_names_for_import); | ||
135 | }; | ||
115 | 136 | ||
116 | let krate = sema.to_module_def(position.file_id).map(|m| m.krate()); | 137 | let krate = sema.to_module_def(position.file_id).map(|m| m.krate()); |
117 | let original_token = | 138 | let original_token = |