7297: Propose trait associated items and autoimport traits on completion r=matklad a=SomeoneToIgnore  Closes #7248 7338: Parse `impl const Trait` r=Veykril a=Veykril Closes #7313 bors r+ Co-authored-by: Kirill Bulatov <mail4score@gmail.com> Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
This commit is contained in:
@@ -93,7 +93,7 @@ impl BenchCmd {
|
||||
if is_completion {
|
||||
let options = CompletionConfig {
|
||||
enable_postfix_completions: true,
|
||||
enable_autoimport_completions: true,
|
||||
enable_imports_on_the_fly: true,
|
||||
add_call_parenthesis: true,
|
||||
add_call_argument_snippets: true,
|
||||
snippet_cap: SnippetCap::new(true),
|
||||
|
||||
@@ -559,7 +559,7 @@ impl Config {
|
||||
pub fn completion(&self) -> CompletionConfig {
|
||||
CompletionConfig {
|
||||
enable_postfix_completions: self.data.completion_postfix_enable,
|
||||
enable_autoimport_completions: self.data.completion_autoimport_enable
|
||||
enable_imports_on_the_fly: self.data.completion_autoimport_enable
|
||||
&& completion_item_edit_resolve(&self.caps),
|
||||
add_call_parenthesis: self.data.completion_addCallParenthesis,
|
||||
add_call_argument_snippets: self.data.completion_addCallArgumentSnippets,
|
||||
@@ -581,18 +581,7 @@ impl Config {
|
||||
AssistConfig {
|
||||
snippet_cap: SnippetCap::new(self.experimental("snippetTextEdit")),
|
||||
allowed: None,
|
||||
insert_use: InsertUseConfig {
|
||||
merge: match self.data.assist_importMergeBehavior {
|
||||
MergeBehaviorDef::None => None,
|
||||
MergeBehaviorDef::Full => Some(MergeBehavior::Full),
|
||||
MergeBehaviorDef::Last => Some(MergeBehavior::Last),
|
||||
},
|
||||
prefix_kind: match self.data.assist_importPrefix {
|
||||
ImportPrefixDef::Plain => PrefixKind::Plain,
|
||||
ImportPrefixDef::ByCrate => PrefixKind::ByCrate,
|
||||
ImportPrefixDef::BySelf => PrefixKind::BySelf,
|
||||
},
|
||||
},
|
||||
insert_use: self.insert_use_config(),
|
||||
}
|
||||
}
|
||||
pub fn call_info_full(&self) -> bool {
|
||||
|
||||
@@ -653,7 +653,7 @@ pub(crate) fn handle_completion(
|
||||
let mut new_completion_items =
|
||||
to_proto::completion_item(&line_index, line_endings, item.clone());
|
||||
|
||||
if completion_config.enable_autoimport_completions {
|
||||
if completion_config.enable_imports_on_the_fly {
|
||||
for new_item in &mut new_completion_items {
|
||||
fill_resolve_data(&mut new_item.data, &item, &text_document_position);
|
||||
}
|
||||
@@ -703,6 +703,7 @@ pub(crate) fn handle_completion_resolve(
|
||||
FilePosition { file_id, offset },
|
||||
&resolve_data.full_import_path,
|
||||
resolve_data.imported_name,
|
||||
resolve_data.import_for_trait_assoc_item,
|
||||
)?
|
||||
.into_iter()
|
||||
.flat_map(|edit| {
|
||||
@@ -1694,6 +1695,7 @@ struct CompletionResolveData {
|
||||
position: lsp_types::TextDocumentPositionParams,
|
||||
full_import_path: String,
|
||||
imported_name: String,
|
||||
import_for_trait_assoc_item: bool,
|
||||
}
|
||||
|
||||
fn fill_resolve_data(
|
||||
@@ -1710,6 +1712,7 @@ fn fill_resolve_data(
|
||||
position: position.to_owned(),
|
||||
full_import_path,
|
||||
imported_name,
|
||||
import_for_trait_assoc_item: import_edit.import_for_trait_assoc_item,
|
||||
})
|
||||
.unwrap(),
|
||||
);
|
||||
|
||||
@@ -884,7 +884,7 @@ mod tests {
|
||||
.completions(
|
||||
&ide::CompletionConfig {
|
||||
enable_postfix_completions: true,
|
||||
enable_autoimport_completions: true,
|
||||
enable_imports_on_the_fly: true,
|
||||
add_call_parenthesis: true,
|
||||
add_call_argument_snippets: true,
|
||||
snippet_cap: SnippetCap::new(true),
|
||||
|
||||
Reference in New Issue
Block a user