@@ -468,6 +468,16 @@ defmodule NextLSTest do
468
468
469
469
describe "two" do
470
470
setup % { cwd: cwd } do
471
+ remote = Path . join ( cwd , "lib/remote.ex" )
472
+
473
+ File . write! ( remote , """
474
+ defmodule Remote do
475
+ def bang!() do
476
+ "‼️"
477
+ end
478
+ end
479
+ """ )
480
+
471
481
imported = Path . join ( cwd , "lib/imported.ex" )
472
482
473
483
File . write! ( imported , """
@@ -484,6 +494,7 @@ defmodule NextLSTest do
484
494
defmodule Foo do
485
495
import Imported
486
496
def run() do
497
+ Remote.bang!()
487
498
process()
488
499
end
489
500
@@ -494,7 +505,7 @@ defmodule NextLSTest do
494
505
end
495
506
""" )
496
507
497
- [ bar: bar , imported: imported ]
508
+ [ bar: bar , imported: imported , remote: remote ]
498
509
end
499
510
500
511
setup :with_lsp
@@ -517,19 +528,19 @@ defmodule NextLSTest do
517
528
id: 4 ,
518
529
jsonrpc: "2.0" ,
519
530
params: % {
520
- position: % { line: 3 , character: 6 } ,
531
+ position: % { line: 4 , character: 6 } ,
521
532
textDocument: % { uri: uri }
522
533
}
523
534
} )
524
535
525
536
assert_result 4 , % {
526
537
"range" => % {
527
538
"start" => % {
528
- "line" => 6 ,
539
+ "line" => 7 ,
529
540
"character" => 0
530
541
} ,
531
542
"end" => % {
532
- "line" => 6 ,
543
+ "line" => 7 ,
533
544
"character" => 0
534
545
}
535
546
} ,
@@ -555,7 +566,7 @@ defmodule NextLSTest do
555
566
id: 4 ,
556
567
jsonrpc: "2.0" ,
557
568
params: % {
558
- position: % { line: 7 , character: 5 } ,
569
+ position: % { line: 8 , character: 5 } ,
559
570
textDocument: % { uri: uri }
560
571
}
561
572
} )
@@ -576,6 +587,46 @@ defmodule NextLSTest do
576
587
"uri" => ^ uri
577
588
}
578
589
end
590
+
591
+ test "go to remote function definition" , % { client: client , bar: bar , remote: remote } do
592
+ assert :ok ==
593
+ notify ( client , % {
594
+ method: "initialized" ,
595
+ jsonrpc: "2.0" ,
596
+ params: % { }
597
+ } )
598
+
599
+ assert_notification "window/logMessage" , % { "message" => "[NextLS] Runtime ready..." }
600
+ assert_notification "window/logMessage" , % { "message" => "[NextLS] Compiled!" }
601
+
602
+ uri = uri ( bar )
603
+
604
+ request ( client , % {
605
+ method: "textDocument/definition" ,
606
+ id: 4 ,
607
+ jsonrpc: "2.0" ,
608
+ params: % {
609
+ position: % { line: 3 , character: 12 } ,
610
+ textDocument: % { uri: uri }
611
+ }
612
+ } )
613
+
614
+ uri = uri ( remote )
615
+
616
+ assert_result 4 , % {
617
+ "range" => % {
618
+ "start" => % {
619
+ "line" => 1 ,
620
+ "character" => 0
621
+ } ,
622
+ "end" => % {
623
+ "line" => 1 ,
624
+ "character" => 0
625
+ }
626
+ } ,
627
+ "uri" => ^ uri
628
+ }
629
+ end
579
630
end
580
631
581
632
defp with_lsp ( % { tmp_dir: tmp_dir } ) do
0 commit comments