aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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/completions/unqualified_path.rs38
-rw-r--r--crates/completion/src/item.rs72
-rw-r--r--crates/completion/src/render.rs107
-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/src/display/navigation_target.rs25
-rw-r--r--crates/ide/src/file_structure.rs3
-rw-r--r--crates/ide/src/lib.rs2
-rw-r--r--crates/ide/src/runnables.rs4
-rw-r--r--crates/ide/src/syntax_highlighting.rs4
-rw-r--r--crates/ide/src/syntax_highlighting/format.rs3
-rw-r--r--crates/ide/src/syntax_highlighting/highlight.rs4
-rw-r--r--crates/ide/src/syntax_highlighting/tags.rs2
-rw-r--r--crates/ide_db/src/lib.rs24
-rw-r--r--crates/rust-analyzer/src/handlers.rs3
-rw-r--r--crates/rust-analyzer/src/to_proto.rs45
23 files changed, 225 insertions, 164 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/completions/unqualified_path.rs b/crates/completion/src/completions/unqualified_path.rs
index 809e1645a..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) {
165} 165}
166"#, 166"#,
167 expect![[r#" 167 expect![[r#"
168 bn y i32 168 lc y i32
169 bn x i32 169 lc x i32
170 fn quux(…) fn quux(x: i32) 170 fn quux(…) fn quux(x: i32)
171 "#]], 171 "#]],
172 ); 172 );
@@ -187,8 +187,8 @@ fn quux() {
187} 187}
188"#, 188"#,
189 expect![[r#" 189 expect![[r#"
190 bn b i32 190 lc b i32
191 bn a 191 lc a
192 fn quux() fn quux() 192 fn quux() fn quux()
193 "#]], 193 "#]],
194 ); 194 );
@@ -203,7 +203,7 @@ fn quux() {
203} 203}
204"#, 204"#,
205 expect![[r#" 205 expect![[r#"
206 bn x 206 lc x
207 fn quux() fn quux() 207 fn quux() fn quux()
208 "#]], 208 "#]],
209 ); 209 );
@@ -241,7 +241,7 @@ fn main() {
241 check( 241 check(
242 r#"fn quux<const C: usize>() { $0 }"#, 242 r#"fn quux<const C: usize>() { $0 }"#,
243 expect![[r#" 243 expect![[r#"
244 tp C 244 cp C
245 fn quux() fn quux<const C: usize>() 245 fn quux() fn quux<const C: usize>()
246 "#]], 246 "#]],
247 ); 247 );
@@ -263,7 +263,7 @@ fn main() {
263 check( 263 check(
264 r#"struct S<T> { x: $0}"#, 264 r#"struct S<T> { x: $0}"#,
265 expect![[r#" 265 expect![[r#"
266 tp Self 266 sp Self
267 tp T 267 tp T
268 st S<…> 268 st S<…>
269 "#]], 269 "#]],
@@ -275,7 +275,7 @@ fn main() {
275 check( 275 check(
276 r#"enum X { Y($0) }"#, 276 r#"enum X { Y($0) }"#,
277 expect![[r#" 277 expect![[r#"
278 tp Self 278 sp Self
279 en X 279 en X
280 "#]], 280 "#]],
281 ); 281 );
@@ -378,8 +378,8 @@ fn foo() {
378"#, 378"#,
379 // FIXME: should be only one bar here 379 // FIXME: should be only one bar here
380 expect![[r#" 380 expect![[r#"
381 bn bar i32 381 lc bar i32
382 bn bar i32 382 lc bar i32
383 fn foo() fn foo() 383 fn foo() fn foo()
384 "#]], 384 "#]],
385 ); 385 );
@@ -390,8 +390,8 @@ fn foo() {
390 check( 390 check(
391 r#"impl S { fn foo(&self) { $0 } }"#, 391 r#"impl S { fn foo(&self) { $0 } }"#,
392 expect![[r#" 392 expect![[r#"
393 bn self &{unknown} 393 lc self &{unknown}
394 tp Self 394 sp Self
395 "#]], 395 "#]],
396 ); 396 );
397 } 397 }
@@ -575,8 +575,8 @@ fn quux(x: i32) {
575} 575}
576"#, 576"#,
577 expect![[r#" 577 expect![[r#"
578 bn y i32 578 lc y i32
579 bn x i32 579 lc x i32
580 fn quux(…) fn quux(x: i32) 580 fn quux(…) fn quux(x: i32)
581 ma m!(…) macro_rules! m 581 ma m!(…) macro_rules! m
582 "#]], 582 "#]],
@@ -594,8 +594,8 @@ fn quux(x: i32) {
594} 594}
595", 595",
596 expect![[r#" 596 expect![[r#"
597 bn y i32 597 lc y i32
598 bn x i32 598 lc x i32
599 fn quux(…) fn quux(x: i32) 599 fn quux(…) fn quux(x: i32)
600 ma m!(…) macro_rules! m 600 ma m!(…) macro_rules! m
601 "#]], 601 "#]],
@@ -613,8 +613,8 @@ fn quux(x: i32) {
613} 613}
614"#, 614"#,
615 expect![[r#" 615 expect![[r#"
616 bn y i32 616 lc y i32
617 bn x i32 617 lc x i32
618 fn quux(…) fn quux(x: i32) 618 fn quux(…) fn quux(x: i32)
619 ma m!(…) macro_rules! m 619 ma m!(…) macro_rules! m
620 "#]], 620 "#]],
@@ -750,7 +750,7 @@ struct MyStruct {}
750impl My$0 750impl My$0
751"#, 751"#,
752 expect![[r#" 752 expect![[r#"
753 tp Self 753 sp Self
754 tt MyTrait 754 tt MyTrait
755 st MyStruct 755 st MyStruct
756 "#]], 756 "#]],
diff --git a/crates/completion/src/item.rs b/crates/completion/src/item.rs
index 4147853e7..d2e6a6aeb 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,49 +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 {
120 Snippet, 123 SymbolKind(SymbolKind),
121 Keyword, 124 Attribute,
122 Module,
123 Function,
124 BuiltinType,
125 Struct,
126 Enum,
127 EnumVariant,
128 Binding, 125 Binding,
129 Field, 126 BuiltinType,
130 Static, 127 Keyword,
131 Const,
132 Trait,
133 TypeAlias,
134 Method, 128 Method,
135 TypeParam, 129 Snippet,
136 Macro,
137 Attribute,
138 UnresolvedReference, 130 UnresolvedReference,
139} 131}
140 132
133impl_from!(SymbolKind for CompletionItemKind);
134
141impl CompletionItemKind { 135impl CompletionItemKind {
142 #[cfg(test)] 136 #[cfg(test)]
143 pub(crate) fn tag(&self) -> &'static str { 137 pub(crate) fn tag(&self) -> &'static str {
144 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 },
145 CompletionItemKind::Attribute => "at", 161 CompletionItemKind::Attribute => "at",
146 CompletionItemKind::Binding => "bn", 162 CompletionItemKind::Binding => "bn",
147 CompletionItemKind::BuiltinType => "bt", 163 CompletionItemKind::BuiltinType => "bt",
148 CompletionItemKind::Const => "ct",
149 CompletionItemKind::Enum => "en",
150 CompletionItemKind::EnumVariant => "ev",
151 CompletionItemKind::Field => "fd",
152 CompletionItemKind::Function => "fn",
153 CompletionItemKind::Keyword => "kw", 164 CompletionItemKind::Keyword => "kw",
154 CompletionItemKind::Macro => "ma",
155 CompletionItemKind::Method => "me", 165 CompletionItemKind::Method => "me",
156 CompletionItemKind::Module => "md",
157 CompletionItemKind::Snippet => "sn", 166 CompletionItemKind::Snippet => "sn",
158 CompletionItemKind::Static => "sc",
159 CompletionItemKind::Struct => "st",
160 CompletionItemKind::Trait => "tt",
161 CompletionItemKind::TypeAlias => "ta",
162 CompletionItemKind::TypeParam => "tp",
163 CompletionItemKind::UnresolvedReference => "??", 167 CompletionItemKind::UnresolvedReference => "??",
164 } 168 }
165 } 169 }
@@ -382,8 +386,8 @@ impl Builder {
382 self.insert_text_format = InsertTextFormat::Snippet; 386 self.insert_text_format = InsertTextFormat::Snippet;
383 self.insert_text(snippet) 387 self.insert_text(snippet)
384 } 388 }
385 pub(crate) fn kind(mut self, kind: CompletionItemKind) -> Builder { 389 pub(crate) fn kind(mut self, kind: impl Into<CompletionItemKind>) -> Builder {
386 self.kind = Some(kind); 390 self.kind = Some(kind.into());
387 self 391 self
388 } 392 }
389 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 4f622d28a..fa594b5e5 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,20 +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(..) => CompletionItemKind::TypeParam, 215 ScopeDef::GenericParam(param) => CompletionItemKind::SymbolKind(match param {
212 ScopeDef::Local(..) => CompletionItemKind::Binding, 216 hir::GenericParam::TypeParam(_) => SymbolKind::TypeParam,
213 // (does this need its own kind?) 217 hir::GenericParam::LifetimeParam(_) => SymbolKind::LifetimeParam,
214 ScopeDef::AdtSelfType(..) | ScopeDef::ImplSelfType(..) => CompletionItemKind::TypeParam, 218 hir::GenericParam::ConstParam(_) => SymbolKind::ConstParam,
219 }),
220 ScopeDef::Local(..) => CompletionItemKind::SymbolKind(SymbolKind::Local),
221 ScopeDef::AdtSelfType(..) | ScopeDef::ImplSelfType(..) => {
222 CompletionItemKind::SymbolKind(SymbolKind::SelfParam)
223 }
215 ScopeDef::Unknown => { 224 ScopeDef::Unknown => {
216 let item = CompletionItem::new( 225 let item = CompletionItem::new(
217 CompletionKind::Reference, 226 CompletionKind::Reference,
@@ -400,7 +409,9 @@ fn main() { Foo::Fo$0 }
400 source_range: 54..56, 409 source_range: 54..56,
401 delete: 54..56, 410 delete: 54..56,
402 insert: "Foo", 411 insert: "Foo",
403 kind: EnumVariant, 412 kind: SymbolKind(
413 Variant,
414 ),
404 detail: "{ x: i32, y: i32 }", 415 detail: "{ x: i32, y: i32 }",
405 }, 416 },
406 ] 417 ]
@@ -423,7 +434,9 @@ fn main() { Foo::Fo$0 }
423 source_range: 46..48, 434 source_range: 46..48,
424 delete: 46..48, 435 delete: 46..48,
425 insert: "Foo($0)", 436 insert: "Foo($0)",
426 kind: EnumVariant, 437 kind: SymbolKind(
438 Variant,
439 ),
427 lookup: "Foo", 440 lookup: "Foo",
428 detail: "(i32, i32)", 441 detail: "(i32, i32)",
429 trigger_call_info: true, 442 trigger_call_info: true,
@@ -448,7 +461,9 @@ fn main() { Foo::Fo$0 }
448 source_range: 35..37, 461 source_range: 35..37,
449 delete: 35..37, 462 delete: 35..37,
450 insert: "Foo", 463 insert: "Foo",
451 kind: EnumVariant, 464 kind: SymbolKind(
465 Variant,
466 ),
452 detail: "()", 467 detail: "()",
453 }, 468 },
454 ] 469 ]
@@ -472,7 +487,9 @@ fn main() { let _: m::Spam = S$0 }
472 source_range: 75..76, 487 source_range: 75..76,
473 delete: 75..76, 488 delete: 75..76,
474 insert: "Spam::Bar($0)", 489 insert: "Spam::Bar($0)",
475 kind: EnumVariant, 490 kind: SymbolKind(
491 Variant,
492 ),
476 lookup: "Spam::Bar", 493 lookup: "Spam::Bar",
477 detail: "(i32)", 494 detail: "(i32)",
478 trigger_call_info: true, 495 trigger_call_info: true,
@@ -482,14 +499,18 @@ fn main() { let _: m::Spam = S$0 }
482 source_range: 75..76, 499 source_range: 75..76,
483 delete: 75..76, 500 delete: 75..76,
484 insert: "m", 501 insert: "m",
485 kind: Module, 502 kind: SymbolKind(
503 Module,
504 ),
486 }, 505 },
487 CompletionItem { 506 CompletionItem {
488 label: "m::Spam::Foo", 507 label: "m::Spam::Foo",
489 source_range: 75..76, 508 source_range: 75..76,
490 delete: 75..76, 509 delete: 75..76,
491 insert: "m::Spam::Foo", 510 insert: "m::Spam::Foo",
492 kind: EnumVariant, 511 kind: SymbolKind(
512 Variant,
513 ),
493 lookup: "Spam::Foo", 514 lookup: "Spam::Foo",
494 detail: "()", 515 detail: "()",
495 }, 516 },
@@ -498,7 +519,9 @@ fn main() { let _: m::Spam = S$0 }
498 source_range: 75..76, 519 source_range: 75..76,
499 delete: 75..76, 520 delete: 75..76,
500 insert: "main()$0", 521 insert: "main()$0",
501 kind: Function, 522 kind: SymbolKind(
523 Function,
524 ),
502 lookup: "main", 525 lookup: "main",
503 detail: "fn main()", 526 detail: "fn main()",
504 }, 527 },
@@ -525,7 +548,9 @@ fn main() { som$0 }
525 source_range: 127..130, 548 source_range: 127..130,
526 delete: 127..130, 549 delete: 127..130,
527 insert: "main()$0", 550 insert: "main()$0",
528 kind: Function, 551 kind: SymbolKind(
552 Function,
553 ),
529 lookup: "main", 554 lookup: "main",
530 detail: "fn main()", 555 detail: "fn main()",
531 }, 556 },
@@ -534,7 +559,9 @@ fn main() { som$0 }
534 source_range: 127..130, 559 source_range: 127..130,
535 delete: 127..130, 560 delete: 127..130,
536 insert: "something_deprecated()$0", 561 insert: "something_deprecated()$0",
537 kind: Function, 562 kind: SymbolKind(
563 Function,
564 ),
538 lookup: "something_deprecated", 565 lookup: "something_deprecated",
539 detail: "fn something_deprecated()", 566 detail: "fn something_deprecated()",
540 deprecated: true, 567 deprecated: true,
@@ -544,7 +571,9 @@ fn main() { som$0 }
544 source_range: 127..130, 571 source_range: 127..130,
545 delete: 127..130, 572 delete: 127..130,
546 insert: "something_else_deprecated()$0", 573 insert: "something_else_deprecated()$0",
547 kind: Function, 574 kind: SymbolKind(
575 Function,
576 ),
548 lookup: "something_else_deprecated", 577 lookup: "something_else_deprecated",
549 detail: "fn something_else_deprecated()", 578 detail: "fn something_else_deprecated()",
550 deprecated: true, 579 deprecated: true,
@@ -565,7 +594,9 @@ fn foo() { A { the$0 } }
565 source_range: 57..60, 594 source_range: 57..60,
566 delete: 57..60, 595 delete: 57..60,
567 insert: "the_field", 596 insert: "the_field",
568 kind: Field, 597 kind: SymbolKind(
598 Field,
599 ),
569 detail: "u32", 600 detail: "u32",
570 deprecated: true, 601 deprecated: true,
571 }, 602 },
@@ -605,7 +636,9 @@ impl S {
605 source_range: 94..94, 636 source_range: 94..94,
606 delete: 94..94, 637 delete: 94..94,
607 insert: "foo", 638 insert: "foo",
608 kind: Field, 639 kind: SymbolKind(
640 Field,
641 ),
609 detail: "{unknown}", 642 detail: "{unknown}",
610 documentation: Documentation( 643 documentation: Documentation(
611 "Field docs", 644 "Field docs",
@@ -636,7 +669,9 @@ use self::E::*;
636 source_range: 10..12, 669 source_range: 10..12,
637 delete: 10..12, 670 delete: 10..12,
638 insert: "E", 671 insert: "E",
639 kind: Enum, 672 kind: SymbolKind(
673 Enum,
674 ),
640 documentation: Documentation( 675 documentation: Documentation(
641 "enum docs", 676 "enum docs",
642 ), 677 ),
@@ -646,7 +681,9 @@ use self::E::*;
646 source_range: 10..12, 681 source_range: 10..12,
647 delete: 10..12, 682 delete: 10..12,
648 insert: "V", 683 insert: "V",
649 kind: EnumVariant, 684 kind: SymbolKind(
685 Variant,
686 ),
650 detail: "()", 687 detail: "()",
651 documentation: Documentation( 688 documentation: Documentation(
652 "variant docs", 689 "variant docs",
@@ -657,7 +694,9 @@ use self::E::*;
657 source_range: 10..12, 694 source_range: 10..12,
658 delete: 10..12, 695 delete: 10..12,
659 insert: "my", 696 insert: "my",
660 kind: Module, 697 kind: SymbolKind(
698 Module,
699 ),
661 documentation: Documentation( 700 documentation: Documentation(
662 "mod docs", 701 "mod docs",
663 ), 702 ),
@@ -883,7 +922,7 @@ struct WorldSnapshot { _f: () };
883fn go(world: &WorldSnapshot) { go(w$0) } 922fn go(world: &WorldSnapshot) { go(w$0) }
884"#, 923"#,
885 expect![[r#" 924 expect![[r#"
886 bn world [type+name] 925 lc world [type+name]
887 st WorldSnapshot [] 926 st WorldSnapshot []
888 fn go(…) [] 927 fn go(…) []
889 "#]], 928 "#]],
@@ -900,7 +939,7 @@ fn f(foo: &Foo) { f(foo, w$0) }
900 expect![[r#" 939 expect![[r#"
901 st Foo [] 940 st Foo []
902 fn f(…) [] 941 fn f(…) []
903 bn foo [] 942 lc foo []
904 "#]], 943 "#]],
905 ); 944 );
906 } 945 }
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/src/display/navigation_target.rs b/crates/ide/src/display/navigation_target.rs
index 9c568c90c..16fa828ad 100644
--- a/crates/ide/src/display/navigation_target.rs
+++ b/crates/ide/src/display/navigation_target.rs
@@ -7,6 +7,7 @@ use hir::{AssocItem, Documentation, FieldSource, HasAttrs, HasSource, InFile, Mo
7use ide_db::{ 7use ide_db::{
8 base_db::{FileId, FileRange, SourceDatabase}, 8 base_db::{FileId, FileRange, SourceDatabase},
9 symbol_index::FileSymbolKind, 9 symbol_index::FileSymbolKind,
10 SymbolKind,
10}; 11};
11use ide_db::{defs::Definition, RootDatabase}; 12use ide_db::{defs::Definition, RootDatabase};
12use syntax::{ 13use syntax::{
@@ -18,30 +19,6 @@ use crate::FileSymbol;
18 19
19use super::short_label::ShortLabel; 20use super::short_label::ShortLabel;
20 21
21#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
22pub enum SymbolKind {
23 Module,
24 Impl,
25 Field,
26 TypeParam,
27 ConstParam,
28 LifetimeParam,
29 ValueParam,
30 SelfParam,
31 Local,
32 Label,
33 Function,
34 Const,
35 Static,
36 Struct,
37 Enum,
38 Variant,
39 Union,
40 TypeAlias,
41 Trait,
42 Macro,
43}
44
45/// `NavigationTarget` represents and element in the editor's UI which you can 22/// `NavigationTarget` represents and element in the editor's UI which you can
46/// click on to navigate to a particular piece of code. 23/// click on to navigate to a particular piece of code.
47/// 24///
diff --git a/crates/ide/src/file_structure.rs b/crates/ide/src/file_structure.rs
index 32556dad3..26793bdb4 100644
--- a/crates/ide/src/file_structure.rs
+++ b/crates/ide/src/file_structure.rs
@@ -1,10 +1,9 @@
1use ide_db::SymbolKind;
1use syntax::{ 2use syntax::{
2 ast::{self, AttrsOwner, GenericParamsOwner, NameOwner}, 3 ast::{self, AttrsOwner, GenericParamsOwner, NameOwner},
3 match_ast, AstNode, SourceFile, SyntaxNode, TextRange, WalkEvent, 4 match_ast, AstNode, SourceFile, SyntaxNode, TextRange, WalkEvent,
4}; 5};
5 6
6use crate::SymbolKind;
7
8#[derive(Debug, Clone)] 7#[derive(Debug, Clone)]
9pub struct StructureNode { 8pub struct StructureNode {
10 pub parent: Option<usize>, 9 pub parent: Option<usize>,
diff --git a/crates/ide/src/lib.rs b/crates/ide/src/lib.rs
index 567b8117e..989e94a31 100644
--- a/crates/ide/src/lib.rs
+++ b/crates/ide/src/lib.rs
@@ -65,7 +65,7 @@ use crate::display::ToNav;
65pub use crate::{ 65pub use crate::{
66 call_hierarchy::CallItem, 66 call_hierarchy::CallItem,
67 diagnostics::{Diagnostic, DiagnosticsConfig, Fix, Severity}, 67 diagnostics::{Diagnostic, DiagnosticsConfig, Fix, Severity},
68 display::navigation_target::{NavigationTarget, SymbolKind}, 68 display::navigation_target::NavigationTarget,
69 expand_macro::ExpandedMacro, 69 expand_macro::ExpandedMacro,
70 file_structure::StructureNode, 70 file_structure::StructureNode,
71 folding_ranges::{Fold, FoldKind}, 71 folding_ranges::{Fold, FoldKind},
diff --git a/crates/ide/src/runnables.rs b/crates/ide/src/runnables.rs
index 975abf47f..33170906d 100644
--- a/crates/ide/src/runnables.rs
+++ b/crates/ide/src/runnables.rs
@@ -3,7 +3,7 @@ use std::fmt;
3use assists::utils::test_related_attribute; 3use assists::utils::test_related_attribute;
4use cfg::CfgExpr; 4use cfg::CfgExpr;
5use hir::{AsAssocItem, HasAttrs, HasSource, Semantics}; 5use hir::{AsAssocItem, HasAttrs, HasSource, Semantics};
6use ide_db::{defs::Definition, RootDatabase}; 6use ide_db::{defs::Definition, RootDatabase, SymbolKind};
7use itertools::Itertools; 7use itertools::Itertools;
8use syntax::{ 8use syntax::{
9 ast::{self, AstNode, AttrsOwner}, 9 ast::{self, AstNode, AttrsOwner},
@@ -13,7 +13,7 @@ use test_utils::mark;
13 13
14use crate::{ 14use crate::{
15 display::{ToNav, TryToNav}, 15 display::{ToNav, TryToNav},
16 FileId, NavigationTarget, SymbolKind, 16 FileId, NavigationTarget,
17}; 17};
18 18
19#[derive(Debug, Clone)] 19#[derive(Debug, Clone)]
diff --git a/crates/ide/src/syntax_highlighting.rs b/crates/ide/src/syntax_highlighting.rs
index f2d4da78d..a3d4e4f77 100644
--- a/crates/ide/src/syntax_highlighting.rs
+++ b/crates/ide/src/syntax_highlighting.rs
@@ -13,7 +13,7 @@ mod html;
13mod tests; 13mod tests;
14 14
15use hir::{Name, Semantics}; 15use hir::{Name, Semantics};
16use ide_db::RootDatabase; 16use ide_db::{RootDatabase, SymbolKind};
17use rustc_hash::FxHashMap; 17use rustc_hash::FxHashMap;
18use syntax::{ 18use syntax::{
19 ast::{self, HasFormatSpecifier}, 19 ast::{self, HasFormatSpecifier},
@@ -27,7 +27,7 @@ use crate::{
27 format::highlight_format_string, highlights::Highlights, 27 format::highlight_format_string, highlights::Highlights,
28 macro_rules::MacroRulesHighlighter, tags::Highlight, 28 macro_rules::MacroRulesHighlighter, tags::Highlight,
29 }, 29 },
30 FileId, HlMod, HlTag, SymbolKind, 30 FileId, HlMod, HlTag,
31}; 31};
32 32
33pub(crate) use html::highlight_as_html; 33pub(crate) use html::highlight_as_html;
diff --git a/crates/ide/src/syntax_highlighting/format.rs b/crates/ide/src/syntax_highlighting/format.rs
index 8a9b5ca8c..8c67a0863 100644
--- a/crates/ide/src/syntax_highlighting/format.rs
+++ b/crates/ide/src/syntax_highlighting/format.rs
@@ -1,10 +1,11 @@
1//! Syntax highlighting for format macro strings. 1//! Syntax highlighting for format macro strings.
2use ide_db::SymbolKind;
2use syntax::{ 3use syntax::{
3 ast::{self, FormatSpecifier, HasFormatSpecifier}, 4 ast::{self, FormatSpecifier, HasFormatSpecifier},
4 AstNode, AstToken, TextRange, 5 AstNode, AstToken, TextRange,
5}; 6};
6 7
7use crate::{syntax_highlighting::highlights::Highlights, HlRange, HlTag, SymbolKind}; 8use crate::{syntax_highlighting::highlights::Highlights, HlRange, HlTag};
8 9
9pub(super) fn highlight_format_string( 10pub(super) fn highlight_format_string(
10 stack: &mut Highlights, 11 stack: &mut Highlights,
diff --git a/crates/ide/src/syntax_highlighting/highlight.rs b/crates/ide/src/syntax_highlighting/highlight.rs
index 8625ef5df..24fcbb584 100644
--- a/crates/ide/src/syntax_highlighting/highlight.rs
+++ b/crates/ide/src/syntax_highlighting/highlight.rs
@@ -3,7 +3,7 @@
3use hir::{AsAssocItem, Semantics, VariantDef}; 3use hir::{AsAssocItem, Semantics, VariantDef};
4use ide_db::{ 4use ide_db::{
5 defs::{Definition, NameClass, NameRefClass}, 5 defs::{Definition, NameClass, NameRefClass},
6 RootDatabase, 6 RootDatabase, SymbolKind,
7}; 7};
8use rustc_hash::FxHashMap; 8use rustc_hash::FxHashMap;
9use syntax::{ 9use syntax::{
@@ -12,7 +12,7 @@ use syntax::{
12 SyntaxNode, SyntaxToken, T, 12 SyntaxNode, SyntaxToken, T,
13}; 13};
14 14
15use crate::{syntax_highlighting::tags::HlPunct, Highlight, HlMod, HlTag, SymbolKind}; 15use crate::{syntax_highlighting::tags::HlPunct, Highlight, HlMod, HlTag};
16 16
17pub(super) fn element( 17pub(super) fn element(
18 sema: &Semantics<RootDatabase>, 18 sema: &Semantics<RootDatabase>,
diff --git a/crates/ide/src/syntax_highlighting/tags.rs b/crates/ide/src/syntax_highlighting/tags.rs
index 8dd05ac52..3c02fdb11 100644
--- a/crates/ide/src/syntax_highlighting/tags.rs
+++ b/crates/ide/src/syntax_highlighting/tags.rs
@@ -3,7 +3,7 @@
3 3
4use std::{fmt, ops}; 4use std::{fmt, ops};
5 5
6use crate::SymbolKind; 6use ide_db::SymbolKind;
7 7
8#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] 8#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
9pub struct Highlight { 9pub struct Highlight {
diff --git a/crates/ide_db/src/lib.rs b/crates/ide_db/src/lib.rs
index 118c090d7..6eb34b06b 100644
--- a/crates/ide_db/src/lib.rs
+++ b/crates/ide_db/src/lib.rs
@@ -134,3 +134,27 @@ fn line_index(db: &dyn LineIndexDatabase, file_id: FileId) -> Arc<LineIndex> {
134 let text = db.file_text(file_id); 134 let text = db.file_text(file_id);
135 Arc::new(LineIndex::new(&*text)) 135 Arc::new(LineIndex::new(&*text))
136} 136}
137
138#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
139pub enum SymbolKind {
140 Const,
141 ConstParam,
142 Enum,
143 Field,
144 Function,
145 Impl,
146 Label,
147 LifetimeParam,
148 Local,
149 Macro,
150 Module,
151 SelfParam,
152 Static,
153 Struct,
154 Trait,
155 TypeAlias,
156 TypeParam,
157 Union,
158 ValueParam,
159 Variant,
160}
diff --git a/crates/rust-analyzer/src/handlers.rs b/crates/rust-analyzer/src/handlers.rs
index 42451cd2d..809452e6d 100644
--- a/crates/rust-analyzer/src/handlers.rs
+++ b/crates/rust-analyzer/src/handlers.rs
@@ -10,8 +10,9 @@ use std::{
10 10
11use ide::{ 11use ide::{
12 FileId, FilePosition, FileRange, HoverAction, HoverGotoTypeData, LineIndex, NavigationTarget, 12 FileId, FilePosition, FileRange, HoverAction, HoverGotoTypeData, LineIndex, NavigationTarget,
13 Query, RangeInfo, Runnable, RunnableKind, SearchScope, SourceChange, SymbolKind, TextEdit, 13 Query, RangeInfo, Runnable, RunnableKind, SearchScope, SourceChange, TextEdit,
14}; 14};
15use ide_db::SymbolKind;
15use itertools::Itertools; 16use itertools::Itertools;
16use lsp_server::ErrorCode; 17use lsp_server::ErrorCode;
17use lsp_types::{ 18use lsp_types::{
diff --git a/crates/rust-analyzer/src/to_proto.rs b/crates/rust-analyzer/src/to_proto.rs
index 0e3550002..96f915f1c 100644
--- a/crates/rust-analyzer/src/to_proto.rs
+++ b/crates/rust-analyzer/src/to_proto.rs
@@ -8,8 +8,9 @@ use ide::{
8 Assist, AssistKind, CallInfo, CompletionItem, CompletionItemKind, Documentation, FileId, 8 Assist, AssistKind, CallInfo, CompletionItem, CompletionItemKind, Documentation, FileId,
9 FileRange, FileSystemEdit, Fold, FoldKind, Highlight, HlMod, HlPunct, HlRange, HlTag, Indel, 9 FileRange, FileSystemEdit, Fold, FoldKind, Highlight, HlMod, HlPunct, HlRange, HlTag, Indel,
10 InlayHint, InlayKind, InsertTextFormat, LineIndex, Markup, NavigationTarget, ReferenceAccess, 10 InlayHint, InlayKind, InsertTextFormat, LineIndex, Markup, NavigationTarget, ReferenceAccess,
11 RenameError, Runnable, Severity, SourceChange, SymbolKind, TextEdit, TextRange, TextSize, 11 RenameError, Runnable, Severity, SourceChange, TextEdit, TextRange, TextSize,
12}; 12};
13use ide_db::SymbolKind;
13use itertools::Itertools; 14use itertools::Itertools;
14 15
15use crate::{ 16use crate::{
@@ -87,25 +88,35 @@ pub(crate) fn completion_item_kind(
87 completion_item_kind: CompletionItemKind, 88 completion_item_kind: CompletionItemKind,
88) -> lsp_types::CompletionItemKind { 89) -> lsp_types::CompletionItemKind {
89 match completion_item_kind { 90 match completion_item_kind {
90 CompletionItemKind::Keyword => lsp_types::CompletionItemKind::Keyword, 91 CompletionItemKind::Attribute => lsp_types::CompletionItemKind::EnumMember,
91 CompletionItemKind::Snippet => lsp_types::CompletionItemKind::Snippet,
92 CompletionItemKind::Module => lsp_types::CompletionItemKind::Module,
93 CompletionItemKind::Function => lsp_types::CompletionItemKind::Function,
94 CompletionItemKind::Struct => lsp_types::CompletionItemKind::Struct,
95 CompletionItemKind::Enum => lsp_types::CompletionItemKind::Enum,
96 CompletionItemKind::EnumVariant => lsp_types::CompletionItemKind::EnumMember,
97 CompletionItemKind::BuiltinType => lsp_types::CompletionItemKind::Struct,
98 CompletionItemKind::Binding => lsp_types::CompletionItemKind::Variable, 92 CompletionItemKind::Binding => lsp_types::CompletionItemKind::Variable,
99 CompletionItemKind::Field => lsp_types::CompletionItemKind::Field, 93 CompletionItemKind::BuiltinType => lsp_types::CompletionItemKind::Struct,
100 CompletionItemKind::Trait => lsp_types::CompletionItemKind::Interface, 94 CompletionItemKind::Keyword => lsp_types::CompletionItemKind::Keyword,
101 CompletionItemKind::TypeAlias => lsp_types::CompletionItemKind::Struct,
102 CompletionItemKind::Const => lsp_types::CompletionItemKind::Constant,
103 CompletionItemKind::Static => lsp_types::CompletionItemKind::Value,
104 CompletionItemKind::Method => lsp_types::CompletionItemKind::Method, 95 CompletionItemKind::Method => lsp_types::CompletionItemKind::Method,
105 CompletionItemKind::TypeParam => lsp_types::CompletionItemKind::TypeParameter, 96 CompletionItemKind::Snippet => lsp_types::CompletionItemKind::Snippet,
106 CompletionItemKind::Macro => lsp_types::CompletionItemKind::Method,
107 CompletionItemKind::Attribute => lsp_types::CompletionItemKind::EnumMember,
108 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 },
109 } 120 }
110} 121}
111 122