microsoft/qdk

Public

mirrored from https://github.com/microsoft/qdkAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v1.23.0

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

source/language_service/src/signature_help/tests.rs

3368lines · modecode

1// Copyright (c) Microsoft Corporation.
2// Licensed under the MIT License.
3
4use super::get_signature_help;
5use crate::{Encoding, test_utils::compile_with_markers};
6use expect_test::{Expect, expect};
7use indoc::indoc;
8
9/// Asserts that the signature help given at the cursor position matches the expected signature help.
10/// The cursor position is indicated by a `↘` marker in the source text.
11fn check(source_with_markers: &str, expect: &Expect) {
12 let (compilation, cursor_position, _) = compile_with_markers(source_with_markers, true);
13 let actual = get_signature_help(&compilation, "<source>", cursor_position, Encoding::Utf8)
14 .expect("Expected a signature help.");
15 expect.assert_debug_eq(&actual);
16}
17
18#[test]
19fn first_argument() {
20 check(
21 indoc! {r#"
22 namespace Test {
23 operation Foo(x : Int, y : Double, z : String) : Unit {}
24 operation Bar() : Unit {
25 Foo(↘)
26 let x = 3;
27 }
28 }
29 "#},
30 &expect![[r#"
31 SignatureHelp {
32 signatures: [
33 SignatureInformation {
34 label: "operation Foo(x : Int, y : Double, z : String) : Unit",
35 documentation: None,
36 parameters: [
37 ParameterInformation {
38 label: (
39 13,
40 46,
41 ),
42 documentation: None,
43 },
44 ParameterInformation {
45 label: (
46 14,
47 21,
48 ),
49 documentation: None,
50 },
51 ParameterInformation {
52 label: (
53 23,
54 33,
55 ),
56 documentation: None,
57 },
58 ParameterInformation {
59 label: (
60 35,
61 45,
62 ),
63 documentation: None,
64 },
65 ],
66 },
67 ],
68 active_signature: 0,
69 active_parameter: 1,
70 }
71 "#]],
72 );
73}
74
75#[test]
76fn mid_argument() {
77 check(
78 indoc! {r#"
79 namespace Test {
80 operation Foo(x : Int, y : Double, z : String) : Unit {}
81 operation Bar() : Unit {
82 Foo(12↘)
83 let x = 3;
84 }
85 }
86 "#},
87 &expect![[r#"
88 SignatureHelp {
89 signatures: [
90 SignatureInformation {
91 label: "operation Foo(x : Int, y : Double, z : String) : Unit",
92 documentation: None,
93 parameters: [
94 ParameterInformation {
95 label: (
96 13,
97 46,
98 ),
99 documentation: None,
100 },
101 ParameterInformation {
102 label: (
103 14,
104 21,
105 ),
106 documentation: None,
107 },
108 ParameterInformation {
109 label: (
110 23,
111 33,
112 ),
113 documentation: None,
114 },
115 ParameterInformation {
116 label: (
117 35,
118 45,
119 ),
120 documentation: None,
121 },
122 ],
123 },
124 ],
125 active_signature: 0,
126 active_parameter: 1,
127 }
128 "#]],
129 );
130}
131
132#[test]
133fn second_argument() {
134 check(
135 indoc! {r#"
136 namespace Test {
137 operation Foo(x : Int, y : Double, z : String) : Unit {}
138 operation Bar() : Unit {
139 Foo(1,↘)
140 let x = 3;
141 }
142 }
143 "#},
144 &expect![[r#"
145 SignatureHelp {
146 signatures: [
147 SignatureInformation {
148 label: "operation Foo(x : Int, y : Double, z : String) : Unit",
149 documentation: None,
150 parameters: [
151 ParameterInformation {
152 label: (
153 13,
154 46,
155 ),
156 documentation: None,
157 },
158 ParameterInformation {
159 label: (
160 14,
161 21,
162 ),
163 documentation: None,
164 },
165 ParameterInformation {
166 label: (
167 23,
168 33,
169 ),
170 documentation: None,
171 },
172 ParameterInformation {
173 label: (
174 35,
175 45,
176 ),
177 documentation: None,
178 },
179 ],
180 },
181 ],
182 active_signature: 0,
183 active_parameter: 2,
184 }
185 "#]],
186 );
187}
188
189#[test]
190fn last_argument() {
191 check(
192 indoc! {r#"
193 namespace Test {
194 operation Foo(x : Int, y : Double, z : String) : Unit {}
195 operation Bar() : Unit {
196 Foo(1, 1.2,↘)
197 let x = 3;
198 }
199 }
200 "#},
201 &expect![[r#"
202 SignatureHelp {
203 signatures: [
204 SignatureInformation {
205 label: "operation Foo(x : Int, y : Double, z : String) : Unit",
206 documentation: None,
207 parameters: [
208 ParameterInformation {
209 label: (
210 13,
211 46,
212 ),
213 documentation: None,
214 },
215 ParameterInformation {
216 label: (
217 14,
218 21,
219 ),
220 documentation: None,
221 },
222 ParameterInformation {
223 label: (
224 23,
225 33,
226 ),
227 documentation: None,
228 },
229 ParameterInformation {
230 label: (
231 35,
232 45,
233 ),
234 documentation: None,
235 },
236 ],
237 },
238 ],
239 active_signature: 0,
240 active_parameter: 3,
241 }
242 "#]],
243 );
244}
245
246#[test]
247fn insert_second_argument() {
248 check(
249 indoc! {r#"
250 namespace Test {
251 operation Foo(x : Int, y : Double, z : String) : Unit {}
252 operation Bar() : Unit {
253 Foo(1,↘, "Four")
254 let x = 3;
255 }
256 }
257 "#},
258 &expect![[r#"
259 SignatureHelp {
260 signatures: [
261 SignatureInformation {
262 label: "operation Foo(x : Int, y : Double, z : String) : Unit",
263 documentation: None,
264 parameters: [
265 ParameterInformation {
266 label: (
267 13,
268 46,
269 ),
270 documentation: None,
271 },
272 ParameterInformation {
273 label: (
274 14,
275 21,
276 ),
277 documentation: None,
278 },
279 ParameterInformation {
280 label: (
281 23,
282 33,
283 ),
284 documentation: None,
285 },
286 ParameterInformation {
287 label: (
288 35,
289 45,
290 ),
291 documentation: None,
292 },
293 ],
294 },
295 ],
296 active_signature: 0,
297 active_parameter: 2,
298 }
299 "#]],
300 );
301}
302
303#[test]
304fn revisit_second_argument() {
305 check(
306 indoc! {r#"
307 namespace Test {
308 operation Foo(x : Int, y : Double, z : String) : Unit {}
309 operation Bar() : Unit {
310 Foo(1, 2.↘3, "Four")
311 let x = 3;
312 }
313 }
314 "#},
315 &expect![[r#"
316 SignatureHelp {
317 signatures: [
318 SignatureInformation {
319 label: "operation Foo(x : Int, y : Double, z : String) : Unit",
320 documentation: None,
321 parameters: [
322 ParameterInformation {
323 label: (
324 13,
325 46,
326 ),
327 documentation: None,
328 },
329 ParameterInformation {
330 label: (
331 14,
332 21,
333 ),
334 documentation: None,
335 },
336 ParameterInformation {
337 label: (
338 23,
339 33,
340 ),
341 documentation: None,
342 },
343 ParameterInformation {
344 label: (
345 35,
346 45,
347 ),
348 documentation: None,
349 },
350 ],
351 },
352 ],
353 active_signature: 0,
354 active_parameter: 2,
355 }
356 "#]],
357 );
358}
359
360#[test]
361fn nested_call_argument() {
362 check(
363 indoc! {r#"
364 namespace Test {
365 operation Foo(x : Int, y : Double, z : String) : Unit {}
366 operation Bar(a : Int, b : Double) : Double { b }
367 operation Baz() : Unit {
368 Foo(1, Bar(↘))
369 let x = 3;
370 }
371 }
372 "#},
373 &expect![[r#"
374 SignatureHelp {
375 signatures: [
376 SignatureInformation {
377 label: "operation Bar(a : Int, b : Double) : Double",
378 documentation: None,
379 parameters: [
380 ParameterInformation {
381 label: (
382 13,
383 34,
384 ),
385 documentation: None,
386 },
387 ParameterInformation {
388 label: (
389 14,
390 21,
391 ),
392 documentation: None,
393 },
394 ParameterInformation {
395 label: (
396 23,
397 33,
398 ),
399 documentation: None,
400 },
401 ],
402 },
403 ],
404 active_signature: 0,
405 active_parameter: 1,
406 }
407 "#]],
408 );
409}
410
411#[test]
412fn nested_call_second_argument() {
413 check(
414 indoc! {r#"
415 namespace Test {
416 operation Foo(x : Int, y : Double, z : String) : Unit {}
417 operation Bar(a : Int, b : Double) : Double { b }
418 operation Baz() : Unit {
419 Foo(1, Bar(2,↘))
420 let x = 3;
421 }
422 }
423 "#},
424 &expect![[r#"
425 SignatureHelp {
426 signatures: [
427 SignatureInformation {
428 label: "operation Bar(a : Int, b : Double) : Double",
429 documentation: None,
430 parameters: [
431 ParameterInformation {
432 label: (
433 13,
434 34,
435 ),
436 documentation: None,
437 },
438 ParameterInformation {
439 label: (
440 14,
441 21,
442 ),
443 documentation: None,
444 },
445 ParameterInformation {
446 label: (
447 23,
448 33,
449 ),
450 documentation: None,
451 },
452 ],
453 },
454 ],
455 active_signature: 0,
456 active_parameter: 2,
457 }
458 "#]],
459 );
460}
461
462#[test]
463fn tuple_argument() {
464 check(
465 indoc! {r#"
466 namespace Test {
467 operation Foo(x : Int, y : (Int, Double), z : String) : Unit {}
468 operation Bar() : Unit {
469 Foo(1, ↘)
470 let x = 3;
471 }
472 }
473 "#},
474 &expect![[r#"
475 SignatureHelp {
476 signatures: [
477 SignatureInformation {
478 label: "operation Foo(x : Int, y : (Int, Double), z : String) : Unit",
479 documentation: None,
480 parameters: [
481 ParameterInformation {
482 label: (
483 13,
484 53,
485 ),
486 documentation: None,
487 },
488 ParameterInformation {
489 label: (
490 14,
491 21,
492 ),
493 documentation: None,
494 },
495 ParameterInformation {
496 label: (
497 23,
498 40,
499 ),
500 documentation: None,
501 },
502 ParameterInformation {
503 label: (
504 42,
505 52,
506 ),
507 documentation: None,
508 },
509 ],
510 },
511 ],
512 active_signature: 0,
513 active_parameter: 2,
514 }
515 "#]],
516 );
517}
518
519#[test]
520fn tuple_argument_first_item() {
521 check(
522 indoc! {r#"
523 namespace Test {
524 operation Foo(x : Int, y : (Int, Double), z : String) : Unit {}
525 operation Bar() : Unit {
526 Foo(1, (↘))
527 let x = 3;
528 }
529 }
530 "#},
531 &expect![[r#"
532 SignatureHelp {
533 signatures: [
534 SignatureInformation {
535 label: "operation Foo(x : Int, y : (Int, Double), z : String) : Unit",
536 documentation: None,
537 parameters: [
538 ParameterInformation {
539 label: (
540 13,
541 53,
542 ),
543 documentation: None,
544 },
545 ParameterInformation {
546 label: (
547 14,
548 21,
549 ),
550 documentation: None,
551 },
552 ParameterInformation {
553 label: (
554 23,
555 40,
556 ),
557 documentation: None,
558 },
559 ParameterInformation {
560 label: (
561 42,
562 52,
563 ),
564 documentation: None,
565 },
566 ],
567 },
568 ],
569 active_signature: 0,
570 active_parameter: 2,
571 }
572 "#]],
573 );
574}
575
576#[test]
577fn tuple_argument_last_item() {
578 check(
579 indoc! {r#"
580 namespace Test {
581 operation Foo(x : Int, y : (Int, Double), z : String) : Unit {}
582 operation Bar() : Unit {
583 Foo(1, (2,↘))
584 let x = 3;
585 }
586 }
587 "#},
588 &expect![[r#"
589 SignatureHelp {
590 signatures: [
591 SignatureInformation {
592 label: "operation Foo(x : Int, y : (Int, Double), z : String) : Unit",
593 documentation: None,
594 parameters: [
595 ParameterInformation {
596 label: (
597 13,
598 53,
599 ),
600 documentation: None,
601 },
602 ParameterInformation {
603 label: (
604 14,
605 21,
606 ),
607 documentation: None,
608 },
609 ParameterInformation {
610 label: (
611 23,
612 40,
613 ),
614 documentation: None,
615 },
616 ParameterInformation {
617 label: (
618 42,
619 52,
620 ),
621 documentation: None,
622 },
623 ],
624 },
625 ],
626 active_signature: 0,
627 active_parameter: 2,
628 }
629 "#]],
630 );
631}
632
633#[test]
634fn tuple_argument_after_tuple() {
635 check(
636 indoc! {r#"
637 namespace Test {
638 operation Foo(x : Int, y : (Int, Double), z : String) : Unit {}
639 operation Bar() : Unit {
640 Foo(1, (2, 3.0),↘)
641 let x = 3;
642 }
643 }
644 "#},
645 &expect![[r#"
646 SignatureHelp {
647 signatures: [
648 SignatureInformation {
649 label: "operation Foo(x : Int, y : (Int, Double), z : String) : Unit",
650 documentation: None,
651 parameters: [
652 ParameterInformation {
653 label: (
654 13,
655 53,
656 ),
657 documentation: None,
658 },
659 ParameterInformation {
660 label: (
661 14,
662 21,
663 ),
664 documentation: None,
665 },
666 ParameterInformation {
667 label: (
668 23,
669 40,
670 ),
671 documentation: None,
672 },
673 ParameterInformation {
674 label: (
675 42,
676 52,
677 ),
678 documentation: None,
679 },
680 ],
681 },
682 ],
683 active_signature: 0,
684 active_parameter: 3,
685 }
686 "#]],
687 );
688}
689
690#[test]
691fn arguments_in_nested_tuple() {
692 check(
693 indoc! {r#"
694 namespace Test {
695 operation Foo(w : Int, (x : Double, y : String), z : Bool) : Unit {}
696 operation Bar() : Unit {
697 Foo(1, ↘)
698 let x = 3;
699 }
700 }
701 "#},
702 &expect![[r#"
703 SignatureHelp {
704 signatures: [
705 SignatureInformation {
706 label: "operation Foo(w : Int, (x : Double, y : String), z : Bool) : Unit",
707 documentation: None,
708 parameters: [
709 ParameterInformation {
710 label: (
711 13,
712 58,
713 ),
714 documentation: None,
715 },
716 ParameterInformation {
717 label: (
718 14,
719 21,
720 ),
721 documentation: None,
722 },
723 ParameterInformation {
724 label: (
725 23,
726 47,
727 ),
728 documentation: None,
729 },
730 ParameterInformation {
731 label: (
732 24,
733 34,
734 ),
735 documentation: None,
736 },
737 ParameterInformation {
738 label: (
739 36,
740 46,
741 ),
742 documentation: None,
743 },
744 ParameterInformation {
745 label: (
746 49,
747 57,
748 ),
749 documentation: None,
750 },
751 ],
752 },
753 ],
754 active_signature: 0,
755 active_parameter: 2,
756 }
757 "#]],
758 );
759}
760
761#[test]
762fn first_inner_argument_in_nested_tuple() {
763 check(
764 indoc! {r#"
765 namespace Test {
766 operation Foo(w : Int, (x : Double, y : String), z : Bool) : Unit {}
767 operation Bar() : Unit {
768 Foo(1, (↘))
769 let x = 3;
770 }
771 }
772 "#},
773 &expect![[r#"
774 SignatureHelp {
775 signatures: [
776 SignatureInformation {
777 label: "operation Foo(w : Int, (x : Double, y : String), z : Bool) : Unit",
778 documentation: None,
779 parameters: [
780 ParameterInformation {
781 label: (
782 13,
783 58,
784 ),
785 documentation: None,
786 },
787 ParameterInformation {
788 label: (
789 14,
790 21,
791 ),
792 documentation: None,
793 },
794 ParameterInformation {
795 label: (
796 23,
797 47,
798 ),
799 documentation: None,
800 },
801 ParameterInformation {
802 label: (
803 24,
804 34,
805 ),
806 documentation: None,
807 },
808 ParameterInformation {
809 label: (
810 36,
811 46,
812 ),
813 documentation: None,
814 },
815 ParameterInformation {
816 label: (
817 49,
818 57,
819 ),
820 documentation: None,
821 },
822 ],
823 },
824 ],
825 active_signature: 0,
826 active_parameter: 3,
827 }
828 "#]],
829 );
830}
831
832#[test]
833fn second_inner_argument_in_nested_tuple() {
834 check(
835 indoc! {r#"
836 namespace Test {
837 operation Foo(w : Int, (x : Double, y : String), z : Bool) : Unit {}
838 operation Bar() : Unit {
839 Foo(1, (2.3,↘))
840 let x = 3;
841 }
842 }
843 "#},
844 &expect![[r#"
845 SignatureHelp {
846 signatures: [
847 SignatureInformation {
848 label: "operation Foo(w : Int, (x : Double, y : String), z : Bool) : Unit",
849 documentation: None,
850 parameters: [
851 ParameterInformation {
852 label: (
853 13,
854 58,
855 ),
856 documentation: None,
857 },
858 ParameterInformation {
859 label: (
860 14,
861 21,
862 ),
863 documentation: None,
864 },
865 ParameterInformation {
866 label: (
867 23,
868 47,
869 ),
870 documentation: None,
871 },
872 ParameterInformation {
873 label: (
874 24,
875 34,
876 ),
877 documentation: None,
878 },
879 ParameterInformation {
880 label: (
881 36,
882 46,
883 ),
884 documentation: None,
885 },
886 ParameterInformation {
887 label: (
888 49,
889 57,
890 ),
891 documentation: None,
892 },
893 ],
894 },
895 ],
896 active_signature: 0,
897 active_parameter: 4,
898 }
899 "#]],
900 );
901}
902
903#[test]
904fn argument_after_nested_tuple() {
905 check(
906 indoc! {r#"
907 namespace Test {
908 operation Foo(w : Int, (x : Double, y : String), z : Bool) : Unit {}
909 operation Bar() : Unit {
910 Foo(1, (2.3, "Four"),↘)
911 let x = 3;
912 }
913 }
914 "#},
915 &expect![[r#"
916 SignatureHelp {
917 signatures: [
918 SignatureInformation {
919 label: "operation Foo(w : Int, (x : Double, y : String), z : Bool) : Unit",
920 documentation: None,
921 parameters: [
922 ParameterInformation {
923 label: (
924 13,
925 58,
926 ),
927 documentation: None,
928 },
929 ParameterInformation {
930 label: (
931 14,
932 21,
933 ),
934 documentation: None,
935 },
936 ParameterInformation {
937 label: (
938 23,
939 47,
940 ),
941 documentation: None,
942 },
943 ParameterInformation {
944 label: (
945 24,
946 34,
947 ),
948 documentation: None,
949 },
950 ParameterInformation {
951 label: (
952 36,
953 46,
954 ),
955 documentation: None,
956 },
957 ParameterInformation {
958 label: (
959 49,
960 57,
961 ),
962 documentation: None,
963 },
964 ],
965 },
966 ],
967 active_signature: 0,
968 active_parameter: 5,
969 }
970 "#]],
971 );
972}
973
974#[test]
975fn argument_end_of_nested_tuple() {
976 check(
977 indoc! {r#"
978 namespace Test {
979 operation Foo(w : Int, (x : Double, y : String), z : Bool) : Unit {}
980 operation Bar() : Unit {
981 Foo(1, (2.3, "Four")↘)
982 let x = 3;
983 }
984 }
985 "#},
986 &expect![[r#"
987 SignatureHelp {
988 signatures: [
989 SignatureInformation {
990 label: "operation Foo(w : Int, (x : Double, y : String), z : Bool) : Unit",
991 documentation: None,
992 parameters: [
993 ParameterInformation {
994 label: (
995 13,
996 58,
997 ),
998 documentation: None,
999 },
1000 ParameterInformation {
1001 label: (
1002 14,
1003 21,
1004 ),
1005 documentation: None,
1006 },
1007 ParameterInformation {
1008 label: (
1009 23,
1010 47,
1011 ),
1012 documentation: None,
1013 },
1014 ParameterInformation {
1015 label: (
1016 24,
1017 34,
1018 ),
1019 documentation: None,
1020 },
1021 ParameterInformation {
1022 label: (
1023 36,
1024 46,
1025 ),
1026 documentation: None,
1027 },
1028 ParameterInformation {
1029 label: (
1030 49,
1031 57,
1032 ),
1033 documentation: None,
1034 },
1035 ],
1036 },
1037 ],
1038 active_signature: 0,
1039 active_parameter: 2,
1040 }
1041 "#]],
1042 );
1043}
1044
1045#[test]
1046fn argument_nested_tuple_after_last() {
1047 check(
1048 indoc! {r#"
1049 namespace Test {
1050 operation Foo(w : Int, (x : Double, y : String), z : Bool) : Unit {}
1051 operation Bar() : Unit {
1052 Foo(1, (2.3, "Four" ↘))
1053 let x = 3;
1054 }
1055 }
1056 "#},
1057 &expect![[r#"
1058 SignatureHelp {
1059 signatures: [
1060 SignatureInformation {
1061 label: "operation Foo(w : Int, (x : Double, y : String), z : Bool) : Unit",
1062 documentation: None,
1063 parameters: [
1064 ParameterInformation {
1065 label: (
1066 13,
1067 58,
1068 ),
1069 documentation: None,
1070 },
1071 ParameterInformation {
1072 label: (
1073 14,
1074 21,
1075 ),
1076 documentation: None,
1077 },
1078 ParameterInformation {
1079 label: (
1080 23,
1081 47,
1082 ),
1083 documentation: None,
1084 },
1085 ParameterInformation {
1086 label: (
1087 24,
1088 34,
1089 ),
1090 documentation: None,
1091 },
1092 ParameterInformation {
1093 label: (
1094 36,
1095 46,
1096 ),
1097 documentation: None,
1098 },
1099 ParameterInformation {
1100 label: (
1101 49,
1102 57,
1103 ),
1104 documentation: None,
1105 },
1106 ],
1107 },
1108 ],
1109 active_signature: 0,
1110 active_parameter: 2,
1111 }
1112 "#]],
1113 );
1114}
1115
1116#[test]
1117fn nested_tuple_mismatch_after() {
1118 check(
1119 indoc! {r#"
1120 namespace Test {
1121 operation Foo(w : Int, (x : Double, y : String), z : Bool) : Unit {}
1122 operation Bar() : Unit {
1123 Foo(1, 2,↘)
1124 let x = 3;
1125 }
1126 }
1127 "#},
1128 &expect![[r#"
1129 SignatureHelp {
1130 signatures: [
1131 SignatureInformation {
1132 label: "operation Foo(w : Int, (x : Double, y : String), z : Bool) : Unit",
1133 documentation: None,
1134 parameters: [
1135 ParameterInformation {
1136 label: (
1137 13,
1138 58,
1139 ),
1140 documentation: None,
1141 },
1142 ParameterInformation {
1143 label: (
1144 14,
1145 21,
1146 ),
1147 documentation: None,
1148 },
1149 ParameterInformation {
1150 label: (
1151 23,
1152 47,
1153 ),
1154 documentation: None,
1155 },
1156 ParameterInformation {
1157 label: (
1158 24,
1159 34,
1160 ),
1161 documentation: None,
1162 },
1163 ParameterInformation {
1164 label: (
1165 36,
1166 46,
1167 ),
1168 documentation: None,
1169 },
1170 ParameterInformation {
1171 label: (
1172 49,
1173 57,
1174 ),
1175 documentation: None,
1176 },
1177 ],
1178 },
1179 ],
1180 active_signature: 0,
1181 active_parameter: 5,
1182 }
1183 "#]],
1184 );
1185}
1186
1187#[test]
1188fn nested_tuple_mismatch_mid() {
1189 check(
1190 indoc! {r#"
1191 namespace Test {
1192 operation Foo(w : Int, (x : Double, y : String), z : Bool) : Unit {}
1193 operation Bar() : Unit {
1194 Foo(1, 12↘3)
1195 let x = 3;
1196 }
1197 }
1198 "#},
1199 &expect![[r#"
1200 SignatureHelp {
1201 signatures: [
1202 SignatureInformation {
1203 label: "operation Foo(w : Int, (x : Double, y : String), z : Bool) : Unit",
1204 documentation: None,
1205 parameters: [
1206 ParameterInformation {
1207 label: (
1208 13,
1209 58,
1210 ),
1211 documentation: None,
1212 },
1213 ParameterInformation {
1214 label: (
1215 14,
1216 21,
1217 ),
1218 documentation: None,
1219 },
1220 ParameterInformation {
1221 label: (
1222 23,
1223 47,
1224 ),
1225 documentation: None,
1226 },
1227 ParameterInformation {
1228 label: (
1229 24,
1230 34,
1231 ),
1232 documentation: None,
1233 },
1234 ParameterInformation {
1235 label: (
1236 36,
1237 46,
1238 ),
1239 documentation: None,
1240 },
1241 ParameterInformation {
1242 label: (
1243 49,
1244 57,
1245 ),
1246 documentation: None,
1247 },
1248 ],
1249 },
1250 ],
1251 active_signature: 0,
1252 active_parameter: 2,
1253 }
1254 "#]],
1255 );
1256}
1257
1258#[test]
1259fn nested_tuple_mismatch_before() {
1260 check(
1261 indoc! {r#"
1262 namespace Test {
1263 operation Foo(w : Int, (x : Double, y : String), z : Bool) : Unit {}
1264 operation Bar() : Unit {
1265 Foo(1↘2, 123)
1266 let x = 3;
1267 }
1268 }
1269 "#},
1270 &expect![[r#"
1271 SignatureHelp {
1272 signatures: [
1273 SignatureInformation {
1274 label: "operation Foo(w : Int, (x : Double, y : String), z : Bool) : Unit",
1275 documentation: None,
1276 parameters: [
1277 ParameterInformation {
1278 label: (
1279 13,
1280 58,
1281 ),
1282 documentation: None,
1283 },
1284 ParameterInformation {
1285 label: (
1286 14,
1287 21,
1288 ),
1289 documentation: None,
1290 },
1291 ParameterInformation {
1292 label: (
1293 23,
1294 47,
1295 ),
1296 documentation: None,
1297 },
1298 ParameterInformation {
1299 label: (
1300 24,
1301 34,
1302 ),
1303 documentation: None,
1304 },
1305 ParameterInformation {
1306 label: (
1307 36,
1308 46,
1309 ),
1310 documentation: None,
1311 },
1312 ParameterInformation {
1313 label: (
1314 49,
1315 57,
1316 ),
1317 documentation: None,
1318 },
1319 ],
1320 },
1321 ],
1322 active_signature: 0,
1323 active_parameter: 1,
1324 }
1325 "#]],
1326 );
1327}
1328
1329#[test]
1330fn nested_tuple_not_enough_end() {
1331 check(
1332 indoc! {r#"
1333 namespace Test {
1334 operation Foo(v : Int, (w : Double, x : String, y : Int), z : Bool) : Unit {}
1335 operation Bar() : Unit {
1336 Foo(1, (2.0, "Three")↘)
1337 let x = 3;
1338 }
1339 }
1340 "#},
1341 &expect![[r#"
1342 SignatureHelp {
1343 signatures: [
1344 SignatureInformation {
1345 label: "operation Foo(v : Int, (w : Double, x : String, y : Int), z : Bool) : Unit",
1346 documentation: None,
1347 parameters: [
1348 ParameterInformation {
1349 label: (
1350 13,
1351 67,
1352 ),
1353 documentation: None,
1354 },
1355 ParameterInformation {
1356 label: (
1357 14,
1358 21,
1359 ),
1360 documentation: None,
1361 },
1362 ParameterInformation {
1363 label: (
1364 23,
1365 56,
1366 ),
1367 documentation: None,
1368 },
1369 ParameterInformation {
1370 label: (
1371 24,
1372 34,
1373 ),
1374 documentation: None,
1375 },
1376 ParameterInformation {
1377 label: (
1378 36,
1379 46,
1380 ),
1381 documentation: None,
1382 },
1383 ParameterInformation {
1384 label: (
1385 48,
1386 55,
1387 ),
1388 documentation: None,
1389 },
1390 ParameterInformation {
1391 label: (
1392 58,
1393 66,
1394 ),
1395 documentation: None,
1396 },
1397 ],
1398 },
1399 ],
1400 active_signature: 0,
1401 active_parameter: 2,
1402 }
1403 "#]],
1404 );
1405}
1406
1407#[test]
1408fn nested_tuple_not_enough_after() {
1409 check(
1410 indoc! {r#"
1411 namespace Test {
1412 operation Foo(v : Int, (w : Double, x : String, y : Int), z : Bool) : Unit {}
1413 operation Bar() : Unit {
1414 Foo(1, (2.0, "Three"),↘)
1415 let x = 3;
1416 }
1417 }
1418 "#},
1419 &expect![[r#"
1420 SignatureHelp {
1421 signatures: [
1422 SignatureInformation {
1423 label: "operation Foo(v : Int, (w : Double, x : String, y : Int), z : Bool) : Unit",
1424 documentation: None,
1425 parameters: [
1426 ParameterInformation {
1427 label: (
1428 13,
1429 67,
1430 ),
1431 documentation: None,
1432 },
1433 ParameterInformation {
1434 label: (
1435 14,
1436 21,
1437 ),
1438 documentation: None,
1439 },
1440 ParameterInformation {
1441 label: (
1442 23,
1443 56,
1444 ),
1445 documentation: None,
1446 },
1447 ParameterInformation {
1448 label: (
1449 24,
1450 34,
1451 ),
1452 documentation: None,
1453 },
1454 ParameterInformation {
1455 label: (
1456 36,
1457 46,
1458 ),
1459 documentation: None,
1460 },
1461 ParameterInformation {
1462 label: (
1463 48,
1464 55,
1465 ),
1466 documentation: None,
1467 },
1468 ParameterInformation {
1469 label: (
1470 58,
1471 66,
1472 ),
1473 documentation: None,
1474 },
1475 ],
1476 },
1477 ],
1478 active_signature: 0,
1479 active_parameter: 6,
1480 }
1481 "#]],
1482 );
1483}
1484
1485#[test]
1486fn nested_tuple_not_enough_single_end() {
1487 check(
1488 indoc! {r#"
1489 namespace Test {
1490 operation Foo(w : Int, (x : Double, y : String), z : Bool) : Unit {}
1491 operation Bar() : Unit {
1492 Foo(1, (2.0)↘)
1493 let x = 3;
1494 }
1495 }
1496 "#},
1497 &expect![[r#"
1498 SignatureHelp {
1499 signatures: [
1500 SignatureInformation {
1501 label: "operation Foo(w : Int, (x : Double, y : String), z : Bool) : Unit",
1502 documentation: None,
1503 parameters: [
1504 ParameterInformation {
1505 label: (
1506 13,
1507 58,
1508 ),
1509 documentation: None,
1510 },
1511 ParameterInformation {
1512 label: (
1513 14,
1514 21,
1515 ),
1516 documentation: None,
1517 },
1518 ParameterInformation {
1519 label: (
1520 23,
1521 47,
1522 ),
1523 documentation: None,
1524 },
1525 ParameterInformation {
1526 label: (
1527 24,
1528 34,
1529 ),
1530 documentation: None,
1531 },
1532 ParameterInformation {
1533 label: (
1534 36,
1535 46,
1536 ),
1537 documentation: None,
1538 },
1539 ParameterInformation {
1540 label: (
1541 49,
1542 57,
1543 ),
1544 documentation: None,
1545 },
1546 ],
1547 },
1548 ],
1549 active_signature: 0,
1550 active_parameter: 2,
1551 }
1552 "#]],
1553 );
1554}
1555
1556#[test]
1557fn nested_tuple_not_enough_single_after() {
1558 check(
1559 indoc! {r#"
1560 namespace Test {
1561 operation Foo(w : Int, (x : Double, y : String), z : Bool) : Unit {}
1562 operation Bar() : Unit {
1563 Foo(1, (2.0),↘)
1564 let x = 3;
1565 }
1566 }
1567 "#},
1568 &expect![[r#"
1569 SignatureHelp {
1570 signatures: [
1571 SignatureInformation {
1572 label: "operation Foo(w : Int, (x : Double, y : String), z : Bool) : Unit",
1573 documentation: None,
1574 parameters: [
1575 ParameterInformation {
1576 label: (
1577 13,
1578 58,
1579 ),
1580 documentation: None,
1581 },
1582 ParameterInformation {
1583 label: (
1584 14,
1585 21,
1586 ),
1587 documentation: None,
1588 },
1589 ParameterInformation {
1590 label: (
1591 23,
1592 47,
1593 ),
1594 documentation: None,
1595 },
1596 ParameterInformation {
1597 label: (
1598 24,
1599 34,
1600 ),
1601 documentation: None,
1602 },
1603 ParameterInformation {
1604 label: (
1605 36,
1606 46,
1607 ),
1608 documentation: None,
1609 },
1610 ParameterInformation {
1611 label: (
1612 49,
1613 57,
1614 ),
1615 documentation: None,
1616 },
1617 ],
1618 },
1619 ],
1620 active_signature: 0,
1621 active_parameter: 5,
1622 }
1623 "#]],
1624 );
1625}
1626
1627#[test]
1628fn nested_tuple_not_enough_empty_end() {
1629 check(
1630 indoc! {r#"
1631 namespace Test {
1632 operation Foo(w : Int, (x : Double, y : String), z : Bool) : Unit {}
1633 operation Bar() : Unit {
1634 Foo(1, ()↘)
1635 let x = 3;
1636 }
1637 }
1638 "#},
1639 &expect![[r#"
1640 SignatureHelp {
1641 signatures: [
1642 SignatureInformation {
1643 label: "operation Foo(w : Int, (x : Double, y : String), z : Bool) : Unit",
1644 documentation: None,
1645 parameters: [
1646 ParameterInformation {
1647 label: (
1648 13,
1649 58,
1650 ),
1651 documentation: None,
1652 },
1653 ParameterInformation {
1654 label: (
1655 14,
1656 21,
1657 ),
1658 documentation: None,
1659 },
1660 ParameterInformation {
1661 label: (
1662 23,
1663 47,
1664 ),
1665 documentation: None,
1666 },
1667 ParameterInformation {
1668 label: (
1669 24,
1670 34,
1671 ),
1672 documentation: None,
1673 },
1674 ParameterInformation {
1675 label: (
1676 36,
1677 46,
1678 ),
1679 documentation: None,
1680 },
1681 ParameterInformation {
1682 label: (
1683 49,
1684 57,
1685 ),
1686 documentation: None,
1687 },
1688 ],
1689 },
1690 ],
1691 active_signature: 0,
1692 active_parameter: 2,
1693 }
1694 "#]],
1695 );
1696}
1697
1698#[test]
1699fn nested_tuple_not_enough_empty_after() {
1700 check(
1701 indoc! {r#"
1702 namespace Test {
1703 operation Foo(w : Int, (x : Double, y : String), z : Bool) : Unit {}
1704 operation Bar() : Unit {
1705 Foo(1, (),↘)
1706 let x = 3;
1707 }
1708 }
1709 "#},
1710 &expect![[r#"
1711 SignatureHelp {
1712 signatures: [
1713 SignatureInformation {
1714 label: "operation Foo(w : Int, (x : Double, y : String), z : Bool) : Unit",
1715 documentation: None,
1716 parameters: [
1717 ParameterInformation {
1718 label: (
1719 13,
1720 58,
1721 ),
1722 documentation: None,
1723 },
1724 ParameterInformation {
1725 label: (
1726 14,
1727 21,
1728 ),
1729 documentation: None,
1730 },
1731 ParameterInformation {
1732 label: (
1733 23,
1734 47,
1735 ),
1736 documentation: None,
1737 },
1738 ParameterInformation {
1739 label: (
1740 24,
1741 34,
1742 ),
1743 documentation: None,
1744 },
1745 ParameterInformation {
1746 label: (
1747 36,
1748 46,
1749 ),
1750 documentation: None,
1751 },
1752 ParameterInformation {
1753 label: (
1754 49,
1755 57,
1756 ),
1757 documentation: None,
1758 },
1759 ],
1760 },
1761 ],
1762 active_signature: 0,
1763 active_parameter: 5,
1764 }
1765 "#]],
1766 );
1767}
1768
1769#[test]
1770fn nested_empty_tuple() {
1771 check(
1772 indoc! {r#"
1773 namespace Test {
1774 operation Foo(x : Int, (), y : Bool) : Unit {}
1775 operation Bar() : Unit {
1776 Foo(1,↘)
1777 let x = 3;
1778 }
1779 }
1780 "#},
1781 &expect![[r#"
1782 SignatureHelp {
1783 signatures: [
1784 SignatureInformation {
1785 label: "operation Foo(x : Int, (), y : Bool) : Unit",
1786 documentation: None,
1787 parameters: [
1788 ParameterInformation {
1789 label: (
1790 13,
1791 36,
1792 ),
1793 documentation: None,
1794 },
1795 ParameterInformation {
1796 label: (
1797 14,
1798 21,
1799 ),
1800 documentation: None,
1801 },
1802 ParameterInformation {
1803 label: (
1804 23,
1805 25,
1806 ),
1807 documentation: None,
1808 },
1809 ParameterInformation {
1810 label: (
1811 27,
1812 35,
1813 ),
1814 documentation: None,
1815 },
1816 ],
1817 },
1818 ],
1819 active_signature: 0,
1820 active_parameter: 2,
1821 }
1822 "#]],
1823 );
1824}
1825
1826#[test]
1827fn nested_empty_tuple_mid() {
1828 check(
1829 indoc! {r#"
1830 namespace Test {
1831 operation Foo(x : Int, (), y : Bool) : Unit {}
1832 operation Bar() : Unit {
1833 Foo(1, (↘))
1834 let x = 3;
1835 }
1836 }
1837 "#},
1838 &expect![[r#"
1839 SignatureHelp {
1840 signatures: [
1841 SignatureInformation {
1842 label: "operation Foo(x : Int, (), y : Bool) : Unit",
1843 documentation: None,
1844 parameters: [
1845 ParameterInformation {
1846 label: (
1847 13,
1848 36,
1849 ),
1850 documentation: None,
1851 },
1852 ParameterInformation {
1853 label: (
1854 14,
1855 21,
1856 ),
1857 documentation: None,
1858 },
1859 ParameterInformation {
1860 label: (
1861 23,
1862 25,
1863 ),
1864 documentation: None,
1865 },
1866 ParameterInformation {
1867 label: (
1868 27,
1869 35,
1870 ),
1871 documentation: None,
1872 },
1873 ],
1874 },
1875 ],
1876 active_signature: 0,
1877 active_parameter: 2,
1878 }
1879 "#]],
1880 );
1881}
1882
1883#[test]
1884fn nested_empty_tuple_end() {
1885 check(
1886 indoc! {r#"
1887 namespace Test {
1888 operation Foo(x : Int, (), y : Bool) : Unit {}
1889 operation Bar() : Unit {
1890 Foo(1, ()↘)
1891 let x = 3;
1892 }
1893 }
1894 "#},
1895 &expect![[r#"
1896 SignatureHelp {
1897 signatures: [
1898 SignatureInformation {
1899 label: "operation Foo(x : Int, (), y : Bool) : Unit",
1900 documentation: None,
1901 parameters: [
1902 ParameterInformation {
1903 label: (
1904 13,
1905 36,
1906 ),
1907 documentation: None,
1908 },
1909 ParameterInformation {
1910 label: (
1911 14,
1912 21,
1913 ),
1914 documentation: None,
1915 },
1916 ParameterInformation {
1917 label: (
1918 23,
1919 25,
1920 ),
1921 documentation: None,
1922 },
1923 ParameterInformation {
1924 label: (
1925 27,
1926 35,
1927 ),
1928 documentation: None,
1929 },
1930 ],
1931 },
1932 ],
1933 active_signature: 0,
1934 active_parameter: 2,
1935 }
1936 "#]],
1937 );
1938}
1939
1940#[test]
1941fn nested_empty_tuple_after() {
1942 check(
1943 indoc! {r#"
1944 namespace Test {
1945 operation Foo(x : Int, (), y : Bool) : Unit {}
1946 operation Bar() : Unit {
1947 Foo(1, (),↘)
1948 let x = 3;
1949 }
1950 }
1951 "#},
1952 &expect![[r#"
1953 SignatureHelp {
1954 signatures: [
1955 SignatureInformation {
1956 label: "operation Foo(x : Int, (), y : Bool) : Unit",
1957 documentation: None,
1958 parameters: [
1959 ParameterInformation {
1960 label: (
1961 13,
1962 36,
1963 ),
1964 documentation: None,
1965 },
1966 ParameterInformation {
1967 label: (
1968 14,
1969 21,
1970 ),
1971 documentation: None,
1972 },
1973 ParameterInformation {
1974 label: (
1975 23,
1976 25,
1977 ),
1978 documentation: None,
1979 },
1980 ParameterInformation {
1981 label: (
1982 27,
1983 35,
1984 ),
1985 documentation: None,
1986 },
1987 ],
1988 },
1989 ],
1990 active_signature: 0,
1991 active_parameter: 3,
1992 }
1993 "#]],
1994 );
1995}
1996
1997#[test]
1998fn multi_nested_tuple() {
1999 check(
2000 indoc! {r#"
2001 namespace Test {
2002 operation Foo(a : Int, (b : Int, (c : Int, d : Int), e : Int), f : Int) : Unit {}
2003 operation Bar() : Unit {
2004 Foo(1, (2, (3, 4), 5),↘)
2005 let x = 3;
2006 }
2007 }
2008 "#},
2009 &expect![[r#"
2010 SignatureHelp {
2011 signatures: [
2012 SignatureInformation {
2013 label: "operation Foo(a : Int, (b : Int, (c : Int, d : Int), e : Int), f : Int) : Unit",
2014 documentation: None,
2015 parameters: [
2016 ParameterInformation {
2017 label: (
2018 13,
2019 71,
2020 ),
2021 documentation: None,
2022 },
2023 ParameterInformation {
2024 label: (
2025 14,
2026 21,
2027 ),
2028 documentation: None,
2029 },
2030 ParameterInformation {
2031 label: (
2032 23,
2033 61,
2034 ),
2035 documentation: None,
2036 },
2037 ParameterInformation {
2038 label: (
2039 24,
2040 31,
2041 ),
2042 documentation: None,
2043 },
2044 ParameterInformation {
2045 label: (
2046 33,
2047 51,
2048 ),
2049 documentation: None,
2050 },
2051 ParameterInformation {
2052 label: (
2053 34,
2054 41,
2055 ),
2056 documentation: None,
2057 },
2058 ParameterInformation {
2059 label: (
2060 43,
2061 50,
2062 ),
2063 documentation: None,
2064 },
2065 ParameterInformation {
2066 label: (
2067 53,
2068 60,
2069 ),
2070 documentation: None,
2071 },
2072 ParameterInformation {
2073 label: (
2074 63,
2075 70,
2076 ),
2077 documentation: None,
2078 },
2079 ],
2080 },
2081 ],
2082 active_signature: 0,
2083 active_parameter: 8,
2084 }
2085 "#]],
2086 );
2087}
2088
2089#[allow(clippy::too_many_lines)]
2090#[test]
2091fn documentation_test() {
2092 check(
2093 indoc! {r#"
2094 namespace Test {
2095 /// # Summary
2096 /// This is the operation `Foo`.
2097 /// # Input
2098 /// ## a
2099 /// This is the parameter `a`.
2100 /// ## b
2101 /// This is the parameter `b`.
2102 /// ## c
2103 /// This is the parameter `c`.
2104 /// ## d
2105 /// This is the parameter `d`.
2106 /// ## e
2107 /// This is the parameter `e`.
2108 /// ## f
2109 /// This is the parameter `f`.
2110 operation Foo(a : Int, (b : Int, (c : Int, d : Int), e : Int), f : Int) : Unit {}
2111 operation Bar() : Unit {
2112 Foo(1, (2, (3, 4), 5),↘)
2113 let x = 3;
2114 }
2115 }
2116 "#},
2117 &expect![[r#"
2118 SignatureHelp {
2119 signatures: [
2120 SignatureInformation {
2121 label: "operation Foo(a : Int, (b : Int, (c : Int, d : Int), e : Int), f : Int) : Unit",
2122 documentation: Some(
2123 "This is the operation `Foo`.",
2124 ),
2125 parameters: [
2126 ParameterInformation {
2127 label: (
2128 13,
2129 71,
2130 ),
2131 documentation: None,
2132 },
2133 ParameterInformation {
2134 label: (
2135 14,
2136 21,
2137 ),
2138 documentation: Some(
2139 "This is the parameter `a`.",
2140 ),
2141 },
2142 ParameterInformation {
2143 label: (
2144 23,
2145 61,
2146 ),
2147 documentation: None,
2148 },
2149 ParameterInformation {
2150 label: (
2151 24,
2152 31,
2153 ),
2154 documentation: Some(
2155 "This is the parameter `b`.",
2156 ),
2157 },
2158 ParameterInformation {
2159 label: (
2160 33,
2161 51,
2162 ),
2163 documentation: None,
2164 },
2165 ParameterInformation {
2166 label: (
2167 34,
2168 41,
2169 ),
2170 documentation: Some(
2171 "This is the parameter `c`.",
2172 ),
2173 },
2174 ParameterInformation {
2175 label: (
2176 43,
2177 50,
2178 ),
2179 documentation: Some(
2180 "This is the parameter `d`.",
2181 ),
2182 },
2183 ParameterInformation {
2184 label: (
2185 53,
2186 60,
2187 ),
2188 documentation: Some(
2189 "This is the parameter `e`.",
2190 ),
2191 },
2192 ParameterInformation {
2193 label: (
2194 63,
2195 70,
2196 ),
2197 documentation: Some(
2198 "This is the parameter `f`.",
2199 ),
2200 },
2201 ],
2202 },
2203 ],
2204 active_signature: 0,
2205 active_parameter: 8,
2206 }
2207 "#]],
2208 );
2209}
2210
2211#[test]
2212fn single_parameter_end() {
2213 check(
2214 indoc! {r#"
2215 namespace Test {
2216 operation Foo(a : Int) : Unit {}
2217 operation Bar() : Unit {
2218 Foo(1↘)
2219 let x = 3;
2220 }
2221 }
2222 "#},
2223 &expect![[r#"
2224 SignatureHelp {
2225 signatures: [
2226 SignatureInformation {
2227 label: "operation Foo(a : Int) : Unit",
2228 documentation: None,
2229 parameters: [
2230 ParameterInformation {
2231 label: (
2232 13,
2233 22,
2234 ),
2235 documentation: None,
2236 },
2237 ParameterInformation {
2238 label: (
2239 14,
2240 21,
2241 ),
2242 documentation: None,
2243 },
2244 ],
2245 },
2246 ],
2247 active_signature: 0,
2248 active_parameter: 1,
2249 }
2250 "#]],
2251 );
2252}
2253
2254#[test]
2255fn single_parameter_after() {
2256 check(
2257 indoc! {r#"
2258 namespace Test {
2259 operation Foo(a : Int) : Unit {}
2260 operation Bar() : Unit {
2261 Foo(1,↘)
2262 let x = 3;
2263 }
2264 }
2265 "#},
2266 &expect![[r#"
2267 SignatureHelp {
2268 signatures: [
2269 SignatureInformation {
2270 label: "operation Foo(a : Int) : Unit",
2271 documentation: None,
2272 parameters: [
2273 ParameterInformation {
2274 label: (
2275 13,
2276 22,
2277 ),
2278 documentation: None,
2279 },
2280 ParameterInformation {
2281 label: (
2282 14,
2283 21,
2284 ),
2285 documentation: None,
2286 },
2287 ],
2288 },
2289 ],
2290 active_signature: 0,
2291 active_parameter: 0,
2292 }
2293 "#]],
2294 );
2295}
2296
2297#[test]
2298fn single_parameter_before() {
2299 check(
2300 indoc! {r#"
2301 namespace Test {
2302 operation Foo(a : Int) : Unit {}
2303 operation Bar() : Unit {
2304 Foo(↘ 1)
2305 let x = 3;
2306 }
2307 }
2308 "#},
2309 &expect![[r#"
2310 SignatureHelp {
2311 signatures: [
2312 SignatureInformation {
2313 label: "operation Foo(a : Int) : Unit",
2314 documentation: None,
2315 parameters: [
2316 ParameterInformation {
2317 label: (
2318 13,
2319 22,
2320 ),
2321 documentation: None,
2322 },
2323 ParameterInformation {
2324 label: (
2325 14,
2326 21,
2327 ),
2328 documentation: None,
2329 },
2330 ],
2331 },
2332 ],
2333 active_signature: 0,
2334 active_parameter: 1,
2335 }
2336 "#]],
2337 );
2338}
2339
2340#[test]
2341fn indirect_local_call() {
2342 check(
2343 indoc! {r#"
2344 namespace Test {
2345 operation Foo(x : Int, y : Int, z : Int) : Unit {}
2346 operation Bar() : Unit {
2347 let foo = Foo;
2348 foo(↘)
2349 let x = 3;
2350 }
2351 }
2352 "#},
2353 &expect![[r#"
2354 SignatureHelp {
2355 signatures: [
2356 SignatureInformation {
2357 label: "((Int, Int, Int) => Unit)",
2358 documentation: None,
2359 parameters: [
2360 ParameterInformation {
2361 label: (
2362 1,
2363 16,
2364 ),
2365 documentation: None,
2366 },
2367 ParameterInformation {
2368 label: (
2369 2,
2370 5,
2371 ),
2372 documentation: None,
2373 },
2374 ParameterInformation {
2375 label: (
2376 7,
2377 10,
2378 ),
2379 documentation: None,
2380 },
2381 ParameterInformation {
2382 label: (
2383 12,
2384 15,
2385 ),
2386 documentation: None,
2387 },
2388 ],
2389 },
2390 ],
2391 active_signature: 0,
2392 active_parameter: 1,
2393 }
2394 "#]],
2395 );
2396}
2397
2398#[test]
2399fn indirect_array_call() {
2400 check(
2401 indoc! {r#"
2402 namespace Test {
2403 operation Foo(x : Int, y : Int, z : Int) : Unit {}
2404 operation Bar() : Unit {
2405 let foo = [Foo];
2406 foo[0](↘)
2407 let x = 3;
2408 }
2409 }
2410 "#},
2411 &expect![[r#"
2412 SignatureHelp {
2413 signatures: [
2414 SignatureInformation {
2415 label: "((Int, Int, Int) => Unit)",
2416 documentation: None,
2417 parameters: [
2418 ParameterInformation {
2419 label: (
2420 1,
2421 16,
2422 ),
2423 documentation: None,
2424 },
2425 ParameterInformation {
2426 label: (
2427 2,
2428 5,
2429 ),
2430 documentation: None,
2431 },
2432 ParameterInformation {
2433 label: (
2434 7,
2435 10,
2436 ),
2437 documentation: None,
2438 },
2439 ParameterInformation {
2440 label: (
2441 12,
2442 15,
2443 ),
2444 documentation: None,
2445 },
2446 ],
2447 },
2448 ],
2449 active_signature: 0,
2450 active_parameter: 1,
2451 }
2452 "#]],
2453 );
2454}
2455
2456#[test]
2457fn indirect_block_call() {
2458 check(
2459 indoc! {r#"
2460 namespace Test {
2461 operation Foo(x : Int, y : Int, z : Int) : Unit {}
2462 operation Bar() : Unit {
2463 ({ Foo }(↘))
2464 let x = 3;
2465 }
2466 }
2467 "#},
2468 &expect![[r#"
2469 SignatureHelp {
2470 signatures: [
2471 SignatureInformation {
2472 label: "((Int, Int, Int) => Unit)",
2473 documentation: None,
2474 parameters: [
2475 ParameterInformation {
2476 label: (
2477 1,
2478 16,
2479 ),
2480 documentation: None,
2481 },
2482 ParameterInformation {
2483 label: (
2484 2,
2485 5,
2486 ),
2487 documentation: None,
2488 },
2489 ParameterInformation {
2490 label: (
2491 7,
2492 10,
2493 ),
2494 documentation: None,
2495 },
2496 ParameterInformation {
2497 label: (
2498 12,
2499 15,
2500 ),
2501 documentation: None,
2502 },
2503 ],
2504 },
2505 ],
2506 active_signature: 0,
2507 active_parameter: 1,
2508 }
2509 "#]],
2510 );
2511}
2512
2513#[test]
2514fn indirect_unresolved_lambda_call() {
2515 check(
2516 indoc! {r#"
2517 namespace Test {
2518 operation Bar() : Unit {
2519 let foo = (x, y, z) => {};
2520 foo(↘)
2521 let x = 3;
2522 }
2523 }
2524 "#},
2525 &expect![[r#"
2526 SignatureHelp {
2527 signatures: [
2528 SignatureInformation {
2529 label: "((?, ?, ?) => Unit)",
2530 documentation: None,
2531 parameters: [
2532 ParameterInformation {
2533 label: (
2534 1,
2535 10,
2536 ),
2537 documentation: None,
2538 },
2539 ParameterInformation {
2540 label: (
2541 2,
2542 3,
2543 ),
2544 documentation: None,
2545 },
2546 ParameterInformation {
2547 label: (
2548 5,
2549 6,
2550 ),
2551 documentation: None,
2552 },
2553 ParameterInformation {
2554 label: (
2555 8,
2556 9,
2557 ),
2558 documentation: None,
2559 },
2560 ],
2561 },
2562 ],
2563 active_signature: 0,
2564 active_parameter: 1,
2565 }
2566 "#]],
2567 );
2568}
2569
2570#[test]
2571fn indirect_partially_resolved_lambda_call() {
2572 check(
2573 indoc! {r#"
2574 namespace Test {
2575 operation Bar() : Unit {
2576 let foo = (x, y, z) => {};
2577 foo(1, ↘)
2578 let x = 3;
2579 }
2580 }
2581 "#},
2582 &expect![[r#"
2583 SignatureHelp {
2584 signatures: [
2585 SignatureInformation {
2586 label: "((Int, ?, ?) => Unit)",
2587 documentation: None,
2588 parameters: [
2589 ParameterInformation {
2590 label: (
2591 1,
2592 12,
2593 ),
2594 documentation: None,
2595 },
2596 ParameterInformation {
2597 label: (
2598 2,
2599 5,
2600 ),
2601 documentation: None,
2602 },
2603 ParameterInformation {
2604 label: (
2605 7,
2606 8,
2607 ),
2608 documentation: None,
2609 },
2610 ParameterInformation {
2611 label: (
2612 10,
2613 11,
2614 ),
2615 documentation: None,
2616 },
2617 ],
2618 },
2619 ],
2620 active_signature: 0,
2621 active_parameter: 2,
2622 }
2623 "#]],
2624 );
2625}
2626
2627#[test]
2628fn indirect_resolved_lambda_call() {
2629 check(
2630 indoc! {r#"
2631 namespace Test {
2632 operation Bar() : Unit {
2633 let foo = (x, y, z) => {};
2634 foo(1, 2, 3);
2635 foo(↘)
2636 let x = 3;
2637 }
2638 }
2639 "#},
2640 &expect![[r#"
2641 SignatureHelp {
2642 signatures: [
2643 SignatureInformation {
2644 label: "((Int, Int, Int) => Unit)",
2645 documentation: None,
2646 parameters: [
2647 ParameterInformation {
2648 label: (
2649 1,
2650 16,
2651 ),
2652 documentation: None,
2653 },
2654 ParameterInformation {
2655 label: (
2656 2,
2657 5,
2658 ),
2659 documentation: None,
2660 },
2661 ParameterInformation {
2662 label: (
2663 7,
2664 10,
2665 ),
2666 documentation: None,
2667 },
2668 ParameterInformation {
2669 label: (
2670 12,
2671 15,
2672 ),
2673 documentation: None,
2674 },
2675 ],
2676 },
2677 ],
2678 active_signature: 0,
2679 active_parameter: 1,
2680 }
2681 "#]],
2682 );
2683}
2684
2685#[test]
2686fn controlled_call() {
2687 check(
2688 indoc! {r#"
2689 namespace Test {
2690 operation Foo(x : Int, y : Int, z : Int) : Unit is Ctl {}
2691 operation Bar() : Unit {
2692 Controlled Foo(↘)
2693 let x = 3;
2694 }
2695 }
2696 "#},
2697 &expect![[r#"
2698 SignatureHelp {
2699 signatures: [
2700 SignatureInformation {
2701 label: "((Qubit[], (Int, Int, Int)) => Unit is Ctl)",
2702 documentation: None,
2703 parameters: [
2704 ParameterInformation {
2705 label: (
2706 1,
2707 27,
2708 ),
2709 documentation: None,
2710 },
2711 ParameterInformation {
2712 label: (
2713 2,
2714 9,
2715 ),
2716 documentation: None,
2717 },
2718 ParameterInformation {
2719 label: (
2720 11,
2721 26,
2722 ),
2723 documentation: None,
2724 },
2725 ParameterInformation {
2726 label: (
2727 12,
2728 15,
2729 ),
2730 documentation: None,
2731 },
2732 ParameterInformation {
2733 label: (
2734 17,
2735 20,
2736 ),
2737 documentation: None,
2738 },
2739 ParameterInformation {
2740 label: (
2741 22,
2742 25,
2743 ),
2744 documentation: None,
2745 },
2746 ],
2747 },
2748 ],
2749 active_signature: 0,
2750 active_parameter: 1,
2751 }
2752 "#]],
2753 );
2754}
2755
2756#[test]
2757fn double_controlled_call() {
2758 check(
2759 indoc! {r#"
2760 namespace Test {
2761 operation Foo(x : Int, y : Int, z : Int) : Unit is Ctl {}
2762 operation Bar() : Unit {
2763 Controlled Controlled Foo(↘)
2764 let x = 3;
2765 }
2766 }
2767 "#},
2768 &expect![[r#"
2769 SignatureHelp {
2770 signatures: [
2771 SignatureInformation {
2772 label: "((Qubit[], (Qubit[], (Int, Int, Int))) => Unit is Ctl)",
2773 documentation: None,
2774 parameters: [
2775 ParameterInformation {
2776 label: (
2777 1,
2778 38,
2779 ),
2780 documentation: None,
2781 },
2782 ParameterInformation {
2783 label: (
2784 2,
2785 9,
2786 ),
2787 documentation: None,
2788 },
2789 ParameterInformation {
2790 label: (
2791 11,
2792 37,
2793 ),
2794 documentation: None,
2795 },
2796 ParameterInformation {
2797 label: (
2798 12,
2799 19,
2800 ),
2801 documentation: None,
2802 },
2803 ParameterInformation {
2804 label: (
2805 21,
2806 36,
2807 ),
2808 documentation: None,
2809 },
2810 ParameterInformation {
2811 label: (
2812 22,
2813 25,
2814 ),
2815 documentation: None,
2816 },
2817 ParameterInformation {
2818 label: (
2819 27,
2820 30,
2821 ),
2822 documentation: None,
2823 },
2824 ParameterInformation {
2825 label: (
2826 32,
2827 35,
2828 ),
2829 documentation: None,
2830 },
2831 ],
2832 },
2833 ],
2834 active_signature: 0,
2835 active_parameter: 1,
2836 }
2837 "#]],
2838 );
2839}
2840
2841#[test]
2842fn partial_application_call() {
2843 check(
2844 indoc! {r#"
2845 namespace Test {
2846 operation Foo(x : Int, y : Int, z : Int) : Unit {}
2847 operation Bar() : Unit {
2848 let foo = Foo(1, _, _);
2849 foo(↘)
2850 let x = 3;
2851 }
2852 }
2853 "#},
2854 &expect![[r#"
2855 SignatureHelp {
2856 signatures: [
2857 SignatureInformation {
2858 label: "((Int, Int) => Unit)",
2859 documentation: None,
2860 parameters: [
2861 ParameterInformation {
2862 label: (
2863 1,
2864 11,
2865 ),
2866 documentation: None,
2867 },
2868 ParameterInformation {
2869 label: (
2870 2,
2871 5,
2872 ),
2873 documentation: None,
2874 },
2875 ParameterInformation {
2876 label: (
2877 7,
2878 10,
2879 ),
2880 documentation: None,
2881 },
2882 ],
2883 },
2884 ],
2885 active_signature: 0,
2886 active_parameter: 1,
2887 }
2888 "#]],
2889 );
2890}
2891
2892#[test]
2893fn indirect_no_params_call() {
2894 check(
2895 indoc! {r#"
2896 namespace Test {
2897 operation Foo() : Unit {
2898 let foo = Foo;
2899 foo(↘)
2900 let x = 3;
2901 }
2902 }
2903 "#},
2904 &expect![[r#"
2905 SignatureHelp {
2906 signatures: [
2907 SignatureInformation {
2908 label: "(Unit => Unit)",
2909 documentation: None,
2910 parameters: [
2911 ParameterInformation {
2912 label: (
2913 1,
2914 5,
2915 ),
2916 documentation: None,
2917 },
2918 ],
2919 },
2920 ],
2921 active_signature: 0,
2922 active_parameter: 0,
2923 }
2924 "#]],
2925 );
2926}
2927
2928#[test]
2929fn indirect_single_param_call() {
2930 check(
2931 indoc! {r#"
2932 namespace Test {
2933 operation Foo(x : Int) : Unit {
2934 let foo = Foo;
2935 foo(↘)
2936 let x = 3;
2937 }
2938 }
2939 "#},
2940 &expect![[r#"
2941 SignatureHelp {
2942 signatures: [
2943 SignatureInformation {
2944 label: "(Int => Unit)",
2945 documentation: None,
2946 parameters: [
2947 ParameterInformation {
2948 label: (
2949 1,
2950 4,
2951 ),
2952 documentation: None,
2953 },
2954 ParameterInformation {
2955 label: (
2956 1,
2957 4,
2958 ),
2959 documentation: None,
2960 },
2961 ],
2962 },
2963 ],
2964 active_signature: 0,
2965 active_parameter: 1,
2966 }
2967 "#]],
2968 );
2969}
2970
2971#[test]
2972fn udt_constructor_call() {
2973 check(
2974 indoc! {r#"
2975 namespace Test {
2976 newtype Foo = (fst : Int, snd : Double);
2977 operation Bar(x : Int) : Unit {
2978 let foo = Foo(↘)
2979 let x = 3;
2980 }
2981 }
2982 "#},
2983 &expect![[r#"
2984 SignatureHelp {
2985 signatures: [
2986 SignatureInformation {
2987 label: "((Int, Double) -> Foo)",
2988 documentation: None,
2989 parameters: [
2990 ParameterInformation {
2991 label: (
2992 1,
2993 14,
2994 ),
2995 documentation: None,
2996 },
2997 ParameterInformation {
2998 label: (
2999 2,
3000 5,
3001 ),
3002 documentation: None,
3003 },
3004 ParameterInformation {
3005 label: (
3006 7,
3007 13,
3008 ),
3009 documentation: None,
3010 },
3011 ],
3012 },
3013 ],
3014 active_signature: 0,
3015 active_parameter: 1,
3016 }
3017 "#]],
3018 );
3019}
3020
3021#[test]
3022fn std_callable_with_udt() {
3023 check(
3024 r#"
3025 namespace Test {
3026 open FakeStdLib;
3027 operation Foo() : Udt {
3028 TakesUdt(↘)
3029 }
3030 }
3031 "#,
3032 &expect![[r#"
3033 SignatureHelp {
3034 signatures: [
3035 SignatureInformation {
3036 label: "function TakesUdt(input : Udt) : Udt",
3037 documentation: None,
3038 parameters: [
3039 ParameterInformation {
3040 label: (
3041 17,
3042 30,
3043 ),
3044 documentation: None,
3045 },
3046 ParameterInformation {
3047 label: (
3048 18,
3049 29,
3050 ),
3051 documentation: None,
3052 },
3053 ],
3054 },
3055 ],
3056 active_signature: 0,
3057 active_parameter: 1,
3058 }
3059 "#]],
3060 );
3061}
3062
3063#[test]
3064fn indirect_callable_with_std_udt_args() {
3065 check(
3066 r#"
3067 namespace Test {
3068 open FakeStdLib;
3069 operation Foo() : Udt {
3070 let callee = TakesUdt;
3071 callee(↘)
3072 }
3073 }
3074 "#,
3075 &expect![[r#"
3076 SignatureHelp {
3077 signatures: [
3078 SignatureInformation {
3079 label: "(Udt -> Udt)",
3080 documentation: None,
3081 parameters: [
3082 ParameterInformation {
3083 label: (
3084 1,
3085 4,
3086 ),
3087 documentation: None,
3088 },
3089 ParameterInformation {
3090 label: (
3091 1,
3092 4,
3093 ),
3094 documentation: None,
3095 },
3096 ],
3097 },
3098 ],
3099 active_signature: 0,
3100 active_parameter: 1,
3101 }
3102 "#]],
3103 );
3104}
3105
3106#[test]
3107fn indirect_callable_with_std_udt() {
3108 check(
3109 r#"
3110 namespace Test {
3111 open FakeStdLib;
3112 operation Foo() : Unit {
3113 let fn = UdtFn((x) -> x);
3114 fn!(↘)
3115 }
3116 }
3117 "#,
3118 &expect![[r#"
3119 SignatureHelp {
3120 signatures: [
3121 SignatureInformation {
3122 label: "(Int -> Int)",
3123 documentation: None,
3124 parameters: [
3125 ParameterInformation {
3126 label: (
3127 1,
3128 4,
3129 ),
3130 documentation: None,
3131 },
3132 ParameterInformation {
3133 label: (
3134 1,
3135 4,
3136 ),
3137 documentation: None,
3138 },
3139 ],
3140 },
3141 ],
3142 active_signature: 0,
3143 active_parameter: 1,
3144 }
3145 "#]],
3146 );
3147}
3148
3149#[test]
3150fn indirect_callable_with_std_udt_with_params() {
3151 check(
3152 r#"
3153 namespace Test {
3154 open FakeStdLib;
3155 operation Foo() : Unit {
3156 let fn = UdtFnWithUdtParams(TakesUdt);
3157 fn!(↘)
3158 }
3159 }
3160 "#,
3161 &expect![[r#"
3162 SignatureHelp {
3163 signatures: [
3164 SignatureInformation {
3165 label: "(Udt -> Udt)",
3166 documentation: None,
3167 parameters: [
3168 ParameterInformation {
3169 label: (
3170 1,
3171 4,
3172 ),
3173 documentation: None,
3174 },
3175 ParameterInformation {
3176 label: (
3177 1,
3178 4,
3179 ),
3180 documentation: None,
3181 },
3182 ],
3183 },
3184 ],
3185 active_signature: 0,
3186 active_parameter: 1,
3187 }
3188 "#]],
3189 );
3190}
3191
3192#[test]
3193fn indirect_callable_with_std_struct() {
3194 check(
3195 r#"
3196 namespace Test {
3197 open FakeStdLib;
3198 operation Foo() : Unit {
3199 let fn = new StructFn { inner = (x) -> x };
3200 fn::inner(↘)
3201 }
3202 }
3203 "#,
3204 &expect![[r#"
3205 SignatureHelp {
3206 signatures: [
3207 SignatureInformation {
3208 label: "(Int -> Int)",
3209 documentation: None,
3210 parameters: [
3211 ParameterInformation {
3212 label: (
3213 1,
3214 4,
3215 ),
3216 documentation: None,
3217 },
3218 ParameterInformation {
3219 label: (
3220 1,
3221 4,
3222 ),
3223 documentation: None,
3224 },
3225 ],
3226 },
3227 ],
3228 active_signature: 0,
3229 active_parameter: 1,
3230 }
3231 "#]],
3232 );
3233}
3234
3235#[test]
3236fn indirect_callable_with_std_struct_with_params() {
3237 check(
3238 r#"
3239 namespace Test {
3240 open FakeStdLib;
3241 operation Foo() : Unit {
3242 let fn = new StructFnWithStructParams { inner = TakesStruct };
3243 fn::inner(↘)
3244 }
3245 }
3246 "#,
3247 &expect![[r#"
3248 SignatureHelp {
3249 signatures: [
3250 SignatureInformation {
3251 label: "(FakeStruct -> FakeStruct)",
3252 documentation: None,
3253 parameters: [
3254 ParameterInformation {
3255 label: (
3256 1,
3257 11,
3258 ),
3259 documentation: None,
3260 },
3261 ParameterInformation {
3262 label: (
3263 1,
3264 11,
3265 ),
3266 documentation: None,
3267 },
3268 ],
3269 },
3270 ],
3271 active_signature: 0,
3272 active_parameter: 1,
3273 }
3274 "#]],
3275 );
3276}
3277
3278#[test]
3279fn call_with_type_param() {
3280 check(
3281 indoc! {r#"
3282 namespace Test {
3283 operation Foo<'A, 'B>(a : 'A, b : 'B) : 'B { b }
3284 operation Bar() : Unit {
3285 Foo(1,↘)
3286 let x = 3;
3287 }
3288 }
3289 "#},
3290 &expect![[r#"
3291 SignatureHelp {
3292 signatures: [
3293 SignatureInformation {
3294 label: "operation Foo<'A, 'B>(a : 'A, b : 'B) : 'B",
3295 documentation: None,
3296 parameters: [
3297 ParameterInformation {
3298 label: (
3299 21,
3300 37,
3301 ),
3302 documentation: None,
3303 },
3304 ParameterInformation {
3305 label: (
3306 22,
3307 28,
3308 ),
3309 documentation: None,
3310 },
3311 ParameterInformation {
3312 label: (
3313 30,
3314 36,
3315 ),
3316 documentation: None,
3317 },
3318 ],
3319 },
3320 ],
3321 active_signature: 0,
3322 active_parameter: 2,
3323 }
3324 "#]],
3325 );
3326}
3327
3328#[test]
3329fn std_callable_with_type_params() {
3330 check(
3331 r#"
3332 namespace Test {
3333 open FakeStdLib;
3334 operation Foo() : Unit {
3335 let temp = FakeWithTypeParam(↘);
3336 }
3337 }
3338 "#,
3339 &expect![[r#"
3340 SignatureHelp {
3341 signatures: [
3342 SignatureInformation {
3343 label: "operation FakeWithTypeParam<'A>(a : 'A) : 'A",
3344 documentation: None,
3345 parameters: [
3346 ParameterInformation {
3347 label: (
3348 31,
3349 39,
3350 ),
3351 documentation: None,
3352 },
3353 ParameterInformation {
3354 label: (
3355 32,
3356 38,
3357 ),
3358 documentation: None,
3359 },
3360 ],
3361 },
3362 ],
3363 active_signature: 0,
3364 active_parameter: 1,
3365 }
3366 "#]],
3367 );
3368}
3369