aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/completion/src/completions/fn_param.rs4
-rw-r--r--crates/completion/src/completions/mod_.rs10
-rw-r--r--crates/completion/src/completions/record.rs8
-rw-r--r--crates/completion/src/completions/trait_impl.rs8
-rw-r--r--crates/completion/src/item.rs70
-rw-r--r--crates/completion/src/render.rs47
-rw-r--r--crates/completion/src/render/const_.rs5
-rw-r--r--crates/completion/src/render/enum_variant.rs5
-rw-r--r--crates/completion/src/render/function.rs3
-rw-r--r--crates/completion/src/render/macro_.rs5
-rw-r--r--crates/completion/src/render/type_alias.rs5
-rw-r--r--crates/ide_db/src/lib.rs28
-rw-r--r--crates/rust-analyzer/src/to_proto.rs36
13 files changed, 126 insertions, 108 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
9use crate::{CompletionContext, CompletionItem, CompletionKind, Completions}; 9use 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 @@
3use std::iter; 3use std::iter;
4 4
5use hir::{Module, ModuleSource}; 5use hir::{Module, ModuleSource};
6use ide_db::base_db::{SourceDatabaseExt, VfsPath}; 6use ide_db::{
7use ide_db::RootDatabase; 7 base_db::{SourceDatabaseExt, VfsPath},
8 RootDatabase, SymbolKind,
9};
8use rustc_hash::FxHashSet; 10use rustc_hash::FxHashSet;
9 11
10use crate::{CompletionItem, CompletionItemKind}; 12use crate::CompletionItem;
11 13
12use crate::{context::CompletionContext, item::CompletionKind, Completions}; 14use 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.
2use ide_db::helpers::FamousDefs; 2use ide_db::{helpers::FamousDefs, SymbolKind};
3use syntax::ast::Expr; 3use syntax::ast::Expr;
4 4
5use crate::{ 5use crate::{item::CompletionKind, CompletionContext, CompletionItem, Completions};
6 item::CompletionKind, CompletionContext, CompletionItem, CompletionItemKind, Completions,
7};
8 6
9pub(crate) fn complete_record(acc: &mut Completions, ctx: &CompletionContext) -> Option<()> { 7pub(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
34use hir::{self, HasAttrs, HasSource}; 34use hir::{self, HasAttrs, HasSource};
35use ide_db::traits::get_missing_assoc_items; 35use ide_db::{traits::get_missing_assoc_items, SymbolKind};
36use syntax::{ 36use 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 @@
3use std::fmt; 3use std::fmt;
4 4
5use hir::{Documentation, ModPath, Mutability}; 5use hir::{Documentation, ModPath, Mutability};
6use ide_db::helpers::{ 6use 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};
10use stdx::assert_never; 13use stdx::{assert_never, impl_from};
11use syntax::{algo, TextRange}; 14use syntax::{algo, TextRange};
12use text_edit::TextEdit; 15use 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)]
119pub enum CompletionItemKind { 122pub 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
133impl_from!(SymbolKind for CompletionItemKind);
134
143impl CompletionItemKind { 135impl 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;
13use hir::{ 13use hir::{
14 AsAssocItem, Documentation, HasAttrs, HirDisplay, ModuleDef, Mutability, ScopeDef, Type, 14 AsAssocItem, Documentation, HasAttrs, HirDisplay, ModuleDef, Mutability, ScopeDef, Type,
15}; 15};
16use ide_db::{helpers::SnippetCap, RootDatabase}; 16use ide_db::{helpers::SnippetCap, RootDatabase, SymbolKind};
17use syntax::TextRange; 17use syntax::TextRange;
18use test_utils::mark; 18use 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
3use hir::HasSource; 3use hir::HasSource;
4use ide_db::SymbolKind;
4use syntax::{ 5use syntax::{
5 ast::{Const, NameOwner}, 6 ast::{Const, NameOwner},
6 display::const_label, 7 display::const_label,
7}; 8};
8 9
9use crate::{ 10use 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
3use hir::{HasAttrs, HirDisplay, ModPath, StructKind}; 3use hir::{HasAttrs, HirDisplay, ModPath, StructKind};
4use ide_db::SymbolKind;
4use itertools::Itertools; 5use itertools::Itertools;
5use test_utils::mark; 6use test_utils::mark;
6 7
7use crate::{ 8use 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
3use hir::{HasSource, Type}; 3use hir::{HasSource, Type};
4use ide_db::SymbolKind;
4use syntax::{ast::Fn, display::function_declaration}; 5use syntax::{ast::Fn, display::function_declaration};
5use test_utils::mark; 6use 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
3use hir::{Documentation, HasSource}; 3use hir::{Documentation, HasSource};
4use ide_db::SymbolKind;
4use syntax::display::macro_label; 5use syntax::display::macro_label;
5use test_utils::mark; 6use test_utils::mark;
6 7
7use crate::{ 8use 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
3use hir::HasSource; 3use hir::HasSource;
4use ide_db::SymbolKind;
4use syntax::{ 5use syntax::{
5 ast::{NameOwner, TypeAlias}, 6 ast::{NameOwner, TypeAlias},
6 display::type_label, 7 display::type_label,
7}; 8};
8 9
9use crate::{ 10use 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)
diff --git a/crates/ide_db/src/lib.rs b/crates/ide_db/src/lib.rs
index ee35d02f5..6eb34b06b 100644
--- a/crates/ide_db/src/lib.rs
+++ b/crates/ide_db/src/lib.rs
@@ -137,24 +137,24 @@ fn line_index(db: &dyn LineIndexDatabase, file_id: FileId) -> Arc<LineIndex> {
137 137
138#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)] 138#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
139pub enum SymbolKind { 139pub enum SymbolKind {
140 Module, 140 Const,
141 Impl,
142 Field,
143 TypeParam,
144 ConstParam, 141 ConstParam,
142 Enum,
143 Field,
144 Function,
145 Impl,
146 Label,
145 LifetimeParam, 147 LifetimeParam,
146 ValueParam,
147 SelfParam,
148 Local, 148 Local,
149 Label, 149 Macro,
150 Function, 150 Module,
151 Const, 151 SelfParam,
152 Static, 152 Static,
153 Struct, 153 Struct,
154 Enum,
155 Variant,
156 Union,
157 TypeAlias,
158 Trait, 154 Trait,
159 Macro, 155 TypeAlias,
156 TypeParam,
157 Union,
158 ValueParam,
159 Variant,
160} 160}
diff --git a/crates/rust-analyzer/src/to_proto.rs b/crates/rust-analyzer/src/to_proto.rs
index 18e8a6d22..96f915f1c 100644
--- a/crates/rust-analyzer/src/to_proto.rs
+++ b/crates/rust-analyzer/src/to_proto.rs
@@ -91,24 +91,32 @@ pub(crate) fn completion_item_kind(
91 CompletionItemKind::Attribute => lsp_types::CompletionItemKind::EnumMember, 91 CompletionItemKind::Attribute => lsp_types::CompletionItemKind::EnumMember,
92 CompletionItemKind::Binding => lsp_types::CompletionItemKind::Variable, 92 CompletionItemKind::Binding => lsp_types::CompletionItemKind::Variable,
93 CompletionItemKind::BuiltinType => lsp_types::CompletionItemKind::Struct, 93 CompletionItemKind::BuiltinType => lsp_types::CompletionItemKind::Struct,
94 CompletionItemKind::Const => lsp_types::CompletionItemKind::Constant,
95 CompletionItemKind::ConstParam => lsp_types::CompletionItemKind::TypeParameter,
96 CompletionItemKind::Enum => lsp_types::CompletionItemKind::Enum,
97 CompletionItemKind::EnumVariant => lsp_types::CompletionItemKind::EnumMember,
98 CompletionItemKind::Field => lsp_types::CompletionItemKind::Field,
99 CompletionItemKind::Function => lsp_types::CompletionItemKind::Function,
100 CompletionItemKind::Keyword => lsp_types::CompletionItemKind::Keyword, 94 CompletionItemKind::Keyword => lsp_types::CompletionItemKind::Keyword,
101 CompletionItemKind::LifetimeParam => lsp_types::CompletionItemKind::TypeParameter,
102 CompletionItemKind::Macro => lsp_types::CompletionItemKind::Method,
103 CompletionItemKind::Method => lsp_types::CompletionItemKind::Method, 95 CompletionItemKind::Method => lsp_types::CompletionItemKind::Method,
104 CompletionItemKind::Module => lsp_types::CompletionItemKind::Module,
105 CompletionItemKind::Snippet => lsp_types::CompletionItemKind::Snippet, 96 CompletionItemKind::Snippet => lsp_types::CompletionItemKind::Snippet,
106 CompletionItemKind::Static => lsp_types::CompletionItemKind::Value,
107 CompletionItemKind::Struct => lsp_types::CompletionItemKind::Struct,
108 CompletionItemKind::Trait => lsp_types::CompletionItemKind::Interface,
109 CompletionItemKind::TypeAlias => lsp_types::CompletionItemKind::Struct,
110 CompletionItemKind::TypeParam => lsp_types::CompletionItemKind::TypeParameter,
111 CompletionItemKind::UnresolvedReference => lsp_types::CompletionItemKind::Reference, 97 CompletionItemKind::UnresolvedReference => lsp_types::CompletionItemKind::Reference,
98 CompletionItemKind::SymbolKind(symbol) => match symbol {
99 SymbolKind::Const => lsp_types::CompletionItemKind::Constant,
100 SymbolKind::ConstParam => lsp_types::CompletionItemKind::TypeParameter,
101 SymbolKind::Enum => lsp_types::CompletionItemKind::Enum,
102 SymbolKind::Field => lsp_types::CompletionItemKind::Field,
103 SymbolKind::Function => lsp_types::CompletionItemKind::Function,
104 SymbolKind::Impl => lsp_types::CompletionItemKind::Text,
105 SymbolKind::Label => lsp_types::CompletionItemKind::Variable,
106 SymbolKind::LifetimeParam => lsp_types::CompletionItemKind::TypeParameter,
107 SymbolKind::Local => lsp_types::CompletionItemKind::Variable,
108 SymbolKind::Macro => lsp_types::CompletionItemKind::Method,
109 SymbolKind::Module => lsp_types::CompletionItemKind::Module,
110 SymbolKind::SelfParam => lsp_types::CompletionItemKind::Value,
111 SymbolKind::Static => lsp_types::CompletionItemKind::Value,
112 SymbolKind::Struct => lsp_types::CompletionItemKind::Struct,
113 SymbolKind::Trait => lsp_types::CompletionItemKind::Interface,
114 SymbolKind::TypeAlias => lsp_types::CompletionItemKind::Struct,
115 SymbolKind::TypeParam => lsp_types::CompletionItemKind::TypeParameter,
116 SymbolKind::Union => lsp_types::CompletionItemKind::Struct,
117 SymbolKind::ValueParam => lsp_types::CompletionItemKind::Value,
118 SymbolKind::Variant => lsp_types::CompletionItemKind::EnumMember,
119 },
112 } 120 }
113} 121}
114 122