diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-10-10 16:15:46 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2019-10-10 16:15:46 +0100 |
commit | da190278e900b2f9302fd0ae898d904e3134d938 (patch) | |
tree | a2321ac640ebb44f94eaca103941b6abb6d9379f /crates/ra_ide_api/src | |
parent | ceb6cddb8b63dc283ef7a5fd2abf9bf7662c68fb (diff) | |
parent | 8d3d5cbdb0418e72737158d82bdd64e177960dfa (diff) |
Merge #1981
1981: tweak fn labels in completion r=matklad a=matklad
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_ide_api/src')
-rw-r--r-- | crates/ra_ide_api/src/completion/complete_dot.rs | 14 | ||||
-rw-r--r-- | crates/ra_ide_api/src/completion/complete_path.rs | 12 | ||||
-rw-r--r-- | crates/ra_ide_api/src/completion/complete_scope.rs | 24 | ||||
-rw-r--r-- | crates/ra_ide_api/src/completion/presentation.rs | 19 |
4 files changed, 33 insertions, 36 deletions
diff --git a/crates/ra_ide_api/src/completion/complete_dot.rs b/crates/ra_ide_api/src/completion/complete_dot.rs index 86c11a283..b4df6ee2a 100644 --- a/crates/ra_ide_api/src/completion/complete_dot.rs +++ b/crates/ra_ide_api/src/completion/complete_dot.rs | |||
@@ -121,7 +121,7 @@ mod tests { | |||
121 | @r###" | 121 | @r###" |
122 | [ | 122 | [ |
123 | CompletionItem { | 123 | CompletionItem { |
124 | label: "foo(…)", | 124 | label: "foo()", |
125 | source_range: [187; 187), | 125 | source_range: [187; 187), |
126 | delete: [187; 187), | 126 | delete: [187; 187), |
127 | insert: "foo()$0", | 127 | insert: "foo()$0", |
@@ -161,7 +161,7 @@ mod tests { | |||
161 | @r###" | 161 | @r###" |
162 | [ | 162 | [ |
163 | CompletionItem { | 163 | CompletionItem { |
164 | label: "foo(…)", | 164 | label: "foo()", |
165 | source_range: [126; 126), | 165 | source_range: [126; 126), |
166 | delete: [126; 126), | 166 | delete: [126; 126), |
167 | insert: "foo()$0", | 167 | insert: "foo()$0", |
@@ -214,7 +214,7 @@ mod tests { | |||
214 | @r###" | 214 | @r###" |
215 | [ | 215 | [ |
216 | CompletionItem { | 216 | CompletionItem { |
217 | label: "the_method(…)", | 217 | label: "the_method()", |
218 | source_range: [144; 144), | 218 | source_range: [144; 144), |
219 | delete: [144; 144), | 219 | delete: [144; 144), |
220 | insert: "the_method()$0", | 220 | insert: "the_method()$0", |
@@ -243,7 +243,7 @@ mod tests { | |||
243 | @r###" | 243 | @r###" |
244 | [ | 244 | [ |
245 | CompletionItem { | 245 | CompletionItem { |
246 | label: "the_method(…)", | 246 | label: "the_method()", |
247 | source_range: [151; 151), | 247 | source_range: [151; 151), |
248 | delete: [151; 151), | 248 | delete: [151; 151), |
249 | insert: "the_method()$0", | 249 | insert: "the_method()$0", |
@@ -272,7 +272,7 @@ mod tests { | |||
272 | @r###" | 272 | @r###" |
273 | [ | 273 | [ |
274 | CompletionItem { | 274 | CompletionItem { |
275 | label: "the_method(…)", | 275 | label: "the_method()", |
276 | source_range: [155; 155), | 276 | source_range: [155; 155), |
277 | delete: [155; 155), | 277 | delete: [155; 155), |
278 | insert: "the_method()$0", | 278 | insert: "the_method()$0", |
@@ -324,7 +324,7 @@ mod tests { | |||
324 | @r###" | 324 | @r###" |
325 | [ | 325 | [ |
326 | CompletionItem { | 326 | CompletionItem { |
327 | label: "the_method(…)", | 327 | label: "the_method()", |
328 | source_range: [249; 249), | 328 | source_range: [249; 249), |
329 | delete: [249; 249), | 329 | delete: [249; 249), |
330 | insert: "the_method()$0", | 330 | insert: "the_method()$0", |
@@ -394,7 +394,7 @@ mod tests { | |||
394 | @r###" | 394 | @r###" |
395 | [ | 395 | [ |
396 | CompletionItem { | 396 | CompletionItem { |
397 | label: "blah(…)", | 397 | label: "blah()", |
398 | source_range: [299; 300), | 398 | source_range: [299; 300), |
399 | delete: [299; 300), | 399 | delete: [299; 300), |
400 | insert: "blah()$0", | 400 | insert: "blah()$0", |
diff --git a/crates/ra_ide_api/src/completion/complete_path.rs b/crates/ra_ide_api/src/completion/complete_path.rs index b5e8bf591..23dece73c 100644 --- a/crates/ra_ide_api/src/completion/complete_path.rs +++ b/crates/ra_ide_api/src/completion/complete_path.rs | |||
@@ -378,7 +378,7 @@ mod tests { | |||
378 | @r###" | 378 | @r###" |
379 | [ | 379 | [ |
380 | CompletionItem { | 380 | CompletionItem { |
381 | label: "m(…)", | 381 | label: "m()", |
382 | source_range: [100; 100), | 382 | source_range: [100; 100), |
383 | delete: [100; 100), | 383 | delete: [100; 100), |
384 | insert: "m()$0", | 384 | insert: "m()$0", |
@@ -480,7 +480,7 @@ mod tests { | |||
480 | @r###" | 480 | @r###" |
481 | [ | 481 | [ |
482 | CompletionItem { | 482 | CompletionItem { |
483 | label: "m(…)", | 483 | label: "m()", |
484 | source_range: [100; 100), | 484 | source_range: [100; 100), |
485 | delete: [100; 100), | 485 | delete: [100; 100), |
486 | insert: "m()$0", | 486 | insert: "m()$0", |
@@ -516,7 +516,7 @@ mod tests { | |||
516 | @r###" | 516 | @r###" |
517 | [ | 517 | [ |
518 | CompletionItem { | 518 | CompletionItem { |
519 | label: "m(…)", | 519 | label: "m()", |
520 | source_range: [101; 101), | 520 | source_range: [101; 101), |
521 | delete: [101; 101), | 521 | delete: [101; 101), |
522 | insert: "m()$0", | 522 | insert: "m()$0", |
@@ -576,7 +576,7 @@ mod tests { | |||
576 | @r###" | 576 | @r###" |
577 | [ | 577 | [ |
578 | CompletionItem { | 578 | CompletionItem { |
579 | label: "bar(…)", | 579 | label: "bar()", |
580 | source_range: [185; 185), | 580 | source_range: [185; 185), |
581 | delete: [185; 185), | 581 | delete: [185; 185), |
582 | insert: "bar()$0", | 582 | insert: "bar()$0", |
@@ -585,7 +585,7 @@ mod tests { | |||
585 | detail: "fn bar()", | 585 | detail: "fn bar()", |
586 | }, | 586 | }, |
587 | CompletionItem { | 587 | CompletionItem { |
588 | label: "foo(…)", | 588 | label: "foo()", |
589 | source_range: [185; 185), | 589 | source_range: [185; 185), |
590 | delete: [185; 185), | 590 | delete: [185; 185), |
591 | insert: "foo()$0", | 591 | insert: "foo()$0", |
@@ -624,7 +624,7 @@ mod tests { | |||
624 | detail: "#[macro_export]\nmacro_rules! foo", | 624 | detail: "#[macro_export]\nmacro_rules! foo", |
625 | }, | 625 | }, |
626 | CompletionItem { | 626 | CompletionItem { |
627 | label: "main(…)", | 627 | label: "main()", |
628 | source_range: [179; 179), | 628 | source_range: [179; 179), |
629 | delete: [179; 179), | 629 | delete: [179; 179), |
630 | insert: "main()$0", | 630 | insert: "main()$0", |
diff --git a/crates/ra_ide_api/src/completion/complete_scope.rs b/crates/ra_ide_api/src/completion/complete_scope.rs index b64540365..4e56de3f5 100644 --- a/crates/ra_ide_api/src/completion/complete_scope.rs +++ b/crates/ra_ide_api/src/completion/complete_scope.rs | |||
@@ -211,7 +211,7 @@ mod tests { | |||
211 | detail: "i32", | 211 | detail: "i32", |
212 | }, | 212 | }, |
213 | CompletionItem { | 213 | CompletionItem { |
214 | label: "quux(…)", | 214 | label: "quux()", |
215 | source_range: [242; 242), | 215 | source_range: [242; 242), |
216 | delete: [242; 242), | 216 | delete: [242; 242), |
217 | insert: "quux()$0", | 217 | insert: "quux()$0", |
@@ -239,7 +239,7 @@ mod tests { | |||
239 | @r###" | 239 | @r###" |
240 | [ | 240 | [ |
241 | CompletionItem { | 241 | CompletionItem { |
242 | label: "quux(…)", | 242 | label: "quux()", |
243 | source_range: [95; 95), | 243 | source_range: [95; 95), |
244 | delete: [95; 95), | 244 | delete: [95; 95), |
245 | insert: "quux()$0", | 245 | insert: "quux()$0", |
@@ -279,7 +279,7 @@ mod tests { | |||
279 | kind: TypeParam, | 279 | kind: TypeParam, |
280 | }, | 280 | }, |
281 | CompletionItem { | 281 | CompletionItem { |
282 | label: "quux(…)", | 282 | label: "quux()", |
283 | source_range: [52; 52), | 283 | source_range: [52; 52), |
284 | delete: [52; 52), | 284 | delete: [52; 52), |
285 | insert: "quux()$0", | 285 | insert: "quux()$0", |
@@ -384,7 +384,7 @@ mod tests { | |||
384 | kind: Struct, | 384 | kind: Struct, |
385 | }, | 385 | }, |
386 | CompletionItem { | 386 | CompletionItem { |
387 | label: "quux(…)", | 387 | label: "quux()", |
388 | source_range: [105; 105), | 388 | source_range: [105; 105), |
389 | delete: [105; 105), | 389 | delete: [105; 105), |
390 | insert: "quux()$0", | 390 | insert: "quux()$0", |
@@ -443,7 +443,7 @@ mod tests { | |||
443 | kind: Struct, | 443 | kind: Struct, |
444 | }, | 444 | }, |
445 | CompletionItem { | 445 | CompletionItem { |
446 | label: "quux(…)", | 446 | label: "quux()", |
447 | source_range: [117; 117), | 447 | source_range: [117; 117), |
448 | delete: [117; 117), | 448 | delete: [117; 117), |
449 | insert: "quux()$0", | 449 | insert: "quux()$0", |
@@ -475,7 +475,7 @@ mod tests { | |||
475 | kind: Struct, | 475 | kind: Struct, |
476 | }, | 476 | }, |
477 | CompletionItem { | 477 | CompletionItem { |
478 | label: "x(…)", | 478 | label: "x()", |
479 | source_range: [55; 55), | 479 | source_range: [55; 55), |
480 | delete: [55; 55), | 480 | delete: [55; 55), |
481 | insert: "x()$0", | 481 | insert: "x()$0", |
@@ -513,7 +513,7 @@ mod tests { | |||
513 | detail: "i32", | 513 | detail: "i32", |
514 | }, | 514 | }, |
515 | CompletionItem { | 515 | CompletionItem { |
516 | label: "foo(…)", | 516 | label: "foo()", |
517 | source_range: [146; 146), | 517 | source_range: [146; 146), |
518 | delete: [146; 146), | 518 | delete: [146; 146), |
519 | insert: "foo()$0", | 519 | insert: "foo()$0", |
@@ -577,7 +577,7 @@ mod tests { | |||
577 | kind: Struct, | 577 | kind: Struct, |
578 | }, | 578 | }, |
579 | CompletionItem { | 579 | CompletionItem { |
580 | label: "foo(…)", | 580 | label: "foo()", |
581 | source_range: [18; 18), | 581 | source_range: [18; 18), |
582 | delete: [18; 18), | 582 | delete: [18; 18), |
583 | insert: "foo()$0", | 583 | insert: "foo()$0", |
@@ -671,7 +671,7 @@ mod tests { | |||
671 | kind: Module, | 671 | kind: Module, |
672 | }, | 672 | }, |
673 | CompletionItem { | 673 | CompletionItem { |
674 | label: "main(…)", | 674 | label: "main()", |
675 | source_range: [252; 252), | 675 | source_range: [252; 252), |
676 | delete: [252; 252), | 676 | delete: [252; 252), |
677 | insert: "main()$0", | 677 | insert: "main()$0", |
@@ -710,7 +710,7 @@ mod tests { | |||
710 | detail: "macro_rules! foo", | 710 | detail: "macro_rules! foo", |
711 | }, | 711 | }, |
712 | CompletionItem { | 712 | CompletionItem { |
713 | label: "foo(…)", | 713 | label: "foo()", |
714 | source_range: [49; 49), | 714 | source_range: [49; 49), |
715 | delete: [49; 49), | 715 | delete: [49; 49), |
716 | insert: "foo()$0", | 716 | insert: "foo()$0", |
@@ -749,7 +749,7 @@ mod tests { | |||
749 | detail: "macro_rules! foo", | 749 | detail: "macro_rules! foo", |
750 | }, | 750 | }, |
751 | CompletionItem { | 751 | CompletionItem { |
752 | label: "main(…)", | 752 | label: "main()", |
753 | source_range: [57; 57), | 753 | source_range: [57; 57), |
754 | delete: [57; 57), | 754 | delete: [57; 57), |
755 | insert: "main()$0", | 755 | insert: "main()$0", |
@@ -788,7 +788,7 @@ mod tests { | |||
788 | detail: "macro_rules! foo", | 788 | detail: "macro_rules! foo", |
789 | }, | 789 | }, |
790 | CompletionItem { | 790 | CompletionItem { |
791 | label: "main(…)", | 791 | label: "main()", |
792 | source_range: [50; 50), | 792 | source_range: [50; 50), |
793 | delete: [50; 50), | 793 | delete: [50; 50), |
794 | insert: "main()$0", | 794 | insert: "main()$0", |
diff --git a/crates/ra_ide_api/src/completion/presentation.rs b/crates/ra_ide_api/src/completion/presentation.rs index 175a27ba9..20242d293 100644 --- a/crates/ra_ide_api/src/completion/presentation.rs +++ b/crates/ra_ide_api/src/completion/presentation.rs | |||
@@ -188,16 +188,13 @@ impl Completions { | |||
188 | && ctx.db.feature_flags.get("completion.insertion.add-call-parenthesis") | 188 | && ctx.db.feature_flags.get("completion.insertion.add-call-parenthesis") |
189 | { | 189 | { |
190 | tested_by!(inserts_parens_for_function_calls); | 190 | tested_by!(inserts_parens_for_function_calls); |
191 | let snippet = | 191 | let (snippet, label) = |
192 | if data.params().is_empty() || data.has_self_param() && data.params().len() == 1 { | 192 | if data.params().is_empty() || data.has_self_param() && data.params().len() == 1 { |
193 | format!("{}()$0", data.name()) | 193 | (format!("{}()$0", data.name()), format!("{}()", name)) |
194 | } else { | 194 | } else { |
195 | format!("{}($0)", data.name()) | 195 | (format!("{}($0)", data.name()), format!("{}(…)", name)) |
196 | }; | 196 | }; |
197 | builder = builder | 197 | builder = builder.lookup_by(name.clone()).label(label).insert_snippet(snippet); |
198 | .lookup_by(name.clone()) | ||
199 | .label(format!("{}(…)", name)) | ||
200 | .insert_snippet(snippet); | ||
201 | } | 198 | } |
202 | 199 | ||
203 | self.add(builder) | 200 | self.add(builder) |
@@ -279,7 +276,7 @@ mod tests { | |||
279 | @r###" | 276 | @r###" |
280 | [ | 277 | [ |
281 | CompletionItem { | 278 | CompletionItem { |
282 | label: "main(…)", | 279 | label: "main()", |
283 | source_range: [61; 64), | 280 | source_range: [61; 64), |
284 | delete: [61; 64), | 281 | delete: [61; 64), |
285 | insert: "main()$0", | 282 | insert: "main()$0", |
@@ -288,7 +285,7 @@ mod tests { | |||
288 | detail: "fn main()", | 285 | detail: "fn main()", |
289 | }, | 286 | }, |
290 | CompletionItem { | 287 | CompletionItem { |
291 | label: "no_args(…)", | 288 | label: "no_args()", |
292 | source_range: [61; 64), | 289 | source_range: [61; 64), |
293 | delete: [61; 64), | 290 | delete: [61; 64), |
294 | insert: "no_args()$0", | 291 | insert: "no_args()$0", |
@@ -309,7 +306,7 @@ mod tests { | |||
309 | @r###" | 306 | @r###" |
310 | [ | 307 | [ |
311 | CompletionItem { | 308 | CompletionItem { |
312 | label: "main(…)", | 309 | label: "main()", |
313 | source_range: [80; 85), | 310 | source_range: [80; 85), |
314 | delete: [80; 85), | 311 | delete: [80; 85), |
315 | insert: "main()$0", | 312 | insert: "main()$0", |
@@ -344,7 +341,7 @@ mod tests { | |||
344 | @r###" | 341 | @r###" |
345 | [ | 342 | [ |
346 | CompletionItem { | 343 | CompletionItem { |
347 | label: "foo(…)", | 344 | label: "foo()", |
348 | source_range: [163; 164), | 345 | source_range: [163; 164), |
349 | delete: [163; 164), | 346 | delete: [163; 164), |
350 | insert: "foo()$0", | 347 | insert: "foo()$0", |