diff options
author | Lukas Wirth <[email protected]> | 2021-01-20 17:38:12 +0000 |
---|---|---|
committer | Lukas Wirth <[email protected]> | 2021-01-20 17:39:46 +0000 |
commit | f2cb7dbcb71d81336c95dc7ae1301ba2a79ef707 (patch) | |
tree | c17a9cf589910137b5388fc22856c991a5ec0a31 /crates/completion | |
parent | 563a175fdb9073a548fc2e161d5de0a093b0d74d (diff) |
Partially unify SymbolKind and CompletionItemKind
Diffstat (limited to 'crates/completion')
-rw-r--r-- | crates/completion/src/completions/fn_param.rs | 4 | ||||
-rw-r--r-- | crates/completion/src/completions/mod_.rs | 10 | ||||
-rw-r--r-- | crates/completion/src/completions/record.rs | 8 | ||||
-rw-r--r-- | crates/completion/src/completions/trait_impl.rs | 8 | ||||
-rw-r--r-- | crates/completion/src/item.rs | 70 | ||||
-rw-r--r-- | crates/completion/src/render.rs | 47 | ||||
-rw-r--r-- | crates/completion/src/render/const_.rs | 5 | ||||
-rw-r--r-- | crates/completion/src/render/enum_variant.rs | 5 | ||||
-rw-r--r-- | crates/completion/src/render/function.rs | 3 | ||||
-rw-r--r-- | crates/completion/src/render/macro_.rs | 5 | ||||
-rw-r--r-- | crates/completion/src/render/type_alias.rs | 5 |
11 files changed, 90 insertions, 80 deletions
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::{ | |||
6 | match_ast, AstNode, | 6 | match_ast, AstNode, |
7 | }; | 7 | }; |
8 | 8 | ||
9 | use crate::{CompletionContext, CompletionItem, CompletionKind, Completions}; | 9 | use crate::{CompletionContext, CompletionItem, CompletionItemKind, CompletionKind, Completions}; |
10 | 10 | ||
11 | /// Complete repeated parameters, both name and type. For example, if all | 11 | /// Complete repeated parameters, both name and type. For example, if all |
12 | /// functions in a file have a `spam: &mut Spam` parameter, a completion with | 12 | /// 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) | |||
58 | }) | 58 | }) |
59 | .for_each(|(label, lookup)| { | 59 | .for_each(|(label, lookup)| { |
60 | CompletionItem::new(CompletionKind::Magic, ctx.source_range(), label) | 60 | CompletionItem::new(CompletionKind::Magic, ctx.source_range(), label) |
61 | .kind(crate::CompletionItemKind::Binding) | 61 | .kind(CompletionItemKind::Binding) |
62 | .lookup_by(lookup) | 62 | .lookup_by(lookup) |
63 | .add_to(acc) | 63 | .add_to(acc) |
64 | }); | 64 | }); |
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 @@ | |||
3 | use std::iter; | 3 | use std::iter; |
4 | 4 | ||
5 | use hir::{Module, ModuleSource}; | 5 | use hir::{Module, ModuleSource}; |
6 | use ide_db::base_db::{SourceDatabaseExt, VfsPath}; | 6 | use ide_db::{ |
7 | use ide_db::RootDatabase; | 7 | base_db::{SourceDatabaseExt, VfsPath}, |
8 | RootDatabase, SymbolKind, | ||
9 | }; | ||
8 | use rustc_hash::FxHashSet; | 10 | use rustc_hash::FxHashSet; |
9 | 11 | ||
10 | use crate::{CompletionItem, CompletionItemKind}; | 12 | use crate::CompletionItem; |
11 | 13 | ||
12 | use crate::{context::CompletionContext, item::CompletionKind, Completions}; | 14 | use crate::{context::CompletionContext, item::CompletionKind, Completions}; |
13 | 15 | ||
@@ -79,7 +81,7 @@ pub(crate) fn complete_mod(acc: &mut Completions, ctx: &CompletionContext) -> Op | |||
79 | label.push(';'); | 81 | label.push(';'); |
80 | } | 82 | } |
81 | CompletionItem::new(CompletionKind::Magic, ctx.source_range(), &label) | 83 | CompletionItem::new(CompletionKind::Magic, ctx.source_range(), &label) |
82 | .kind(CompletionItemKind::Module) | 84 | .kind(SymbolKind::Module) |
83 | .add_to(acc) | 85 | .add_to(acc) |
84 | }); | 86 | }); |
85 | 87 | ||
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 @@ | |||
1 | //! Complete fields in record literals and patterns. | 1 | //! Complete fields in record literals and patterns. |
2 | use ide_db::helpers::FamousDefs; | 2 | use ide_db::{helpers::FamousDefs, SymbolKind}; |
3 | use syntax::ast::Expr; | 3 | use syntax::ast::Expr; |
4 | 4 | ||
5 | use crate::{ | 5 | use crate::{item::CompletionKind, CompletionContext, CompletionItem, Completions}; |
6 | item::CompletionKind, CompletionContext, CompletionItem, CompletionItemKind, Completions, | ||
7 | }; | ||
8 | 6 | ||
9 | pub(crate) fn complete_record(acc: &mut Completions, ctx: &CompletionContext) -> Option<()> { | 7 | pub(crate) fn complete_record(acc: &mut Completions, ctx: &CompletionContext) -> Option<()> { |
10 | let missing_fields = match (ctx.record_pat_syntax.as_ref(), ctx.record_lit_syntax.as_ref()) { | 8 | 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) -> | |||
31 | "..Default::default()", | 29 | "..Default::default()", |
32 | ) | 30 | ) |
33 | .insert_text(completion_text) | 31 | .insert_text(completion_text) |
34 | .kind(CompletionItemKind::Field) | 32 | .kind(SymbolKind::Field) |
35 | .build(), | 33 | .build(), |
36 | ); | 34 | ); |
37 | } | 35 | } |
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 @@ | |||
32 | //! ``` | 32 | //! ``` |
33 | 33 | ||
34 | use hir::{self, HasAttrs, HasSource}; | 34 | use hir::{self, HasAttrs, HasSource}; |
35 | use ide_db::traits::get_missing_assoc_items; | 35 | use ide_db::{traits::get_missing_assoc_items, SymbolKind}; |
36 | use syntax::{ | 36 | use syntax::{ |
37 | ast::{self, edit, Impl}, | 37 | ast::{self, edit, Impl}, |
38 | display::function_declaration, | 38 | display::function_declaration, |
@@ -152,7 +152,7 @@ fn add_function_impl( | |||
152 | let completion_kind = if func.self_param(ctx.db).is_some() { | 152 | let completion_kind = if func.self_param(ctx.db).is_some() { |
153 | CompletionItemKind::Method | 153 | CompletionItemKind::Method |
154 | } else { | 154 | } else { |
155 | CompletionItemKind::Function | 155 | CompletionItemKind::SymbolKind(SymbolKind::Function) |
156 | }; | 156 | }; |
157 | let range = TextRange::new(fn_def_node.text_range().start(), ctx.source_range().end()); | 157 | let range = TextRange::new(fn_def_node.text_range().start(), ctx.source_range().end()); |
158 | 158 | ||
@@ -188,7 +188,7 @@ fn add_type_alias_impl( | |||
188 | CompletionItem::new(CompletionKind::Magic, ctx.source_range(), snippet.clone()) | 188 | CompletionItem::new(CompletionKind::Magic, ctx.source_range(), snippet.clone()) |
189 | .text_edit(TextEdit::replace(range, snippet)) | 189 | .text_edit(TextEdit::replace(range, snippet)) |
190 | .lookup_by(alias_name) | 190 | .lookup_by(alias_name) |
191 | .kind(CompletionItemKind::TypeAlias) | 191 | .kind(SymbolKind::TypeAlias) |
192 | .set_documentation(type_alias.docs(ctx.db)) | 192 | .set_documentation(type_alias.docs(ctx.db)) |
193 | .add_to(acc); | 193 | .add_to(acc); |
194 | } | 194 | } |
@@ -211,7 +211,7 @@ fn add_const_impl( | |||
211 | CompletionItem::new(CompletionKind::Magic, ctx.source_range(), snippet.clone()) | 211 | CompletionItem::new(CompletionKind::Magic, ctx.source_range(), snippet.clone()) |
212 | .text_edit(TextEdit::replace(range, snippet)) | 212 | .text_edit(TextEdit::replace(range, snippet)) |
213 | .lookup_by(const_name) | 213 | .lookup_by(const_name) |
214 | .kind(CompletionItemKind::Const) | 214 | .kind(SymbolKind::Const) |
215 | .set_documentation(const_.docs(ctx.db)) | 215 | .set_documentation(const_.docs(ctx.db)) |
216 | .add_to(acc); | 216 | .add_to(acc); |
217 | } | 217 | } |
diff --git a/crates/completion/src/item.rs b/crates/completion/src/item.rs index ecf581be2..178e05c46 100644 --- a/crates/completion/src/item.rs +++ b/crates/completion/src/item.rs | |||
@@ -3,11 +3,14 @@ | |||
3 | use std::fmt; | 3 | use std::fmt; |
4 | 4 | ||
5 | use hir::{Documentation, ModPath, Mutability}; | 5 | use hir::{Documentation, ModPath, Mutability}; |
6 | use ide_db::helpers::{ | 6 | use ide_db::{ |
7 | insert_use::{self, ImportScope, MergeBehavior}, | 7 | helpers::{ |
8 | mod_path_to_ast, SnippetCap, | 8 | insert_use::{self, ImportScope, MergeBehavior}, |
9 | mod_path_to_ast, SnippetCap, | ||
10 | }, | ||
11 | SymbolKind, | ||
9 | }; | 12 | }; |
10 | use stdx::assert_never; | 13 | use stdx::{assert_never, impl_from}; |
11 | use syntax::{algo, TextRange}; | 14 | use syntax::{algo, TextRange}; |
12 | use text_edit::TextEdit; | 15 | use text_edit::TextEdit; |
13 | 16 | ||
@@ -117,53 +120,50 @@ pub enum CompletionScore { | |||
117 | 120 | ||
118 | #[derive(Debug, Clone, Copy, PartialEq, Eq)] | 121 | #[derive(Debug, Clone, Copy, PartialEq, Eq)] |
119 | pub enum CompletionItemKind { | 122 | pub enum CompletionItemKind { |
123 | SymbolKind(SymbolKind), | ||
124 | BuiltinType, | ||
120 | Attribute, | 125 | Attribute, |
121 | Binding, | 126 | Binding, |
122 | BuiltinType, | ||
123 | Const, | ||
124 | ConstParam, | ||
125 | Enum, | ||
126 | EnumVariant, | ||
127 | Field, | ||
128 | Function, | ||
129 | Keyword, | 127 | Keyword, |
130 | LifetimeParam, | ||
131 | Macro, | ||
132 | Method, | 128 | Method, |
133 | Module, | ||
134 | Snippet, | 129 | Snippet, |
135 | Static, | ||
136 | Struct, | ||
137 | Trait, | ||
138 | TypeAlias, | ||
139 | TypeParam, | ||
140 | UnresolvedReference, | 130 | UnresolvedReference, |
141 | } | 131 | } |
142 | 132 | ||
133 | impl_from!(SymbolKind for CompletionItemKind); | ||
134 | |||
143 | impl CompletionItemKind { | 135 | impl CompletionItemKind { |
144 | #[cfg(test)] | 136 | #[cfg(test)] |
145 | pub(crate) fn tag(&self) -> &'static str { | 137 | pub(crate) fn tag(&self) -> &'static str { |
146 | match self { | 138 | match self { |
139 | CompletionItemKind::SymbolKind(kind) => match kind { | ||
140 | SymbolKind::Const => "ct", | ||
141 | SymbolKind::ConstParam => "cp", | ||
142 | SymbolKind::Enum => "en", | ||
143 | SymbolKind::Field => "fd", | ||
144 | SymbolKind::Function => "fn", | ||
145 | SymbolKind::Impl => "im", | ||
146 | SymbolKind::Label => "lb", | ||
147 | SymbolKind::LifetimeParam => "lt", | ||
148 | SymbolKind::Local => "lc", | ||
149 | SymbolKind::Macro => "ma", | ||
150 | SymbolKind::Module => "md", | ||
151 | SymbolKind::SelfParam => "sp", | ||
152 | SymbolKind::Static => "sc", | ||
153 | SymbolKind::Struct => "st", | ||
154 | SymbolKind::Trait => "tt", | ||
155 | SymbolKind::TypeAlias => "ta", | ||
156 | SymbolKind::TypeParam => "tp", | ||
157 | SymbolKind::Union => "un", | ||
158 | SymbolKind::ValueParam => "vp", | ||
159 | SymbolKind::Variant => "ev", | ||
160 | }, | ||
147 | CompletionItemKind::Attribute => "at", | 161 | CompletionItemKind::Attribute => "at", |
148 | CompletionItemKind::Binding => "bn", | 162 | CompletionItemKind::Binding => "bn", |
149 | CompletionItemKind::BuiltinType => "bt", | 163 | CompletionItemKind::BuiltinType => "bt", |
150 | CompletionItemKind::Const => "ct", | ||
151 | CompletionItemKind::ConstParam => "cp", | ||
152 | CompletionItemKind::Enum => "en", | ||
153 | CompletionItemKind::EnumVariant => "ev", | ||
154 | CompletionItemKind::Field => "fd", | ||
155 | CompletionItemKind::Function => "fn", | ||
156 | CompletionItemKind::Keyword => "kw", | 164 | CompletionItemKind::Keyword => "kw", |
157 | CompletionItemKind::LifetimeParam => "lt", | ||
158 | CompletionItemKind::Macro => "ma", | ||
159 | CompletionItemKind::Method => "me", | 165 | CompletionItemKind::Method => "me", |
160 | CompletionItemKind::Module => "md", | ||
161 | CompletionItemKind::Snippet => "sn", | 166 | CompletionItemKind::Snippet => "sn", |
162 | CompletionItemKind::Static => "sc", | ||
163 | CompletionItemKind::Struct => "st", | ||
164 | CompletionItemKind::Trait => "tt", | ||
165 | CompletionItemKind::TypeAlias => "ta", | ||
166 | CompletionItemKind::TypeParam => "tp", | ||
167 | CompletionItemKind::UnresolvedReference => "??", | 167 | CompletionItemKind::UnresolvedReference => "??", |
168 | } | 168 | } |
169 | } | 169 | } |
@@ -386,8 +386,8 @@ impl Builder { | |||
386 | self.insert_text_format = InsertTextFormat::Snippet; | 386 | self.insert_text_format = InsertTextFormat::Snippet; |
387 | self.insert_text(snippet) | 387 | self.insert_text(snippet) |
388 | } | 388 | } |
389 | pub(crate) fn kind(mut self, kind: CompletionItemKind) -> Builder { | 389 | pub(crate) fn kind(mut self, kind: impl Into<CompletionItemKind>) -> Builder { |
390 | self.kind = Some(kind); | 390 | self.kind = Some(kind.into()); |
391 | self | 391 | self |
392 | } | 392 | } |
393 | pub(crate) fn text_edit(mut self, edit: TextEdit) -> Builder { | 393 | pub(crate) fn text_edit(mut self, edit: TextEdit) -> Builder { |
diff --git a/crates/completion/src/render.rs b/crates/completion/src/render.rs index 68556c8ce..8f66f6e59 100644 --- a/crates/completion/src/render.rs +++ b/crates/completion/src/render.rs | |||
@@ -13,7 +13,7 @@ mod builder_ext; | |||
13 | use hir::{ | 13 | use hir::{ |
14 | AsAssocItem, Documentation, HasAttrs, HirDisplay, ModuleDef, Mutability, ScopeDef, Type, | 14 | AsAssocItem, Documentation, HasAttrs, HirDisplay, ModuleDef, Mutability, ScopeDef, Type, |
15 | }; | 15 | }; |
16 | use ide_db::{helpers::SnippetCap, RootDatabase}; | 16 | use ide_db::{helpers::SnippetCap, RootDatabase, SymbolKind}; |
17 | use syntax::TextRange; | 17 | use syntax::TextRange; |
18 | use test_utils::mark; | 18 | use test_utils::mark; |
19 | 19 | ||
@@ -146,7 +146,7 @@ impl<'a> Render<'a> { | |||
146 | self.ctx.source_range(), | 146 | self.ctx.source_range(), |
147 | name.to_string(), | 147 | name.to_string(), |
148 | ) | 148 | ) |
149 | .kind(CompletionItemKind::Field) | 149 | .kind(SymbolKind::Field) |
150 | .detail(ty.display(self.ctx.db()).to_string()) | 150 | .detail(ty.display(self.ctx.db()).to_string()) |
151 | .set_documentation(field.docs(self.ctx.db())) | 151 | .set_documentation(field.docs(self.ctx.db())) |
152 | .set_deprecated(is_deprecated); | 152 | .set_deprecated(is_deprecated); |
@@ -160,7 +160,7 @@ impl<'a> Render<'a> { | |||
160 | 160 | ||
161 | fn add_tuple_field(&mut self, field: usize, ty: &Type) -> CompletionItem { | 161 | fn add_tuple_field(&mut self, field: usize, ty: &Type) -> CompletionItem { |
162 | CompletionItem::new(CompletionKind::Reference, self.ctx.source_range(), field.to_string()) | 162 | CompletionItem::new(CompletionKind::Reference, self.ctx.source_range(), field.to_string()) |
163 | .kind(CompletionItemKind::Field) | 163 | .kind(SymbolKind::Field) |
164 | .detail(ty.display(self.ctx.db()).to_string()) | 164 | .detail(ty.display(self.ctx.db()).to_string()) |
165 | .build() | 165 | .build() |
166 | } | 166 | } |
@@ -187,7 +187,7 @@ impl<'a> Render<'a> { | |||
187 | if self.ctx.completion.is_pat_binding_or_const | 187 | if self.ctx.completion.is_pat_binding_or_const |
188 | | self.ctx.completion.is_irrefutable_pat_binding => | 188 | | self.ctx.completion.is_irrefutable_pat_binding => |
189 | { | 189 | { |
190 | CompletionItemKind::EnumVariant | 190 | CompletionItemKind::SymbolKind(SymbolKind::Variant) |
191 | } | 191 | } |
192 | ScopeDef::ModuleDef(Variant(var)) => { | 192 | ScopeDef::ModuleDef(Variant(var)) => { |
193 | let item = render_variant(self.ctx, import_to_add, Some(local_name), *var, None); | 193 | let item = render_variant(self.ctx, import_to_add, Some(local_name), *var, None); |
@@ -198,24 +198,29 @@ impl<'a> Render<'a> { | |||
198 | return item; | 198 | return item; |
199 | } | 199 | } |
200 | 200 | ||
201 | ScopeDef::ModuleDef(Module(..)) => CompletionItemKind::Module, | 201 | ScopeDef::ModuleDef(Module(..)) => CompletionItemKind::SymbolKind(SymbolKind::Module), |
202 | ScopeDef::ModuleDef(Adt(hir::Adt::Struct(_))) => CompletionItemKind::Struct, | 202 | ScopeDef::ModuleDef(Adt(adt)) => CompletionItemKind::SymbolKind(match adt { |
203 | // FIXME: add CompletionItemKind::Union | 203 | hir::Adt::Struct(_) => SymbolKind::Struct, |
204 | ScopeDef::ModuleDef(Adt(hir::Adt::Union(_))) => CompletionItemKind::Struct, | 204 | // FIXME: add CompletionItemKind::Union |
205 | ScopeDef::ModuleDef(Adt(hir::Adt::Enum(_))) => CompletionItemKind::Enum, | 205 | hir::Adt::Union(_) => SymbolKind::Struct, |
206 | ScopeDef::ModuleDef(Const(..)) => CompletionItemKind::Const, | 206 | hir::Adt::Enum(_) => SymbolKind::Enum, |
207 | ScopeDef::ModuleDef(Static(..)) => CompletionItemKind::Static, | 207 | }), |
208 | ScopeDef::ModuleDef(Trait(..)) => CompletionItemKind::Trait, | 208 | ScopeDef::ModuleDef(Const(..)) => CompletionItemKind::SymbolKind(SymbolKind::Const), |
209 | ScopeDef::ModuleDef(TypeAlias(..)) => CompletionItemKind::TypeAlias, | 209 | ScopeDef::ModuleDef(Static(..)) => CompletionItemKind::SymbolKind(SymbolKind::Static), |
210 | ScopeDef::ModuleDef(Trait(..)) => CompletionItemKind::SymbolKind(SymbolKind::Trait), | ||
211 | ScopeDef::ModuleDef(TypeAlias(..)) => { | ||
212 | CompletionItemKind::SymbolKind(SymbolKind::TypeAlias) | ||
213 | } | ||
210 | ScopeDef::ModuleDef(BuiltinType(..)) => CompletionItemKind::BuiltinType, | 214 | ScopeDef::ModuleDef(BuiltinType(..)) => CompletionItemKind::BuiltinType, |
211 | ScopeDef::GenericParam(param) => match param { | 215 | ScopeDef::GenericParam(param) => CompletionItemKind::SymbolKind(match param { |
212 | hir::GenericParam::TypeParam(_) => CompletionItemKind::TypeParam, | 216 | hir::GenericParam::TypeParam(_) => SymbolKind::TypeParam, |
213 | hir::GenericParam::LifetimeParam(_) => CompletionItemKind::LifetimeParam, | 217 | hir::GenericParam::LifetimeParam(_) => SymbolKind::LifetimeParam, |
214 | hir::GenericParam::ConstParam(_) => CompletionItemKind::ConstParam, | 218 | hir::GenericParam::ConstParam(_) => SymbolKind::ConstParam, |
215 | }, | 219 | }), |
216 | ScopeDef::Local(..) => CompletionItemKind::Binding, | 220 | ScopeDef::Local(..) => CompletionItemKind::SymbolKind(SymbolKind::Local), |
217 | // (does this need its own kind?) | 221 | ScopeDef::AdtSelfType(..) | ScopeDef::ImplSelfType(..) => { |
218 | ScopeDef::AdtSelfType(..) | ScopeDef::ImplSelfType(..) => CompletionItemKind::TypeParam, | 222 | CompletionItemKind::SymbolKind(SymbolKind::SelfParam) |
223 | } | ||
219 | ScopeDef::Unknown => { | 224 | ScopeDef::Unknown => { |
220 | let item = CompletionItem::new( | 225 | let item = CompletionItem::new( |
221 | CompletionKind::Reference, | 226 | CompletionKind::Reference, |
diff --git a/crates/completion/src/render/const_.rs b/crates/completion/src/render/const_.rs index e46452d4e..5010b642a 100644 --- a/crates/completion/src/render/const_.rs +++ b/crates/completion/src/render/const_.rs | |||
@@ -1,13 +1,14 @@ | |||
1 | //! Renderer for `const` fields. | 1 | //! Renderer for `const` fields. |
2 | 2 | ||
3 | use hir::HasSource; | 3 | use hir::HasSource; |
4 | use ide_db::SymbolKind; | ||
4 | use syntax::{ | 5 | use syntax::{ |
5 | ast::{Const, NameOwner}, | 6 | ast::{Const, NameOwner}, |
6 | display::const_label, | 7 | display::const_label, |
7 | }; | 8 | }; |
8 | 9 | ||
9 | use crate::{ | 10 | use crate::{ |
10 | item::{CompletionItem, CompletionItemKind, CompletionKind}, | 11 | item::{CompletionItem, CompletionKind}, |
11 | render::RenderContext, | 12 | render::RenderContext, |
12 | }; | 13 | }; |
13 | 14 | ||
@@ -36,7 +37,7 @@ impl<'a> ConstRender<'a> { | |||
36 | let detail = self.detail(); | 37 | let detail = self.detail(); |
37 | 38 | ||
38 | let item = CompletionItem::new(CompletionKind::Reference, self.ctx.source_range(), name) | 39 | let item = CompletionItem::new(CompletionKind::Reference, self.ctx.source_range(), name) |
39 | .kind(CompletionItemKind::Const) | 40 | .kind(SymbolKind::Const) |
40 | .set_documentation(self.ctx.docs(self.const_)) | 41 | .set_documentation(self.ctx.docs(self.const_)) |
41 | .set_deprecated( | 42 | .set_deprecated( |
42 | self.ctx.is_deprecated(self.const_) | 43 | self.ctx.is_deprecated(self.const_) |
diff --git a/crates/completion/src/render/enum_variant.rs b/crates/completion/src/render/enum_variant.rs index 89fb49773..adcddebd1 100644 --- a/crates/completion/src/render/enum_variant.rs +++ b/crates/completion/src/render/enum_variant.rs | |||
@@ -1,11 +1,12 @@ | |||
1 | //! Renderer for `enum` variants. | 1 | //! Renderer for `enum` variants. |
2 | 2 | ||
3 | use hir::{HasAttrs, HirDisplay, ModPath, StructKind}; | 3 | use hir::{HasAttrs, HirDisplay, ModPath, StructKind}; |
4 | use ide_db::SymbolKind; | ||
4 | use itertools::Itertools; | 5 | use itertools::Itertools; |
5 | use test_utils::mark; | 6 | use test_utils::mark; |
6 | 7 | ||
7 | use crate::{ | 8 | use crate::{ |
8 | item::{CompletionItem, CompletionItemKind, CompletionKind, ImportEdit}, | 9 | item::{CompletionItem, CompletionKind, ImportEdit}, |
9 | render::{builder_ext::Params, RenderContext}, | 10 | render::{builder_ext::Params, RenderContext}, |
10 | }; | 11 | }; |
11 | 12 | ||
@@ -60,7 +61,7 @@ impl<'a> EnumRender<'a> { | |||
60 | self.ctx.source_range(), | 61 | self.ctx.source_range(), |
61 | self.qualified_name.clone(), | 62 | self.qualified_name.clone(), |
62 | ) | 63 | ) |
63 | .kind(CompletionItemKind::EnumVariant) | 64 | .kind(SymbolKind::Variant) |
64 | .set_documentation(self.variant.docs(self.ctx.db())) | 65 | .set_documentation(self.variant.docs(self.ctx.db())) |
65 | .set_deprecated(self.ctx.is_deprecated(self.variant)) | 66 | .set_deprecated(self.ctx.is_deprecated(self.variant)) |
66 | .add_import(import_to_add) | 67 | .add_import(import_to_add) |
diff --git a/crates/completion/src/render/function.rs b/crates/completion/src/render/function.rs index 8f4c66211..2d616b1fb 100644 --- a/crates/completion/src/render/function.rs +++ b/crates/completion/src/render/function.rs | |||
@@ -1,6 +1,7 @@ | |||
1 | //! Renderer for function calls. | 1 | //! Renderer for function calls. |
2 | 2 | ||
3 | use hir::{HasSource, Type}; | 3 | use hir::{HasSource, Type}; |
4 | use ide_db::SymbolKind; | ||
4 | use syntax::{ast::Fn, display::function_declaration}; | 5 | use syntax::{ast::Fn, display::function_declaration}; |
5 | use test_utils::mark; | 6 | use test_utils::mark; |
6 | 7 | ||
@@ -105,7 +106,7 @@ impl<'a> FunctionRender<'a> { | |||
105 | if self.func.self_param(self.ctx.db()).is_some() { | 106 | if self.func.self_param(self.ctx.db()).is_some() { |
106 | CompletionItemKind::Method | 107 | CompletionItemKind::Method |
107 | } else { | 108 | } else { |
108 | CompletionItemKind::Function | 109 | SymbolKind::Function.into() |
109 | } | 110 | } |
110 | } | 111 | } |
111 | } | 112 | } |
diff --git a/crates/completion/src/render/macro_.rs b/crates/completion/src/render/macro_.rs index f893e420a..a4535786f 100644 --- a/crates/completion/src/render/macro_.rs +++ b/crates/completion/src/render/macro_.rs | |||
@@ -1,11 +1,12 @@ | |||
1 | //! Renderer for macro invocations. | 1 | //! Renderer for macro invocations. |
2 | 2 | ||
3 | use hir::{Documentation, HasSource}; | 3 | use hir::{Documentation, HasSource}; |
4 | use ide_db::SymbolKind; | ||
4 | use syntax::display::macro_label; | 5 | use syntax::display::macro_label; |
5 | use test_utils::mark; | 6 | use test_utils::mark; |
6 | 7 | ||
7 | use crate::{ | 8 | use crate::{ |
8 | item::{CompletionItem, CompletionItemKind, CompletionKind, ImportEdit}, | 9 | item::{CompletionItem, CompletionKind, ImportEdit}, |
9 | render::RenderContext, | 10 | render::RenderContext, |
10 | }; | 11 | }; |
11 | 12 | ||
@@ -41,7 +42,7 @@ impl<'a> MacroRender<'a> { | |||
41 | fn render(&self, import_to_add: Option<ImportEdit>) -> Option<CompletionItem> { | 42 | fn render(&self, import_to_add: Option<ImportEdit>) -> Option<CompletionItem> { |
42 | let mut builder = | 43 | let mut builder = |
43 | CompletionItem::new(CompletionKind::Reference, self.ctx.source_range(), &self.label()) | 44 | CompletionItem::new(CompletionKind::Reference, self.ctx.source_range(), &self.label()) |
44 | .kind(CompletionItemKind::Macro) | 45 | .kind(SymbolKind::Macro) |
45 | .set_documentation(self.docs.clone()) | 46 | .set_documentation(self.docs.clone()) |
46 | .set_deprecated(self.ctx.is_deprecated(self.macro_)) | 47 | .set_deprecated(self.ctx.is_deprecated(self.macro_)) |
47 | .add_import(import_to_add) | 48 | .add_import(import_to_add) |
diff --git a/crates/completion/src/render/type_alias.rs b/crates/completion/src/render/type_alias.rs index 29287143a..bd97c3692 100644 --- a/crates/completion/src/render/type_alias.rs +++ b/crates/completion/src/render/type_alias.rs | |||
@@ -1,13 +1,14 @@ | |||
1 | //! Renderer for type aliases. | 1 | //! Renderer for type aliases. |
2 | 2 | ||
3 | use hir::HasSource; | 3 | use hir::HasSource; |
4 | use ide_db::SymbolKind; | ||
4 | use syntax::{ | 5 | use syntax::{ |
5 | ast::{NameOwner, TypeAlias}, | 6 | ast::{NameOwner, TypeAlias}, |
6 | display::type_label, | 7 | display::type_label, |
7 | }; | 8 | }; |
8 | 9 | ||
9 | use crate::{ | 10 | use crate::{ |
10 | item::{CompletionItem, CompletionItemKind, CompletionKind}, | 11 | item::{CompletionItem, CompletionKind}, |
11 | render::RenderContext, | 12 | render::RenderContext, |
12 | }; | 13 | }; |
13 | 14 | ||
@@ -36,7 +37,7 @@ impl<'a> TypeAliasRender<'a> { | |||
36 | let detail = self.detail(); | 37 | let detail = self.detail(); |
37 | 38 | ||
38 | let item = CompletionItem::new(CompletionKind::Reference, self.ctx.source_range(), name) | 39 | let item = CompletionItem::new(CompletionKind::Reference, self.ctx.source_range(), name) |
39 | .kind(CompletionItemKind::TypeAlias) | 40 | .kind(SymbolKind::TypeAlias) |
40 | .set_documentation(self.ctx.docs(self.type_alias)) | 41 | .set_documentation(self.ctx.docs(self.type_alias)) |
41 | .set_deprecated( | 42 | .set_deprecated( |
42 | self.ctx.is_deprecated(self.type_alias) | 43 | self.ctx.is_deprecated(self.type_alias) |