aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide/src/completion/complete_path.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2020-04-03 18:33:12 +0100
committerAleksey Kladov <[email protected]>2020-04-03 20:11:05 +0100
commita5e8dfd0247648d8108386f4f98b3af0e48181f7 (patch)
treed745850501442345ffee88fa9fa8f32fa155a088 /crates/ra_ide/src/completion/complete_path.rs
parentb1cf95f691cf919b3933d659e3f394f0e7f292cd (diff)
Add parens for enums
Diffstat (limited to 'crates/ra_ide/src/completion/complete_path.rs')
-rw-r--r--crates/ra_ide/src/completion/complete_path.rs24
1 files changed, 15 insertions, 9 deletions
diff --git a/crates/ra_ide/src/completion/complete_path.rs b/crates/ra_ide/src/completion/complete_path.rs
index 3db17f15f..3ed2ae2b6 100644
--- a/crates/ra_ide/src/completion/complete_path.rs
+++ b/crates/ra_ide/src/completion/complete_path.rs
@@ -38,7 +38,7 @@ pub(super) fn complete_path(acc: &mut Completions, ctx: &CompletionContext) {
38 hir::ModuleDef::Adt(_) | hir::ModuleDef::TypeAlias(_) => { 38 hir::ModuleDef::Adt(_) | hir::ModuleDef::TypeAlias(_) => {
39 if let hir::ModuleDef::Adt(Adt::Enum(e)) = def { 39 if let hir::ModuleDef::Adt(Adt::Enum(e)) = def {
40 for variant in e.variants(ctx.db) { 40 for variant in e.variants(ctx.db) {
41 acc.add_enum_variant(ctx, variant); 41 acc.add_enum_variant(ctx, variant, None);
42 } 42 }
43 } 43 }
44 let ty = match def { 44 let ty = match def {
@@ -58,7 +58,7 @@ pub(super) fn complete_path(acc: &mut Completions, ctx: &CompletionContext) {
58 match item { 58 match item {
59 hir::AssocItem::Function(func) => { 59 hir::AssocItem::Function(func) => {
60 if !func.has_self_param(ctx.db) { 60 if !func.has_self_param(ctx.db) {
61 acc.add_function(ctx, func); 61 acc.add_function(ctx, func, None);
62 } 62 }
63 } 63 }
64 hir::AssocItem::Const(ct) => acc.add_const(ctx, ct), 64 hir::AssocItem::Const(ct) => acc.add_const(ctx, ct),
@@ -87,7 +87,7 @@ pub(super) fn complete_path(acc: &mut Completions, ctx: &CompletionContext) {
87 match item { 87 match item {
88 hir::AssocItem::Function(func) => { 88 hir::AssocItem::Function(func) => {
89 if !func.has_self_param(ctx.db) { 89 if !func.has_self_param(ctx.db) {
90 acc.add_function(ctx, func); 90 acc.add_function(ctx, func, None);
91 } 91 }
92 } 92 }
93 hir::AssocItem::Const(ct) => acc.add_const(ctx, ct), 93 hir::AssocItem::Const(ct) => acc.add_const(ctx, ct),
@@ -355,15 +355,17 @@ mod tests {
355 @r###" 355 @r###"
356 [ 356 [
357 CompletionItem { 357 CompletionItem {
358 label: "Bar", 358 label: "Bar(…)",
359 source_range: [116; 116), 359 source_range: [116; 116),
360 delete: [116; 116), 360 delete: [116; 116),
361 insert: "Bar", 361 insert: "Bar($0)",
362 kind: EnumVariant, 362 kind: EnumVariant,
363 lookup: "Bar",
363 detail: "(i32)", 364 detail: "(i32)",
364 documentation: Documentation( 365 documentation: Documentation(
365 "Bar Variant with i32", 366 "Bar Variant with i32",
366 ), 367 ),
368 trigger_call_info: true,
367 }, 369 },
368 CompletionItem { 370 CompletionItem {
369 label: "Foo", 371 label: "Foo",
@@ -403,15 +405,17 @@ mod tests {
403 @r###" 405 @r###"
404 [ 406 [
405 CompletionItem { 407 CompletionItem {
406 label: "Bar", 408 label: "Bar(…)",
407 source_range: [180; 180), 409 source_range: [180; 180),
408 delete: [180; 180), 410 delete: [180; 180),
409 insert: "Bar", 411 insert: "Bar($0)",
410 kind: EnumVariant, 412 kind: EnumVariant,
413 lookup: "Bar",
411 detail: "(i32, u32)", 414 detail: "(i32, u32)",
412 documentation: Documentation( 415 documentation: Documentation(
413 "Bar Variant with i32 and u32", 416 "Bar Variant with i32 and u32",
414 ), 417 ),
418 trigger_call_info: true,
415 }, 419 },
416 CompletionItem { 420 CompletionItem {
417 label: "Foo", 421 label: "Foo",
@@ -425,15 +429,17 @@ mod tests {
425 ), 429 ),
426 }, 430 },
427 CompletionItem { 431 CompletionItem {
428 label: "S", 432 label: "S(…)",
429 source_range: [180; 180), 433 source_range: [180; 180),
430 delete: [180; 180), 434 delete: [180; 180),
431 insert: "S", 435 insert: "S($0)",
432 kind: EnumVariant, 436 kind: EnumVariant,
437 lookup: "S",
433 detail: "(S)", 438 detail: "(S)",
434 documentation: Documentation( 439 documentation: Documentation(
435 "", 440 "",
436 ), 441 ),
442 trigger_call_info: true,
437 }, 443 },
438 ] 444 ]
439 "### 445 "###