From 25dda42f3773b1d002a5809c0182c2adc6c47027 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 22 Dec 2018 01:27:07 +0300 Subject: introduce ComletionItemKind --- crates/ra_analysis/src/completion/complete_keyword.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'crates/ra_analysis/src/completion/complete_keyword.rs') diff --git a/crates/ra_analysis/src/completion/complete_keyword.rs b/crates/ra_analysis/src/completion/complete_keyword.rs index dead15bb6..1e6d7008d 100644 --- a/crates/ra_analysis/src/completion/complete_keyword.rs +++ b/crates/ra_analysis/src/completion/complete_keyword.rs @@ -61,10 +61,7 @@ fn complete_return(fn_def: ast::FnDef, is_stmt: bool) -> Option } fn keyword(kw: &str, snippet: &str) -> CompletionItem { - CompletionItem::new(kw) - .kind(Keyword) - .snippet(snippet) - .build() + CompletionItem::new(Keyword, kw).snippet(snippet).build() } #[cfg(test)] -- cgit v1.2.3 From 284e89406906b97eec8e0f91bce2955a5e94b880 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 22 Dec 2018 01:34:22 +0300 Subject: cleanup --- crates/ra_analysis/src/completion/complete_keyword.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'crates/ra_analysis/src/completion/complete_keyword.rs') diff --git a/crates/ra_analysis/src/completion/complete_keyword.rs b/crates/ra_analysis/src/completion/complete_keyword.rs index 1e6d7008d..2c7891920 100644 --- a/crates/ra_analysis/src/completion/complete_keyword.rs +++ b/crates/ra_analysis/src/completion/complete_keyword.rs @@ -5,7 +5,13 @@ use ra_syntax::{ SyntaxKind::*, SyntaxNodeRef, }; -use crate::completion::{CompletionContext, CompletionItem, Completions, CompletionKind::*}; +use crate::completion::{CompletionContext, CompletionItem, Completions, CompletionKind}; + +fn keyword(kw: &str, snippet: &str) -> CompletionItem { + CompletionItem::new(CompletionKind::Keyword, kw) + .snippet(snippet) + .build() +} pub(super) fn complete_expr_keyword(acc: &mut Completions, ctx: &CompletionContext) { if !ctx.is_trivial_path { @@ -60,10 +66,6 @@ fn complete_return(fn_def: ast::FnDef, is_stmt: bool) -> Option Some(keyword("return", snip)) } -fn keyword(kw: &str, snippet: &str) -> CompletionItem { - CompletionItem::new(Keyword, kw).snippet(snippet).build() -} - #[cfg(test)] mod tests { use crate::completion::{CompletionKind, check_completion}; -- cgit v1.2.3 From 328d123f5baeab8ff9a1f63a6744f6eec89818ab Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 22 Dec 2018 01:37:11 +0300 Subject: specify completion item kind --- crates/ra_analysis/src/completion/complete_keyword.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'crates/ra_analysis/src/completion/complete_keyword.rs') diff --git a/crates/ra_analysis/src/completion/complete_keyword.rs b/crates/ra_analysis/src/completion/complete_keyword.rs index 2c7891920..5427fcb11 100644 --- a/crates/ra_analysis/src/completion/complete_keyword.rs +++ b/crates/ra_analysis/src/completion/complete_keyword.rs @@ -5,10 +5,11 @@ use ra_syntax::{ SyntaxKind::*, SyntaxNodeRef, }; -use crate::completion::{CompletionContext, CompletionItem, Completions, CompletionKind}; +use crate::completion::{CompletionContext, CompletionItem, Completions, CompletionKind, CompletionItemKind}; fn keyword(kw: &str, snippet: &str) -> CompletionItem { CompletionItem::new(CompletionKind::Keyword, kw) + .kind(CompletionItemKind::Keyword) .snippet(snippet) .build() } -- cgit v1.2.3