@@ -483,6 +483,16 @@ def find_in_results(uri, sline):
483
483
484
484
485
485
def test_hover ():
486
+ def hover_req (file_path : str , ln : int , col : int ) -> str :
487
+ return write_rpc_request (
488
+ 1 ,
489
+ "textDocument/hover" ,
490
+ {
491
+ "textDocument" : {"uri" : file_path },
492
+ "position" : {"line" : ln , "character" : col },
493
+ },
494
+ )
495
+
486
496
def check_return (result_array , checks ):
487
497
assert len (result_array ) == len (checks )
488
498
for (i , check ) in enumerate (checks ):
@@ -491,22 +501,32 @@ def check_return(result_array, checks):
491
501
#
492
502
string = write_rpc_request (1 , "initialize" , {"rootPath" : test_dir })
493
503
file_path = os .path .join (test_dir , "subdir" , "test_abstract.f90" )
494
- string += write_rpc_request (
495
- 2 ,
496
- "textDocument/hover" ,
497
- {"textDocument" : {"uri" : file_path }, "position" : {"line" : 7 , "character" : 30 }},
498
- )
499
- errcode , results = run_request (string )
504
+ string += hover_req (file_path , 7 , 30 )
505
+ file_path = os .path .join (test_dir , "hover" , "parameters.f90" )
506
+ string += hover_req (file_path , 2 , 28 )
507
+ string += hover_req (file_path , 3 , 28 )
508
+ string += hover_req (file_path , 4 , 28 )
509
+ string += hover_req (file_path , 4 , 41 )
510
+ string += hover_req (file_path , 6 , 28 )
511
+ string += hover_req (file_path , 7 , 38 )
512
+ string += hover_req (file_path , 7 , 55 )
513
+ errcode , results = run_request (string , fortls_args = " --variable_hover" )
500
514
assert errcode == 0
501
515
#
502
- check_return (
503
- results [1 :],
504
- (
505
- """SUBROUTINE test(a, b)
516
+ ref_results = (
517
+ """SUBROUTINE test(a, b)
506
518
INTEGER(4), DIMENSION(3,6), INTENT(IN) :: a
507
519
REAL(8), DIMENSION(4), INTENT(OUT) :: b""" ,
508
- ),
520
+ "INTEGER, PARAMETER :: var = 1000" ,
521
+ "INTEGER" ,
522
+ "INTEGER, PARAMETER :: var2 = 23" ,
523
+ "INTEGER, PARAMETER :: var3 = var*var2" ,
524
+ "INTEGER, PARAMETER :: var4 = 123" ,
525
+ "DOUBLE PRECISION, PARAMETER :: somevar = 23.12" ,
526
+ "DOUBLE PRECISION, PARAMETER :: some = 1e-19" ,
509
527
)
528
+ assert len (ref_results ) == len (results ) - 1
529
+ check_return (results [1 :], ref_results )
510
530
511
531
512
532
def test_docs ():
0 commit comments