From 83e49200d82dccda54bbf376bba5a9c75da14cab Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Tue, 19 Jan 2021 20:21:56 +0100 Subject: Add LifetimeParam and ConstParam to CompletionItemKind --- crates/completion/src/completions/unqualified_path.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'crates/completion/src/completions') diff --git a/crates/completion/src/completions/unqualified_path.rs b/crates/completion/src/completions/unqualified_path.rs index 809e1645a..860c774c1 100644 --- a/crates/completion/src/completions/unqualified_path.rs +++ b/crates/completion/src/completions/unqualified_path.rs @@ -241,7 +241,7 @@ fn main() { check( r#"fn quux() { $0 }"#, expect![[r#" - tp C + cp C fn quux() fn quux() "#]], ); -- cgit v1.2.3 From f2cb7dbcb71d81336c95dc7ae1301ba2a79ef707 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Wed, 20 Jan 2021 18:38:12 +0100 Subject: Partially unify SymbolKind and CompletionItemKind --- crates/completion/src/completions/fn_param.rs | 4 ++-- crates/completion/src/completions/mod_.rs | 10 ++++++---- crates/completion/src/completions/record.rs | 8 +++----- crates/completion/src/completions/trait_impl.rs | 8 ++++---- 4 files changed, 15 insertions(+), 15 deletions(-) (limited to 'crates/completion/src/completions') diff --git a/crates/completion/src/completions/fn_param.rs b/crates/completion/src/completions/fn_param.rs index 5505c3559..38e33a93e 100644 --- a/crates/completion/src/completions/fn_param.rs +++ b/crates/completion/src/completions/fn_param.rs @@ -6,7 +6,7 @@ use syntax::{ match_ast, AstNode, }; -use crate::{CompletionContext, CompletionItem, CompletionKind, Completions}; +use crate::{CompletionContext, CompletionItem, CompletionItemKind, CompletionKind, Completions}; /// Complete repeated parameters, both name and type. For example, if all /// functions in a file have a `spam: &mut Spam` parameter, a completion with @@ -58,7 +58,7 @@ pub(crate) fn complete_fn_param(acc: &mut Completions, ctx: &CompletionContext) }) .for_each(|(label, lookup)| { CompletionItem::new(CompletionKind::Magic, ctx.source_range(), label) - .kind(crate::CompletionItemKind::Binding) + .kind(CompletionItemKind::Binding) .lookup_by(lookup) .add_to(acc) }); diff --git a/crates/completion/src/completions/mod_.rs b/crates/completion/src/completions/mod_.rs index 00e951ca9..352fc7c77 100644 --- a/crates/completion/src/completions/mod_.rs +++ b/crates/completion/src/completions/mod_.rs @@ -3,11 +3,13 @@ use std::iter; use hir::{Module, ModuleSource}; -use ide_db::base_db::{SourceDatabaseExt, VfsPath}; -use ide_db::RootDatabase; +use ide_db::{ + base_db::{SourceDatabaseExt, VfsPath}, + RootDatabase, SymbolKind, +}; use rustc_hash::FxHashSet; -use crate::{CompletionItem, CompletionItemKind}; +use crate::CompletionItem; use crate::{context::CompletionContext, item::CompletionKind, Completions}; @@ -79,7 +81,7 @@ pub(crate) fn complete_mod(acc: &mut Completions, ctx: &CompletionContext) -> Op label.push(';'); } CompletionItem::new(CompletionKind::Magic, ctx.source_range(), &label) - .kind(CompletionItemKind::Module) + .kind(SymbolKind::Module) .add_to(acc) }); diff --git a/crates/completion/src/completions/record.rs b/crates/completion/src/completions/record.rs index bb6354ded..0a7927eb8 100644 --- a/crates/completion/src/completions/record.rs +++ b/crates/completion/src/completions/record.rs @@ -1,10 +1,8 @@ //! Complete fields in record literals and patterns. -use ide_db::helpers::FamousDefs; +use ide_db::{helpers::FamousDefs, SymbolKind}; use syntax::ast::Expr; -use crate::{ - item::CompletionKind, CompletionContext, CompletionItem, CompletionItemKind, Completions, -}; +use crate::{item::CompletionKind, CompletionContext, CompletionItem, Completions}; pub(crate) fn complete_record(acc: &mut Completions, ctx: &CompletionContext) -> Option<()> { let missing_fields = match (ctx.record_pat_syntax.as_ref(), ctx.record_lit_syntax.as_ref()) { @@ -31,7 +29,7 @@ pub(crate) fn complete_record(acc: &mut Completions, ctx: &CompletionContext) -> "..Default::default()", ) .insert_text(completion_text) - .kind(CompletionItemKind::Field) + .kind(SymbolKind::Field) .build(), ); } diff --git a/crates/completion/src/completions/trait_impl.rs b/crates/completion/src/completions/trait_impl.rs index 135ae49dc..f258ad9c3 100644 --- a/crates/completion/src/completions/trait_impl.rs +++ b/crates/completion/src/completions/trait_impl.rs @@ -32,7 +32,7 @@ //! ``` use hir::{self, HasAttrs, HasSource}; -use ide_db::traits::get_missing_assoc_items; +use ide_db::{traits::get_missing_assoc_items, SymbolKind}; use syntax::{ ast::{self, edit, Impl}, display::function_declaration, @@ -152,7 +152,7 @@ fn add_function_impl( let completion_kind = if func.self_param(ctx.db).is_some() { CompletionItemKind::Method } else { - CompletionItemKind::Function + CompletionItemKind::SymbolKind(SymbolKind::Function) }; let range = TextRange::new(fn_def_node.text_range().start(), ctx.source_range().end()); @@ -188,7 +188,7 @@ fn add_type_alias_impl( CompletionItem::new(CompletionKind::Magic, ctx.source_range(), snippet.clone()) .text_edit(TextEdit::replace(range, snippet)) .lookup_by(alias_name) - .kind(CompletionItemKind::TypeAlias) + .kind(SymbolKind::TypeAlias) .set_documentation(type_alias.docs(ctx.db)) .add_to(acc); } @@ -211,7 +211,7 @@ fn add_const_impl( CompletionItem::new(CompletionKind::Magic, ctx.source_range(), snippet.clone()) .text_edit(TextEdit::replace(range, snippet)) .lookup_by(const_name) - .kind(CompletionItemKind::Const) + .kind(SymbolKind::Const) .set_documentation(const_.docs(ctx.db)) .add_to(acc); } -- cgit v1.2.3 From 08b822b25914bea7405a30383fe43c7235d14346 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Wed, 20 Jan 2021 18:46:14 +0100 Subject: Update completions test output --- .../completion/src/completions/unqualified_path.rs | 36 +++++++++++----------- 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'crates/completion/src/completions') diff --git a/crates/completion/src/completions/unqualified_path.rs b/crates/completion/src/completions/unqualified_path.rs index 860c774c1..a289efc34 100644 --- a/crates/completion/src/completions/unqualified_path.rs +++ b/crates/completion/src/completions/unqualified_path.rs @@ -165,8 +165,8 @@ fn quux(x: i32) { } "#, expect![[r#" - bn y i32 - bn x i32 + lc y i32 + lc x i32 fn quux(…) fn quux(x: i32) "#]], ); @@ -187,8 +187,8 @@ fn quux() { } "#, expect![[r#" - bn b i32 - bn a + lc b i32 + lc a fn quux() fn quux() "#]], ); @@ -203,7 +203,7 @@ fn quux() { } "#, expect![[r#" - bn x + lc x fn quux() fn quux() "#]], ); @@ -263,7 +263,7 @@ fn main() { check( r#"struct S { x: $0}"#, expect![[r#" - tp Self + sp Self tp T st S<…> "#]], @@ -275,7 +275,7 @@ fn main() { check( r#"enum X { Y($0) }"#, expect![[r#" - tp Self + sp Self en X "#]], ); @@ -378,8 +378,8 @@ fn foo() { "#, // FIXME: should be only one bar here expect![[r#" - bn bar i32 - bn bar i32 + lc bar i32 + lc bar i32 fn foo() fn foo() "#]], ); @@ -390,8 +390,8 @@ fn foo() { check( r#"impl S { fn foo(&self) { $0 } }"#, expect![[r#" - bn self &{unknown} - tp Self + lc self &{unknown} + sp Self "#]], ); } @@ -575,8 +575,8 @@ fn quux(x: i32) { } "#, expect![[r#" - bn y i32 - bn x i32 + lc y i32 + lc x i32 fn quux(…) fn quux(x: i32) ma m!(…) macro_rules! m "#]], @@ -594,8 +594,8 @@ fn quux(x: i32) { } ", expect![[r#" - bn y i32 - bn x i32 + lc y i32 + lc x i32 fn quux(…) fn quux(x: i32) ma m!(…) macro_rules! m "#]], @@ -613,8 +613,8 @@ fn quux(x: i32) { } "#, expect![[r#" - bn y i32 - bn x i32 + lc y i32 + lc x i32 fn quux(…) fn quux(x: i32) ma m!(…) macro_rules! m "#]], @@ -750,7 +750,7 @@ struct MyStruct {} impl My$0 "#, expect![[r#" - tp Self + sp Self tt MyTrait st MyStruct "#]], -- cgit v1.2.3