From 9f0ed7ed92a978da73d19fe9f23b3953ca0a1de4 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Sat, 2 May 2020 22:33:23 +0300 Subject: Separate macros completion from other --- crates/ra_ide/src/completion.rs | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) (limited to 'crates/ra_ide/src/completion.rs') diff --git a/crates/ra_ide/src/completion.rs b/crates/ra_ide/src/completion.rs index 4ca0fdf4f..a0e06faa2 100644 --- a/crates/ra_ide/src/completion.rs +++ b/crates/ra_ide/src/completion.rs @@ -65,21 +65,23 @@ pub(crate) fn completions( let ctx = CompletionContext::new(db, position, config)?; let mut acc = Completions::default(); - - complete_fn_param::complete_fn_param(&mut acc, &ctx); - complete_keyword::complete_expr_keyword(&mut acc, &ctx); - complete_keyword::complete_use_tree_keyword(&mut acc, &ctx); - complete_snippet::complete_expr_snippet(&mut acc, &ctx); - complete_snippet::complete_item_snippet(&mut acc, &ctx); - complete_qualified_path::complete_qualified_path(&mut acc, &ctx); - complete_unqualified_path::complete_unqualified_path(&mut acc, &ctx); - complete_dot::complete_dot(&mut acc, &ctx); - complete_record::complete_record(&mut acc, &ctx); - complete_pattern::complete_pattern(&mut acc, &ctx); - complete_postfix::complete_postfix(&mut acc, &ctx); - complete_macro_in_item_position::complete_macro_in_item_position(&mut acc, &ctx); - complete_trait_impl::complete_trait_impl(&mut acc, &ctx); - complete_attribute::complete_attribute(&mut acc, &ctx); + if ctx.attribute_under_caret.is_some() { + complete_attribute::complete_attribute(&mut acc, &ctx); + } else { + complete_fn_param::complete_fn_param(&mut acc, &ctx); + complete_keyword::complete_expr_keyword(&mut acc, &ctx); + complete_keyword::complete_use_tree_keyword(&mut acc, &ctx); + complete_snippet::complete_expr_snippet(&mut acc, &ctx); + complete_snippet::complete_item_snippet(&mut acc, &ctx); + complete_qualified_path::complete_qualified_path(&mut acc, &ctx); + complete_unqualified_path::complete_unqualified_path(&mut acc, &ctx); + complete_dot::complete_dot(&mut acc, &ctx); + complete_record::complete_record(&mut acc, &ctx); + complete_pattern::complete_pattern(&mut acc, &ctx); + complete_postfix::complete_postfix(&mut acc, &ctx); + complete_macro_in_item_position::complete_macro_in_item_position(&mut acc, &ctx); + complete_trait_impl::complete_trait_impl(&mut acc, &ctx); + } Some(acc) } -- cgit v1.2.3 From 71f6d58e310af0f67fba8bb9f59ea9777ecf24d0 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 4 May 2020 15:07:09 +0200 Subject: Remove unnecessary condition No tests fail, and quick manual testing shows that there are no false-positives. In general, each completion contributor should be independent from the others. --- crates/ra_ide/src/completion.rs | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) (limited to 'crates/ra_ide/src/completion.rs') diff --git a/crates/ra_ide/src/completion.rs b/crates/ra_ide/src/completion.rs index a0e06faa2..8bdc43b1a 100644 --- a/crates/ra_ide/src/completion.rs +++ b/crates/ra_ide/src/completion.rs @@ -65,23 +65,20 @@ pub(crate) fn completions( let ctx = CompletionContext::new(db, position, config)?; let mut acc = Completions::default(); - if ctx.attribute_under_caret.is_some() { - complete_attribute::complete_attribute(&mut acc, &ctx); - } else { - complete_fn_param::complete_fn_param(&mut acc, &ctx); - complete_keyword::complete_expr_keyword(&mut acc, &ctx); - complete_keyword::complete_use_tree_keyword(&mut acc, &ctx); - complete_snippet::complete_expr_snippet(&mut acc, &ctx); - complete_snippet::complete_item_snippet(&mut acc, &ctx); - complete_qualified_path::complete_qualified_path(&mut acc, &ctx); - complete_unqualified_path::complete_unqualified_path(&mut acc, &ctx); - complete_dot::complete_dot(&mut acc, &ctx); - complete_record::complete_record(&mut acc, &ctx); - complete_pattern::complete_pattern(&mut acc, &ctx); - complete_postfix::complete_postfix(&mut acc, &ctx); - complete_macro_in_item_position::complete_macro_in_item_position(&mut acc, &ctx); - complete_trait_impl::complete_trait_impl(&mut acc, &ctx); - } + complete_attribute::complete_attribute(&mut acc, &ctx); + complete_fn_param::complete_fn_param(&mut acc, &ctx); + complete_keyword::complete_expr_keyword(&mut acc, &ctx); + complete_keyword::complete_use_tree_keyword(&mut acc, &ctx); + complete_snippet::complete_expr_snippet(&mut acc, &ctx); + complete_snippet::complete_item_snippet(&mut acc, &ctx); + complete_qualified_path::complete_qualified_path(&mut acc, &ctx); + complete_unqualified_path::complete_unqualified_path(&mut acc, &ctx); + complete_dot::complete_dot(&mut acc, &ctx); + complete_record::complete_record(&mut acc, &ctx); + complete_pattern::complete_pattern(&mut acc, &ctx); + complete_postfix::complete_postfix(&mut acc, &ctx); + complete_macro_in_item_position::complete_macro_in_item_position(&mut acc, &ctx); + complete_trait_impl::complete_trait_impl(&mut acc, &ctx); Some(acc) } -- cgit v1.2.3 From c847c079fd66d7ed09c64ff398baf05317b16500 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 17 May 2020 12:09:53 +0200 Subject: Add AssistConfig --- crates/ra_ide/src/completion.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'crates/ra_ide/src/completion.rs') diff --git a/crates/ra_ide/src/completion.rs b/crates/ra_ide/src/completion.rs index 8bdc43b1a..191300704 100644 --- a/crates/ra_ide/src/completion.rs +++ b/crates/ra_ide/src/completion.rs @@ -59,8 +59,8 @@ pub use crate::completion::{ /// with ordering of completions (currently this is done by the client). pub(crate) fn completions( db: &RootDatabase, - position: FilePosition, config: &CompletionConfig, + position: FilePosition, ) -> Option { let ctx = CompletionContext::new(db, position, config)?; -- cgit v1.2.3