diff options
Diffstat (limited to 'crates/completion')
-rw-r--r-- | crates/completion/src/completions/dot.rs | 22 | ||||
-rw-r--r-- | crates/completion/src/completions/flyimport.rs | 16 | ||||
-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/qualified_path.rs | 54 | ||||
-rw-r--r-- | crates/completion/src/completions/record.rs | 8 | ||||
-rw-r--r-- | crates/completion/src/completions/trait_impl.rs | 13 | ||||
-rw-r--r-- | crates/completion/src/completions/unqualified_path.rs | 88 | ||||
-rw-r--r-- | crates/completion/src/item.rs | 75 | ||||
-rw-r--r-- | crates/completion/src/lib.rs | 91 | ||||
-rw-r--r-- | crates/completion/src/render.rs | 118 | ||||
-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 | 10 | ||||
-rw-r--r-- | crates/completion/src/render/macro_.rs | 5 | ||||
-rw-r--r-- | crates/completion/src/render/type_alias.rs | 5 |
16 files changed, 280 insertions, 249 deletions
diff --git a/crates/completion/src/completions/dot.rs b/crates/completion/src/completions/dot.rs index d04eef65a..0880a3830 100644 --- a/crates/completion/src/completions/dot.rs +++ b/crates/completion/src/completions/dot.rs | |||
@@ -83,7 +83,7 @@ fn foo(s: S) { s.$0 } | |||
83 | "#, | 83 | "#, |
84 | expect![[r#" | 84 | expect![[r#" |
85 | fd foo u32 | 85 | fd foo u32 |
86 | me bar() fn bar(&self) | 86 | me bar() -> () |
87 | "#]], | 87 | "#]], |
88 | ); | 88 | ); |
89 | } | 89 | } |
@@ -99,7 +99,7 @@ impl S { | |||
99 | "#, | 99 | "#, |
100 | expect![[r#" | 100 | expect![[r#" |
101 | fd the_field (u32,) | 101 | fd the_field (u32,) |
102 | me foo() fn foo(self) | 102 | me foo() -> () |
103 | "#]], | 103 | "#]], |
104 | ) | 104 | ) |
105 | } | 105 | } |
@@ -115,7 +115,7 @@ impl A { | |||
115 | "#, | 115 | "#, |
116 | expect![[r#" | 116 | expect![[r#" |
117 | fd the_field (u32, i32) | 117 | fd the_field (u32, i32) |
118 | me foo() fn foo(&self) | 118 | me foo() -> () |
119 | "#]], | 119 | "#]], |
120 | ) | 120 | ) |
121 | } | 121 | } |
@@ -165,7 +165,7 @@ mod m { | |||
165 | fn foo(a: A) { a.$0 } | 165 | fn foo(a: A) { a.$0 } |
166 | "#, | 166 | "#, |
167 | expect![[r#" | 167 | expect![[r#" |
168 | me the_method() pub(crate) fn the_method(&self) | 168 | me the_method() -> () |
169 | "#]], | 169 | "#]], |
170 | ); | 170 | ); |
171 | } | 171 | } |
@@ -198,7 +198,7 @@ impl A<i32> { | |||
198 | fn foo(a: A<u32>) { a.$0 } | 198 | fn foo(a: A<u32>) { a.$0 } |
199 | "#, | 199 | "#, |
200 | expect![[r#" | 200 | expect![[r#" |
201 | me the_method() fn the_method(&self) | 201 | me the_method() -> () |
202 | "#]], | 202 | "#]], |
203 | ) | 203 | ) |
204 | } | 204 | } |
@@ -213,7 +213,7 @@ impl Trait for A {} | |||
213 | fn foo(a: A) { a.$0 } | 213 | fn foo(a: A) { a.$0 } |
214 | "#, | 214 | "#, |
215 | expect![[r#" | 215 | expect![[r#" |
216 | me the_method() fn the_method(&self) | 216 | me the_method() -> () |
217 | "#]], | 217 | "#]], |
218 | ); | 218 | ); |
219 | } | 219 | } |
@@ -228,7 +228,7 @@ impl<T> Trait for T {} | |||
228 | fn foo(a: &A) { a.$0 } | 228 | fn foo(a: &A) { a.$0 } |
229 | ", | 229 | ", |
230 | expect![[r#" | 230 | expect![[r#" |
231 | me the_method() fn the_method(&self) | 231 | me the_method() -> () |
232 | "#]], | 232 | "#]], |
233 | ); | 233 | ); |
234 | } | 234 | } |
@@ -246,7 +246,7 @@ impl Trait for A {} | |||
246 | fn foo(a: A) { a.$0 } | 246 | fn foo(a: A) { a.$0 } |
247 | ", | 247 | ", |
248 | expect![[r#" | 248 | expect![[r#" |
249 | me the_method() fn the_method(&self) | 249 | me the_method() -> () |
250 | "#]], | 250 | "#]], |
251 | ); | 251 | ); |
252 | } | 252 | } |
@@ -300,7 +300,7 @@ impl T { | |||
300 | } | 300 | } |
301 | "#, | 301 | "#, |
302 | expect![[r#" | 302 | expect![[r#" |
303 | me blah() pub fn blah(&self) | 303 | me blah() -> () |
304 | "#]], | 304 | "#]], |
305 | ); | 305 | ); |
306 | } | 306 | } |
@@ -409,7 +409,7 @@ fn foo() { | |||
409 | } | 409 | } |
410 | "#, | 410 | "#, |
411 | expect![[r#" | 411 | expect![[r#" |
412 | me the_method() pub fn the_method(&self) | 412 | me the_method() -> () |
413 | "#]], | 413 | "#]], |
414 | ); | 414 | ); |
415 | } | 415 | } |
@@ -424,7 +424,7 @@ macro_rules! make_s { () => { S }; } | |||
424 | fn main() { make_s!().f$0; } | 424 | fn main() { make_s!().f$0; } |
425 | "#, | 425 | "#, |
426 | expect![[r#" | 426 | expect![[r#" |
427 | me foo() fn foo(&self) | 427 | me foo() -> () |
428 | "#]], | 428 | "#]], |
429 | ) | 429 | ) |
430 | } | 430 | } |
diff --git a/crates/completion/src/completions/flyimport.rs b/crates/completion/src/completions/flyimport.rs index dc0b38a16..6591127b1 100644 --- a/crates/completion/src/completions/flyimport.rs +++ b/crates/completion/src/completions/flyimport.rs | |||
@@ -366,8 +366,8 @@ fn main() { | |||
366 | check( | 366 | check( |
367 | fixture, | 367 | fixture, |
368 | expect![[r#" | 368 | expect![[r#" |
369 | fn weird_function() (dep::test_mod::TestTrait) fn weird_function() | 369 | fn weird_function() (dep::test_mod::TestTrait) -> () |
370 | "#]], | 370 | "#]], |
371 | ); | 371 | ); |
372 | 372 | ||
373 | check_edit( | 373 | check_edit( |
@@ -459,8 +459,8 @@ fn main() { | |||
459 | check( | 459 | check( |
460 | fixture, | 460 | fixture, |
461 | expect![[r#" | 461 | expect![[r#" |
462 | me random_method() (dep::test_mod::TestTrait) fn random_method(&self) | 462 | me random_method() (dep::test_mod::TestTrait) -> () |
463 | "#]], | 463 | "#]], |
464 | ); | 464 | ); |
465 | 465 | ||
466 | check_edit( | 466 | check_edit( |
@@ -629,8 +629,8 @@ fn main() { | |||
629 | } | 629 | } |
630 | "#, | 630 | "#, |
631 | expect![[r#" | 631 | expect![[r#" |
632 | me random_method() (dep::test_mod::TestTrait) fn random_method(&self) DEPRECATED | 632 | me random_method() (dep::test_mod::TestTrait) -> () DEPRECATED |
633 | "#]], | 633 | "#]], |
634 | ); | 634 | ); |
635 | 635 | ||
636 | check( | 636 | check( |
@@ -660,8 +660,8 @@ fn main() { | |||
660 | "#, | 660 | "#, |
661 | expect![[r#" | 661 | expect![[r#" |
662 | ct SPECIAL_CONST (dep::test_mod::TestTrait) DEPRECATED | 662 | ct SPECIAL_CONST (dep::test_mod::TestTrait) DEPRECATED |
663 | fn weird_function() (dep::test_mod::TestTrait) fn weird_function() DEPRECATED | 663 | fn weird_function() (dep::test_mod::TestTrait) -> () DEPRECATED |
664 | "#]], | 664 | "#]], |
665 | ); | 665 | ); |
666 | } | 666 | } |
667 | } | 667 | } |
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/qualified_path.rs b/crates/completion/src/completions/qualified_path.rs index 33df26761..bbeaab496 100644 --- a/crates/completion/src/completions/qualified_path.rs +++ b/crates/completion/src/completions/qualified_path.rs | |||
@@ -359,8 +359,8 @@ impl S { | |||
359 | fn foo() { let _ = S::$0 } | 359 | fn foo() { let _ = S::$0 } |
360 | "#, | 360 | "#, |
361 | expect![[r#" | 361 | expect![[r#" |
362 | fn a() fn a() | 362 | fn a() -> () |
363 | me b(…) fn b(&self) | 363 | me b(…) -> () |
364 | ct C const C: i32 = 42; | 364 | ct C const C: i32 = 42; |
365 | ta T type T = i32; | 365 | ta T type T = i32; |
366 | "#]], | 366 | "#]], |
@@ -387,7 +387,7 @@ mod m { | |||
387 | fn foo() { let _ = S::$0 } | 387 | fn foo() { let _ = S::$0 } |
388 | "#, | 388 | "#, |
389 | expect![[r#" | 389 | expect![[r#" |
390 | fn public_method() pub(crate) fn public_method() | 390 | fn public_method() -> () |
391 | ct PUBLIC_CONST pub(crate) const PUBLIC_CONST: u32 = 1; | 391 | ct PUBLIC_CONST pub(crate) const PUBLIC_CONST: u32 = 1; |
392 | ta PublicType pub(crate) type PublicType = u32; | 392 | ta PublicType pub(crate) type PublicType = u32; |
393 | "#]], | 393 | "#]], |
@@ -404,7 +404,7 @@ impl E { fn m() { } } | |||
404 | fn foo() { let _ = E::$0 } | 404 | fn foo() { let _ = E::$0 } |
405 | "#, | 405 | "#, |
406 | expect![[r#" | 406 | expect![[r#" |
407 | fn m() fn m() | 407 | fn m() -> () |
408 | "#]], | 408 | "#]], |
409 | ); | 409 | ); |
410 | } | 410 | } |
@@ -419,7 +419,7 @@ impl U { fn m() { } } | |||
419 | fn foo() { let _ = U::$0 } | 419 | fn foo() { let _ = U::$0 } |
420 | "#, | 420 | "#, |
421 | expect![[r#" | 421 | expect![[r#" |
422 | fn m() fn m() | 422 | fn m() -> () |
423 | "#]], | 423 | "#]], |
424 | ); | 424 | ); |
425 | } | 425 | } |
@@ -449,7 +449,7 @@ trait Trait { fn m(); } | |||
449 | fn foo() { let _ = Trait::$0 } | 449 | fn foo() { let _ = Trait::$0 } |
450 | "#, | 450 | "#, |
451 | expect![[r#" | 451 | expect![[r#" |
452 | fn m() fn m() | 452 | fn m() -> () |
453 | "#]], | 453 | "#]], |
454 | ); | 454 | ); |
455 | } | 455 | } |
@@ -466,7 +466,7 @@ impl Trait for S {} | |||
466 | fn foo() { let _ = S::$0 } | 466 | fn foo() { let _ = S::$0 } |
467 | "#, | 467 | "#, |
468 | expect![[r#" | 468 | expect![[r#" |
469 | fn m() fn m() | 469 | fn m() -> () |
470 | "#]], | 470 | "#]], |
471 | ); | 471 | ); |
472 | } | 472 | } |
@@ -483,7 +483,7 @@ impl Trait for S {} | |||
483 | fn foo() { let _ = <S as Trait>::$0 } | 483 | fn foo() { let _ = <S as Trait>::$0 } |
484 | "#, | 484 | "#, |
485 | expect![[r#" | 485 | expect![[r#" |
486 | fn m() fn m() | 486 | fn m() -> () |
487 | "#]], | 487 | "#]], |
488 | ); | 488 | ); |
489 | } | 489 | } |
@@ -512,11 +512,11 @@ fn foo<T: Sub>() { T::$0 } | |||
512 | ta SubTy type SubTy; | 512 | ta SubTy type SubTy; |
513 | ta Ty type Ty; | 513 | ta Ty type Ty; |
514 | ct C2 const C2: (); | 514 | ct C2 const C2: (); |
515 | fn subfunc() fn subfunc() | 515 | fn subfunc() -> () |
516 | me submethod(…) fn submethod(&self) | 516 | me submethod(…) -> () |
517 | ct CONST const CONST: u8; | 517 | ct CONST const CONST: u8; |
518 | fn func() fn func() | 518 | fn func() -> () |
519 | me method(…) fn method(&self) | 519 | me method(…) -> () |
520 | "#]], | 520 | "#]], |
521 | ); | 521 | ); |
522 | } | 522 | } |
@@ -552,11 +552,11 @@ impl<T> Sub for Wrap<T> { | |||
552 | ta SubTy type SubTy; | 552 | ta SubTy type SubTy; |
553 | ta Ty type Ty; | 553 | ta Ty type Ty; |
554 | ct CONST const CONST: u8 = 0; | 554 | ct CONST const CONST: u8 = 0; |
555 | fn func() fn func() | 555 | fn func() -> () |
556 | me method(…) fn method(&self) | 556 | me method(…) -> () |
557 | ct C2 const C2: () = (); | 557 | ct C2 const C2: () = (); |
558 | fn subfunc() fn subfunc() | 558 | fn subfunc() -> () |
559 | me submethod(…) fn submethod(&self) | 559 | me submethod(…) -> () |
560 | "#]], | 560 | "#]], |
561 | ); | 561 | ); |
562 | } | 562 | } |
@@ -573,8 +573,8 @@ impl T { fn bar() {} } | |||
573 | fn main() { T::$0; } | 573 | fn main() { T::$0; } |
574 | "#, | 574 | "#, |
575 | expect![[r#" | 575 | expect![[r#" |
576 | fn foo() fn foo() | 576 | fn foo() -> () |
577 | fn bar() fn bar() | 577 | fn bar() -> () |
578 | "#]], | 578 | "#]], |
579 | ); | 579 | ); |
580 | } | 580 | } |
@@ -589,7 +589,7 @@ macro_rules! foo { () => {} } | |||
589 | fn main() { let _ = crate::$0 } | 589 | fn main() { let _ = crate::$0 } |
590 | "#, | 590 | "#, |
591 | expect![[r##" | 591 | expect![[r##" |
592 | fn main() fn main() | 592 | fn main() -> () |
593 | ma foo!(…) #[macro_export] macro_rules! foo | 593 | ma foo!(…) #[macro_export] macro_rules! foo |
594 | "##]], | 594 | "##]], |
595 | ); | 595 | ); |
@@ -633,7 +633,7 @@ mod p { | |||
633 | "#, | 633 | "#, |
634 | expect![[r#" | 634 | expect![[r#" |
635 | ct RIGHT_CONST | 635 | ct RIGHT_CONST |
636 | fn right_fn() fn wrong_fn() | 636 | fn right_fn() -> () |
637 | st RightType | 637 | st RightType |
638 | "#]], | 638 | "#]], |
639 | ); | 639 | ); |
@@ -680,8 +680,8 @@ fn main() { m!(self::f$0); } | |||
680 | fn foo() {} | 680 | fn foo() {} |
681 | "#, | 681 | "#, |
682 | expect![[r#" | 682 | expect![[r#" |
683 | fn main() fn main() | 683 | fn main() -> () |
684 | fn foo() fn foo() | 684 | fn foo() -> () |
685 | "#]], | 685 | "#]], |
686 | ); | 686 | ); |
687 | } | 687 | } |
@@ -699,7 +699,7 @@ mod m { | |||
699 | "#, | 699 | "#, |
700 | expect![[r#" | 700 | expect![[r#" |
701 | md z | 701 | md z |
702 | fn z() pub fn z() | 702 | fn z() -> () |
703 | "#]], | 703 | "#]], |
704 | ); | 704 | ); |
705 | } | 705 | } |
@@ -719,7 +719,7 @@ fn foo() { | |||
719 | } | 719 | } |
720 | "#, | 720 | "#, |
721 | expect![[r#" | 721 | expect![[r#" |
722 | fn new() pub fn new() -> HashMap<K, V, RandomState> | 722 | fn new() -> HashMap<K, V, RandomState> |
723 | "#]], | 723 | "#]], |
724 | ); | 724 | ); |
725 | } | 725 | } |
@@ -752,8 +752,8 @@ fn main() { | |||
752 | } | 752 | } |
753 | "#, | 753 | "#, |
754 | expect![[r#" | 754 | expect![[r#" |
755 | fn main() fn main() | 755 | fn main() -> () |
756 | fn foo(…) fn foo(a: i32, b: i32) | 756 | fn foo(…) -> () |
757 | "#]], | 757 | "#]], |
758 | ); | 758 | ); |
759 | } | 759 | } |
@@ -776,7 +776,7 @@ impl Foo { | |||
776 | expect![[r#" | 776 | expect![[r#" |
777 | ev Bar () | 777 | ev Bar () |
778 | ev Baz () | 778 | ev Baz () |
779 | me foo(…) fn foo(self) | 779 | me foo(…) -> () |
780 | "#]], | 780 | "#]], |
781 | ); | 781 | ); |
782 | } | 782 | } |
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..b999540b8 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 | } |
@@ -679,11 +679,6 @@ impl Test for () { | |||
679 | #[test] | 679 | #[test] |
680 | fn complete_without_name() { | 680 | fn complete_without_name() { |
681 | let test = |completion: &str, hint: &str, completed: &str, next_sibling: &str| { | 681 | let test = |completion: &str, hint: &str, completed: &str, next_sibling: &str| { |
682 | println!( | ||
683 | "completion='{}', hint='{}', next_sibling='{}'", | ||
684 | completion, hint, next_sibling | ||
685 | ); | ||
686 | |||
687 | check_edit( | 682 | check_edit( |
688 | completion, | 683 | completion, |
689 | &format!( | 684 | &format!( |
diff --git a/crates/completion/src/completions/unqualified_path.rs b/crates/completion/src/completions/unqualified_path.rs index 809e1645a..5d62fab97 100644 --- a/crates/completion/src/completions/unqualified_path.rs +++ b/crates/completion/src/completions/unqualified_path.rs | |||
@@ -165,9 +165,9 @@ 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(…) -> () |
171 | "#]], | 171 | "#]], |
172 | ); | 172 | ); |
173 | } | 173 | } |
@@ -187,9 +187,9 @@ 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() -> () |
193 | "#]], | 193 | "#]], |
194 | ); | 194 | ); |
195 | } | 195 | } |
@@ -203,8 +203,8 @@ 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() -> () |
208 | "#]], | 208 | "#]], |
209 | ); | 209 | ); |
210 | } | 210 | } |
@@ -235,14 +235,14 @@ fn main() { | |||
235 | r#"fn quux<T>() { $0 }"#, | 235 | r#"fn quux<T>() { $0 }"#, |
236 | expect![[r#" | 236 | expect![[r#" |
237 | tp T | 237 | tp T |
238 | fn quux() fn quux<T>() | 238 | fn quux() -> () |
239 | "#]], | 239 | "#]], |
240 | ); | 240 | ); |
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() -> () |
246 | "#]], | 246 | "#]], |
247 | ); | 247 | ); |
248 | } | 248 | } |
@@ -253,7 +253,7 @@ fn main() { | |||
253 | check( | 253 | check( |
254 | r#"fn quux<'a>() { $0 }"#, | 254 | r#"fn quux<'a>() { $0 }"#, |
255 | expect![[r#" | 255 | expect![[r#" |
256 | fn quux() fn quux<'a>() | 256 | fn quux() -> () |
257 | "#]], | 257 | "#]], |
258 | ); | 258 | ); |
259 | } | 259 | } |
@@ -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 | ); |
@@ -291,7 +291,7 @@ fn quux() { $0 } | |||
291 | "#, | 291 | "#, |
292 | expect![[r#" | 292 | expect![[r#" |
293 | st S | 293 | st S |
294 | fn quux() fn quux() | 294 | fn quux() -> () |
295 | en E | 295 | en E |
296 | "#]], | 296 | "#]], |
297 | ); | 297 | ); |
@@ -344,7 +344,7 @@ mod m { | |||
344 | } | 344 | } |
345 | "#, | 345 | "#, |
346 | expect![[r#" | 346 | expect![[r#" |
347 | fn quux() fn quux() | 347 | fn quux() -> () |
348 | st Bar | 348 | st Bar |
349 | "#]], | 349 | "#]], |
350 | ); | 350 | ); |
@@ -359,7 +359,7 @@ fn x() -> $0 | |||
359 | "#, | 359 | "#, |
360 | expect![[r#" | 360 | expect![[r#" |
361 | st Foo | 361 | st Foo |
362 | fn x() fn x() | 362 | fn x() -> () |
363 | "#]], | 363 | "#]], |
364 | ); | 364 | ); |
365 | } | 365 | } |
@@ -378,9 +378,9 @@ 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() -> () |
384 | "#]], | 384 | "#]], |
385 | ); | 385 | ); |
386 | } | 386 | } |
@@ -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 | } |
@@ -410,7 +410,7 @@ use prelude::*; | |||
410 | mod prelude { struct Option; } | 410 | mod prelude { struct Option; } |
411 | "#, | 411 | "#, |
412 | expect![[r#" | 412 | expect![[r#" |
413 | fn foo() fn foo() | 413 | fn foo() -> () |
414 | md std | 414 | md std |
415 | st Option | 415 | st Option |
416 | "#]], | 416 | "#]], |
@@ -440,7 +440,7 @@ mod macros { | |||
440 | } | 440 | } |
441 | "#, | 441 | "#, |
442 | expect![[r##" | 442 | expect![[r##" |
443 | fn f() fn f() | 443 | fn f() -> () |
444 | ma concat!(…) #[macro_export] macro_rules! concat | 444 | ma concat!(…) #[macro_export] macro_rules! concat |
445 | md std | 445 | md std |
446 | "##]], | 446 | "##]], |
@@ -467,7 +467,7 @@ use prelude::*; | |||
467 | mod prelude { struct String; } | 467 | mod prelude { struct String; } |
468 | "#, | 468 | "#, |
469 | expect![[r#" | 469 | expect![[r#" |
470 | fn foo() fn foo() | 470 | fn foo() -> () |
471 | md std | 471 | md std |
472 | md core | 472 | md core |
473 | st String | 473 | st String |
@@ -498,7 +498,7 @@ fn main() { let v = $0 } | |||
498 | expect![[r##" | 498 | expect![[r##" |
499 | md m1 | 499 | md m1 |
500 | ma baz!(…) #[macro_export] macro_rules! baz | 500 | ma baz!(…) #[macro_export] macro_rules! baz |
501 | fn main() fn main() | 501 | fn main() -> () |
502 | md m2 | 502 | md m2 |
503 | ma bar!(…) macro_rules! bar | 503 | ma bar!(…) macro_rules! bar |
504 | ma foo!(…) macro_rules! foo | 504 | ma foo!(…) macro_rules! foo |
@@ -514,7 +514,7 @@ macro_rules! foo { () => {} } | |||
514 | fn foo() { $0 } | 514 | fn foo() { $0 } |
515 | "#, | 515 | "#, |
516 | expect![[r#" | 516 | expect![[r#" |
517 | fn foo() fn foo() | 517 | fn foo() -> () |
518 | ma foo!(…) macro_rules! foo | 518 | ma foo!(…) macro_rules! foo |
519 | "#]], | 519 | "#]], |
520 | ); | 520 | ); |
@@ -528,7 +528,7 @@ macro_rules! foo { () => {} } | |||
528 | fn main() { let x: $0 } | 528 | fn main() { let x: $0 } |
529 | "#, | 529 | "#, |
530 | expect![[r#" | 530 | expect![[r#" |
531 | fn main() fn main() | 531 | fn main() -> () |
532 | ma foo!(…) macro_rules! foo | 532 | ma foo!(…) macro_rules! foo |
533 | "#]], | 533 | "#]], |
534 | ); | 534 | ); |
@@ -542,7 +542,7 @@ macro_rules! foo { () => {} } | |||
542 | fn main() { $0 } | 542 | fn main() { $0 } |
543 | "#, | 543 | "#, |
544 | expect![[r#" | 544 | expect![[r#" |
545 | fn main() fn main() | 545 | fn main() -> () |
546 | ma foo!(…) macro_rules! foo | 546 | ma foo!(…) macro_rules! foo |
547 | "#]], | 547 | "#]], |
548 | ); | 548 | ); |
@@ -558,8 +558,8 @@ fn main() { | |||
558 | } | 558 | } |
559 | "#, | 559 | "#, |
560 | expect![[r#" | 560 | expect![[r#" |
561 | fn frobnicate() fn frobnicate() | 561 | fn frobnicate() -> () |
562 | fn main() fn main() | 562 | fn main() -> () |
563 | "#]], | 563 | "#]], |
564 | ); | 564 | ); |
565 | } | 565 | } |
@@ -575,9 +575,9 @@ 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(…) -> () |
581 | ma m!(…) macro_rules! m | 581 | ma m!(…) macro_rules! m |
582 | "#]], | 582 | "#]], |
583 | ); | 583 | ); |
@@ -594,9 +594,9 @@ 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(…) -> () |
600 | ma m!(…) macro_rules! m | 600 | ma m!(…) macro_rules! m |
601 | "#]], | 601 | "#]], |
602 | ); | 602 | ); |
@@ -613,9 +613,9 @@ 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(…) -> () |
619 | ma m!(…) macro_rules! m | 619 | ma m!(…) macro_rules! m |
620 | "#]], | 620 | "#]], |
621 | ); | 621 | ); |
@@ -630,7 +630,7 @@ use spam::Quux; | |||
630 | fn main() { $0 } | 630 | fn main() { $0 } |
631 | "#, | 631 | "#, |
632 | expect![[r#" | 632 | expect![[r#" |
633 | fn main() fn main() | 633 | fn main() -> () |
634 | ?? Quux | 634 | ?? Quux |
635 | "#]], | 635 | "#]], |
636 | ); | 636 | ); |
@@ -708,7 +708,7 @@ fn main() { let foo: Foo = Q$0 } | |||
708 | ev Foo::Baz () | 708 | ev Foo::Baz () |
709 | ev Foo::Quux () | 709 | ev Foo::Quux () |
710 | en Foo | 710 | en Foo |
711 | fn main() fn main() | 711 | fn main() -> () |
712 | "#]], | 712 | "#]], |
713 | ) | 713 | ) |
714 | } | 714 | } |
@@ -723,7 +723,7 @@ fn f() -> m::E { V$0 } | |||
723 | expect![[r#" | 723 | expect![[r#" |
724 | ev m::E::V () | 724 | ev m::E::V () |
725 | md m | 725 | md m |
726 | fn f() fn f() -> m::E | 726 | fn f() -> E |
727 | "#]], | 727 | "#]], |
728 | ) | 728 | ) |
729 | } | 729 | } |
@@ -750,7 +750,7 @@ struct MyStruct {} | |||
750 | impl My$0 | 750 | impl 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..eeb952ec3 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,49 +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 { |
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 | ||
133 | impl_from!(SymbolKind for CompletionItemKind); | ||
134 | |||
141 | impl CompletionItemKind { | 135 | impl 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 { |
@@ -394,14 +398,13 @@ impl Builder { | |||
394 | self.insert_text_format = InsertTextFormat::Snippet; | 398 | self.insert_text_format = InsertTextFormat::Snippet; |
395 | self.text_edit(edit) | 399 | self.text_edit(edit) |
396 | } | 400 | } |
397 | #[allow(unused)] | ||
398 | pub(crate) fn detail(self, detail: impl Into<String>) -> Builder { | 401 | pub(crate) fn detail(self, detail: impl Into<String>) -> Builder { |
399 | self.set_detail(Some(detail)) | 402 | self.set_detail(Some(detail)) |
400 | } | 403 | } |
401 | pub(crate) fn set_detail(mut self, detail: Option<impl Into<String>>) -> Builder { | 404 | pub(crate) fn set_detail(mut self, detail: Option<impl Into<String>>) -> Builder { |
402 | self.detail = detail.map(Into::into); | 405 | self.detail = detail.map(Into::into); |
403 | if let Some(detail) = &self.detail { | 406 | if let Some(detail) = &self.detail { |
404 | if assert_never!(detail.contains('\n'), "multiline detail: {}", detail) { | 407 | if assert_never!(detail.contains('\n'), "multiline detail:\n{}", detail) { |
405 | self.detail = Some(detail.splitn(2, '\n').next().unwrap().to_string()); | 408 | self.detail = Some(detail.splitn(2, '\n').next().unwrap().to_string()); |
406 | } | 409 | } |
407 | } | 410 | } |
diff --git a/crates/completion/src/lib.rs b/crates/completion/src/lib.rs index 2c4e54524..db8bfbbc3 100644 --- a/crates/completion/src/lib.rs +++ b/crates/completion/src/lib.rs | |||
@@ -209,25 +209,24 @@ mod tests { | |||
209 | fn test_completion_detail_from_macro_generated_struct_fn_doc_attr() { | 209 | fn test_completion_detail_from_macro_generated_struct_fn_doc_attr() { |
210 | check_detail_and_documentation( | 210 | check_detail_and_documentation( |
211 | r#" | 211 | r#" |
212 | //- /lib.rs | 212 | macro_rules! bar { |
213 | macro_rules! bar { | 213 | () => { |
214 | () => { | 214 | struct Bar; |
215 | struct Bar; | 215 | impl Bar { |
216 | impl Bar { | 216 | #[doc = "Do the foo"] |
217 | #[doc = "Do the foo"] | 217 | fn foo(&self) {} |
218 | fn foo(&self) {} | 218 | } |
219 | } | 219 | } |
220 | } | 220 | } |
221 | } | ||
222 | 221 | ||
223 | bar!(); | 222 | bar!(); |
224 | 223 | ||
225 | fn foo() { | 224 | fn foo() { |
226 | let bar = Bar; | 225 | let bar = Bar; |
227 | bar.fo$0; | 226 | bar.fo$0; |
228 | } | 227 | } |
229 | "#, | 228 | "#, |
230 | DetailAndDocumentation { detail: "fn foo(&self)", documentation: "Do the foo" }, | 229 | DetailAndDocumentation { detail: "-> ()", documentation: "Do the foo" }, |
231 | ); | 230 | ); |
232 | } | 231 | } |
233 | 232 | ||
@@ -235,52 +234,42 @@ mod tests { | |||
235 | fn test_completion_detail_from_macro_generated_struct_fn_doc_comment() { | 234 | fn test_completion_detail_from_macro_generated_struct_fn_doc_comment() { |
236 | check_detail_and_documentation( | 235 | check_detail_and_documentation( |
237 | r#" | 236 | r#" |
238 | //- /lib.rs | 237 | macro_rules! bar { |
239 | macro_rules! bar { | 238 | () => { |
240 | () => { | 239 | struct Bar; |
241 | struct Bar; | 240 | impl Bar { |
242 | impl Bar { | 241 | /// Do the foo |
243 | /// Do the foo | 242 | fn foo(&self) {} |
244 | fn foo(&self) {} | 243 | } |
245 | } | 244 | } |
246 | } | 245 | } |
247 | } | ||
248 | 246 | ||
249 | bar!(); | 247 | bar!(); |
250 | 248 | ||
251 | fn foo() { | 249 | fn foo() { |
252 | let bar = Bar; | 250 | let bar = Bar; |
253 | bar.fo$0; | 251 | bar.fo$0; |
254 | } | 252 | } |
255 | "#, | 253 | "#, |
256 | DetailAndDocumentation { detail: "fn foo(&self)", documentation: " Do the foo" }, | 254 | DetailAndDocumentation { detail: "-> ()", documentation: " Do the foo" }, |
257 | ); | 255 | ); |
258 | } | 256 | } |
259 | 257 | ||
260 | #[test] | 258 | #[test] |
261 | fn test_no_completions_required() { | 259 | fn test_no_completions_required() { |
262 | // There must be no hint for 'in' keyword. | 260 | // There must be no hint for 'in' keyword. |
263 | check_no_completion( | 261 | check_no_completion(r#"fn foo() { for i i$0 }"#); |
264 | r#" | ||
265 | fn foo() { | ||
266 | for i i$0 | ||
267 | } | ||
268 | "#, | ||
269 | ); | ||
270 | // After 'in' keyword hints may be spawned. | 262 | // After 'in' keyword hints may be spawned. |
271 | check_detail_and_documentation( | 263 | check_detail_and_documentation( |
272 | r#" | 264 | r#" |
273 | /// Do the foo | 265 | /// Do the foo |
274 | fn foo() -> &'static str { "foo" } | 266 | fn foo() -> &'static str { "foo" } |
275 | 267 | ||
276 | fn bar() { | 268 | fn bar() { |
277 | for c in fo$0 | 269 | for c in fo$0 |
278 | } | 270 | } |
279 | "#, | 271 | "#, |
280 | DetailAndDocumentation { | 272 | DetailAndDocumentation { detail: "-> &str", documentation: "Do the foo" }, |
281 | detail: "fn foo() -> &'static str", | ||
282 | documentation: "Do the foo", | ||
283 | }, | ||
284 | ); | 273 | ); |
285 | } | 274 | } |
286 | } | 275 | } |
diff --git a/crates/completion/src/render.rs b/crates/completion/src/render.rs index 4f622d28a..e11b881ca 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,20 +198,28 @@ 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 | hir::Adt::Union(_) => SymbolKind::Union, |
205 | ScopeDef::ModuleDef(Adt(hir::Adt::Enum(_))) => CompletionItemKind::Enum, | 205 | hir::Adt::Enum(_) => SymbolKind::Enum, |
206 | ScopeDef::ModuleDef(Const(..)) => CompletionItemKind::Const, | 206 | }), |
207 | ScopeDef::ModuleDef(Static(..)) => CompletionItemKind::Static, | 207 | ScopeDef::ModuleDef(Const(..)) => CompletionItemKind::SymbolKind(SymbolKind::Const), |
208 | ScopeDef::ModuleDef(Trait(..)) => CompletionItemKind::Trait, | 208 | ScopeDef::ModuleDef(Static(..)) => CompletionItemKind::SymbolKind(SymbolKind::Static), |
209 | ScopeDef::ModuleDef(TypeAlias(..)) => CompletionItemKind::TypeAlias, | 209 | ScopeDef::ModuleDef(Trait(..)) => CompletionItemKind::SymbolKind(SymbolKind::Trait), |
210 | ScopeDef::ModuleDef(TypeAlias(..)) => { | ||
211 | CompletionItemKind::SymbolKind(SymbolKind::TypeAlias) | ||
212 | } | ||
210 | ScopeDef::ModuleDef(BuiltinType(..)) => CompletionItemKind::BuiltinType, | 213 | ScopeDef::ModuleDef(BuiltinType(..)) => CompletionItemKind::BuiltinType, |
211 | ScopeDef::GenericParam(..) => CompletionItemKind::TypeParam, | 214 | ScopeDef::GenericParam(param) => CompletionItemKind::SymbolKind(match param { |
212 | ScopeDef::Local(..) => CompletionItemKind::Binding, | 215 | hir::GenericParam::TypeParam(_) => SymbolKind::TypeParam, |
213 | // (does this need its own kind?) | 216 | hir::GenericParam::LifetimeParam(_) => SymbolKind::LifetimeParam, |
214 | ScopeDef::AdtSelfType(..) | ScopeDef::ImplSelfType(..) => CompletionItemKind::TypeParam, | 217 | hir::GenericParam::ConstParam(_) => SymbolKind::ConstParam, |
218 | }), | ||
219 | ScopeDef::Local(..) => CompletionItemKind::SymbolKind(SymbolKind::Local), | ||
220 | ScopeDef::AdtSelfType(..) | ScopeDef::ImplSelfType(..) => { | ||
221 | CompletionItemKind::SymbolKind(SymbolKind::SelfParam) | ||
222 | } | ||
215 | ScopeDef::Unknown => { | 223 | ScopeDef::Unknown => { |
216 | let item = CompletionItem::new( | 224 | let item = CompletionItem::new( |
217 | CompletionKind::Reference, | 225 | CompletionKind::Reference, |
@@ -400,7 +408,9 @@ fn main() { Foo::Fo$0 } | |||
400 | source_range: 54..56, | 408 | source_range: 54..56, |
401 | delete: 54..56, | 409 | delete: 54..56, |
402 | insert: "Foo", | 410 | insert: "Foo", |
403 | kind: EnumVariant, | 411 | kind: SymbolKind( |
412 | Variant, | ||
413 | ), | ||
404 | detail: "{ x: i32, y: i32 }", | 414 | detail: "{ x: i32, y: i32 }", |
405 | }, | 415 | }, |
406 | ] | 416 | ] |
@@ -423,7 +433,9 @@ fn main() { Foo::Fo$0 } | |||
423 | source_range: 46..48, | 433 | source_range: 46..48, |
424 | delete: 46..48, | 434 | delete: 46..48, |
425 | insert: "Foo($0)", | 435 | insert: "Foo($0)", |
426 | kind: EnumVariant, | 436 | kind: SymbolKind( |
437 | Variant, | ||
438 | ), | ||
427 | lookup: "Foo", | 439 | lookup: "Foo", |
428 | detail: "(i32, i32)", | 440 | detail: "(i32, i32)", |
429 | trigger_call_info: true, | 441 | trigger_call_info: true, |
@@ -448,7 +460,9 @@ fn main() { Foo::Fo$0 } | |||
448 | source_range: 35..37, | 460 | source_range: 35..37, |
449 | delete: 35..37, | 461 | delete: 35..37, |
450 | insert: "Foo", | 462 | insert: "Foo", |
451 | kind: EnumVariant, | 463 | kind: SymbolKind( |
464 | Variant, | ||
465 | ), | ||
452 | detail: "()", | 466 | detail: "()", |
453 | }, | 467 | }, |
454 | ] | 468 | ] |
@@ -472,7 +486,9 @@ fn main() { let _: m::Spam = S$0 } | |||
472 | source_range: 75..76, | 486 | source_range: 75..76, |
473 | delete: 75..76, | 487 | delete: 75..76, |
474 | insert: "Spam::Bar($0)", | 488 | insert: "Spam::Bar($0)", |
475 | kind: EnumVariant, | 489 | kind: SymbolKind( |
490 | Variant, | ||
491 | ), | ||
476 | lookup: "Spam::Bar", | 492 | lookup: "Spam::Bar", |
477 | detail: "(i32)", | 493 | detail: "(i32)", |
478 | trigger_call_info: true, | 494 | trigger_call_info: true, |
@@ -482,14 +498,18 @@ fn main() { let _: m::Spam = S$0 } | |||
482 | source_range: 75..76, | 498 | source_range: 75..76, |
483 | delete: 75..76, | 499 | delete: 75..76, |
484 | insert: "m", | 500 | insert: "m", |
485 | kind: Module, | 501 | kind: SymbolKind( |
502 | Module, | ||
503 | ), | ||
486 | }, | 504 | }, |
487 | CompletionItem { | 505 | CompletionItem { |
488 | label: "m::Spam::Foo", | 506 | label: "m::Spam::Foo", |
489 | source_range: 75..76, | 507 | source_range: 75..76, |
490 | delete: 75..76, | 508 | delete: 75..76, |
491 | insert: "m::Spam::Foo", | 509 | insert: "m::Spam::Foo", |
492 | kind: EnumVariant, | 510 | kind: SymbolKind( |
511 | Variant, | ||
512 | ), | ||
493 | lookup: "Spam::Foo", | 513 | lookup: "Spam::Foo", |
494 | detail: "()", | 514 | detail: "()", |
495 | }, | 515 | }, |
@@ -498,9 +518,11 @@ fn main() { let _: m::Spam = S$0 } | |||
498 | source_range: 75..76, | 518 | source_range: 75..76, |
499 | delete: 75..76, | 519 | delete: 75..76, |
500 | insert: "main()$0", | 520 | insert: "main()$0", |
501 | kind: Function, | 521 | kind: SymbolKind( |
522 | Function, | ||
523 | ), | ||
502 | lookup: "main", | 524 | lookup: "main", |
503 | detail: "fn main()", | 525 | detail: "-> ()", |
504 | }, | 526 | }, |
505 | ] | 527 | ] |
506 | "#]], | 528 | "#]], |
@@ -525,18 +547,22 @@ fn main() { som$0 } | |||
525 | source_range: 127..130, | 547 | source_range: 127..130, |
526 | delete: 127..130, | 548 | delete: 127..130, |
527 | insert: "main()$0", | 549 | insert: "main()$0", |
528 | kind: Function, | 550 | kind: SymbolKind( |
551 | Function, | ||
552 | ), | ||
529 | lookup: "main", | 553 | lookup: "main", |
530 | detail: "fn main()", | 554 | detail: "-> ()", |
531 | }, | 555 | }, |
532 | CompletionItem { | 556 | CompletionItem { |
533 | label: "something_deprecated()", | 557 | label: "something_deprecated()", |
534 | source_range: 127..130, | 558 | source_range: 127..130, |
535 | delete: 127..130, | 559 | delete: 127..130, |
536 | insert: "something_deprecated()$0", | 560 | insert: "something_deprecated()$0", |
537 | kind: Function, | 561 | kind: SymbolKind( |
562 | Function, | ||
563 | ), | ||
538 | lookup: "something_deprecated", | 564 | lookup: "something_deprecated", |
539 | detail: "fn something_deprecated()", | 565 | detail: "-> ()", |
540 | deprecated: true, | 566 | deprecated: true, |
541 | }, | 567 | }, |
542 | CompletionItem { | 568 | CompletionItem { |
@@ -544,9 +570,11 @@ fn main() { som$0 } | |||
544 | source_range: 127..130, | 570 | source_range: 127..130, |
545 | delete: 127..130, | 571 | delete: 127..130, |
546 | insert: "something_else_deprecated()$0", | 572 | insert: "something_else_deprecated()$0", |
547 | kind: Function, | 573 | kind: SymbolKind( |
574 | Function, | ||
575 | ), | ||
548 | lookup: "something_else_deprecated", | 576 | lookup: "something_else_deprecated", |
549 | detail: "fn something_else_deprecated()", | 577 | detail: "-> ()", |
550 | deprecated: true, | 578 | deprecated: true, |
551 | }, | 579 | }, |
552 | ] | 580 | ] |
@@ -565,7 +593,9 @@ fn foo() { A { the$0 } } | |||
565 | source_range: 57..60, | 593 | source_range: 57..60, |
566 | delete: 57..60, | 594 | delete: 57..60, |
567 | insert: "the_field", | 595 | insert: "the_field", |
568 | kind: Field, | 596 | kind: SymbolKind( |
597 | Field, | ||
598 | ), | ||
569 | detail: "u32", | 599 | detail: "u32", |
570 | deprecated: true, | 600 | deprecated: true, |
571 | }, | 601 | }, |
@@ -595,7 +625,7 @@ impl S { | |||
595 | insert: "bar()$0", | 625 | insert: "bar()$0", |
596 | kind: Method, | 626 | kind: Method, |
597 | lookup: "bar", | 627 | lookup: "bar", |
598 | detail: "fn bar(self)", | 628 | detail: "-> ()", |
599 | documentation: Documentation( | 629 | documentation: Documentation( |
600 | "Method docs", | 630 | "Method docs", |
601 | ), | 631 | ), |
@@ -605,7 +635,9 @@ impl S { | |||
605 | source_range: 94..94, | 635 | source_range: 94..94, |
606 | delete: 94..94, | 636 | delete: 94..94, |
607 | insert: "foo", | 637 | insert: "foo", |
608 | kind: Field, | 638 | kind: SymbolKind( |
639 | Field, | ||
640 | ), | ||
609 | detail: "{unknown}", | 641 | detail: "{unknown}", |
610 | documentation: Documentation( | 642 | documentation: Documentation( |
611 | "Field docs", | 643 | "Field docs", |
@@ -636,7 +668,9 @@ use self::E::*; | |||
636 | source_range: 10..12, | 668 | source_range: 10..12, |
637 | delete: 10..12, | 669 | delete: 10..12, |
638 | insert: "E", | 670 | insert: "E", |
639 | kind: Enum, | 671 | kind: SymbolKind( |
672 | Enum, | ||
673 | ), | ||
640 | documentation: Documentation( | 674 | documentation: Documentation( |
641 | "enum docs", | 675 | "enum docs", |
642 | ), | 676 | ), |
@@ -646,7 +680,9 @@ use self::E::*; | |||
646 | source_range: 10..12, | 680 | source_range: 10..12, |
647 | delete: 10..12, | 681 | delete: 10..12, |
648 | insert: "V", | 682 | insert: "V", |
649 | kind: EnumVariant, | 683 | kind: SymbolKind( |
684 | Variant, | ||
685 | ), | ||
650 | detail: "()", | 686 | detail: "()", |
651 | documentation: Documentation( | 687 | documentation: Documentation( |
652 | "variant docs", | 688 | "variant docs", |
@@ -657,7 +693,9 @@ use self::E::*; | |||
657 | source_range: 10..12, | 693 | source_range: 10..12, |
658 | delete: 10..12, | 694 | delete: 10..12, |
659 | insert: "my", | 695 | insert: "my", |
660 | kind: Module, | 696 | kind: SymbolKind( |
697 | Module, | ||
698 | ), | ||
661 | documentation: Documentation( | 699 | documentation: Documentation( |
662 | "mod docs", | 700 | "mod docs", |
663 | ), | 701 | ), |
@@ -687,7 +725,7 @@ fn foo(s: S) { s.$0 } | |||
687 | insert: "the_method()$0", | 725 | insert: "the_method()$0", |
688 | kind: Method, | 726 | kind: Method, |
689 | lookup: "the_method", | 727 | lookup: "the_method", |
690 | detail: "fn the_method(&self)", | 728 | detail: "-> ()", |
691 | }, | 729 | }, |
692 | ] | 730 | ] |
693 | "#]], | 731 | "#]], |
@@ -883,7 +921,7 @@ struct WorldSnapshot { _f: () }; | |||
883 | fn go(world: &WorldSnapshot) { go(w$0) } | 921 | fn go(world: &WorldSnapshot) { go(w$0) } |
884 | "#, | 922 | "#, |
885 | expect![[r#" | 923 | expect![[r#" |
886 | bn world [type+name] | 924 | lc world [type+name] |
887 | st WorldSnapshot [] | 925 | st WorldSnapshot [] |
888 | fn go(…) [] | 926 | fn go(…) [] |
889 | "#]], | 927 | "#]], |
@@ -900,7 +938,7 @@ fn f(foo: &Foo) { f(foo, w$0) } | |||
900 | expect![[r#" | 938 | expect![[r#" |
901 | st Foo [] | 939 | st Foo [] |
902 | fn f(…) [] | 940 | fn f(…) [] |
903 | bn foo [] | 941 | lc foo [] |
904 | "#]], | 942 | "#]], |
905 | ); | 943 | ); |
906 | } | 944 | } |
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..e46e21d24 100644 --- a/crates/completion/src/render/function.rs +++ b/crates/completion/src/render/function.rs | |||
@@ -1,7 +1,8 @@ | |||
1 | //! Renderer for function calls. | 1 | //! Renderer for function calls. |
2 | 2 | ||
3 | use hir::{HasSource, Type}; | 3 | use hir::{HasSource, HirDisplay, Type}; |
4 | use syntax::{ast::Fn, display::function_declaration}; | 4 | use ide_db::SymbolKind; |
5 | use syntax::ast::Fn; | ||
5 | use test_utils::mark; | 6 | use test_utils::mark; |
6 | 7 | ||
7 | use crate::{ | 8 | use crate::{ |
@@ -54,7 +55,8 @@ impl<'a> FunctionRender<'a> { | |||
54 | } | 55 | } |
55 | 56 | ||
56 | fn detail(&self) -> String { | 57 | fn detail(&self) -> String { |
57 | function_declaration(&self.ast_node) | 58 | let ty = self.func.ret_type(self.ctx.db()); |
59 | format!("-> {}", ty.display(self.ctx.db())) | ||
58 | } | 60 | } |
59 | 61 | ||
60 | fn add_arg(&self, arg: &str, ty: &Type) -> String { | 62 | fn add_arg(&self, arg: &str, ty: &Type) -> String { |
@@ -105,7 +107,7 @@ impl<'a> FunctionRender<'a> { | |||
105 | if self.func.self_param(self.ctx.db()).is_some() { | 107 | if self.func.self_param(self.ctx.db()).is_some() { |
106 | CompletionItemKind::Method | 108 | CompletionItemKind::Method |
107 | } else { | 109 | } else { |
108 | CompletionItemKind::Function | 110 | SymbolKind::Function.into() |
109 | } | 111 | } |
110 | } | 112 | } |
111 | } | 113 | } |
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) |