@@ -572,11 +572,11 @@ class LSPTests extends FunSuite {
572
572
//
573
573
//
574
574
575
- test(" inlayHints should show the io effect" ) {
575
+ test(" inlayHint should show the io effect" ) {
576
576
withClientAndServer { (client, server) =>
577
577
val (textDoc, positions) = raw """
578
578
|↑
579
- |def main() = {
579
+ |def main(): Unit = {
580
580
|↑
581
581
| println("Hello, world!")
582
582
|}
@@ -609,12 +609,61 @@ class LSPTests extends FunSuite {
609
609
}
610
610
}
611
611
612
- test(" inlayHints work after editing" ) {
612
+ test(" inlayHint shows omitted return type and effect" ) {
613
+ withClientAndServer { (client, server) =>
614
+ val (textDoc, positions) =
615
+ raw """ effect raise(): Unit
616
+ |
617
+ |↑
618
+ |def foo() = { do raise(); 5 }
619
+ |↑ ↑
620
+ |
621
+ |↑
622
+ | """ .textDocumentAndPositions
623
+
624
+ val captureHint = new InlayHint ()
625
+ captureHint.setKind(InlayHintKind .Type )
626
+ captureHint.setPosition(positions(1 ))
627
+ captureHint.setLabel(" {}" )
628
+ captureHint.setData(" capture" )
629
+ captureHint.setTooltip(new MarkupContent (" markdown" , " captures: `{}`" ))
630
+ captureHint.setPaddingRight(true )
631
+
632
+ val omittedHint = new InlayHint ()
633
+ omittedHint.setKind(InlayHintKind .Type )
634
+ omittedHint.setPosition(positions(2 ))
635
+ omittedHint.setLabel(" : Int / { raise }" )
636
+ omittedHint.setData(" return-type-annotation" )
637
+ omittedHint.setTextEdits(List (
638
+ new TextEdit (
639
+ new Range (positions(2 ), positions(2 )),
640
+ " : Int / { raise }"
641
+ )
642
+ ).asJava)
643
+ omittedHint.setTooltip(new MarkupContent (" markdown" , " return type: Int / { raise }" ))
644
+ omittedHint.setPaddingLeft(true )
645
+
646
+ val expectedInlayHints = List (captureHint, omittedHint)
647
+
648
+ val didOpenParams = new DidOpenTextDocumentParams ()
649
+ didOpenParams.setTextDocument(textDoc)
650
+ server.getTextDocumentService().didOpen(didOpenParams)
651
+
652
+ val params = new InlayHintParams ()
653
+ params.setTextDocument(textDoc.versionedTextDocumentIdentifier)
654
+ params.setRange(new Range (positions(0 ), positions(3 )))
655
+
656
+ val inlayHints = server.getTextDocumentService().inlayHint(params).get()
657
+ assertEquals(expectedInlayHints.asJava, inlayHints)
658
+ }
659
+ }
660
+
661
+ test(" inlayHint works after editing" ) {
613
662
withClientAndServer { (client, server) =>
614
663
val (textDoc, positions) =
615
664
raw """
616
665
|↑
617
- |def main() = {
666
+ |def main(): Unit = {
618
667
|↑
619
668
| println("Hello, world!")
620
669
|}
@@ -652,7 +701,7 @@ class LSPTests extends FunSuite {
652
701
val (newTextDoc, changeEvent) = textDoc.changeTo(
653
702
raw """
654
703
|
655
- |def main() = {
704
+ |def main(): Unit = {
656
705
| println("Hello, world!")
657
706
|}
658
707
| """ .stripMargin
@@ -694,12 +743,12 @@ class LSPTests extends FunSuite {
694
743
695
744
}
696
745
697
- test(" inlayHints work after invalid edits" ) {
746
+ test(" inlayHint works after invalid edits" ) {
698
747
withClientAndServer(false ) { (client, server) =>
699
748
val (textDoc, positions) =
700
749
raw """
701
750
|↑
702
- |def main() = {
751
+ |def main(): Unit = {
703
752
|↑
704
753
| println("Hello, world!")
705
754
|}
@@ -736,7 +785,7 @@ class LSPTests extends FunSuite {
736
785
737
786
val (newTextDoc, changeEvent) = textDoc.changeTo(
738
787
raw """
739
- |def main() = {
788
+ |def main(): Unit = {
740
789
| println("Hello, world!")
741
790
|}
742
791
|invalid syntax
0 commit comments