@@ -35,7 +35,7 @@ with Langkit_Support.Token_Data_Handlers;
35
35
36
36
with Pp.Actions ;
37
37
38
- with LSP.Types ; use LSP.Types;
38
+ with LSP.Types ; use LSP.Types;
39
39
40
40
package body LSP.Lal_Utils is
41
41
@@ -356,13 +356,36 @@ package body LSP.Lal_Utils is
356
356
357
357
procedure Get_Call_Expr_Name
358
358
(Node : Libadalang.Analysis.Ada_Node'Class;
359
+ Cursor_Line : Langkit_Support.Slocs.Line_Number;
360
+ Cursor_Column : Langkit_Support.Slocs.Column_Number;
359
361
Active_Position : out LSP.Types.LSP_Number;
360
362
Designator : out Libadalang.Analysis.Ada_Node;
361
363
Name_Node : out Libadalang.Analysis.Name)
362
364
is
365
+ use Langkit_Support.Slocs;
363
366
Cur_Node : Ada_Node := Node.As_Ada_Node;
367
+
368
+ function Is_Active (N : Ada_Node) return Boolean;
369
+ -- Check if N contains the cursor
370
+
371
+ -- -------------
372
+ -- Is_Active --
373
+ -- -------------
374
+
375
+ function Is_Active (N : Ada_Node) return Boolean
376
+ is
377
+ S : constant Langkit_Support.Slocs.Source_Location_Range :=
378
+ N.Sloc_Range;
379
+ begin
380
+ return S.Start_Line <= Cursor_Line
381
+ and then Cursor_Line <= S.End_Line
382
+ and then S.Start_Column <= Cursor_Column
383
+ and then Cursor_Column <= S.End_Column;
384
+ end Is_Active ;
385
+
364
386
begin
365
387
Active_Position := 0 ;
388
+ Designator := Libadalang.Analysis.No_Ada_Node;
366
389
Name_Node := Libadalang.Analysis.No_Name;
367
390
368
391
if not Cur_Node.Is_Null
@@ -404,11 +427,21 @@ package body LSP.Lal_Utils is
404
427
Cur_Node.As_Call_Expr;
405
428
Suffix_Node : constant Libadalang.Analysis.Ada_Node'Class :=
406
429
Call_Expr_Node.F_Suffix;
407
- Node_Parents : constant Libadalang.Analysis.Ada_Node_Array :=
408
- Node.Parents;
409
430
begin
410
431
Name_Node := Call_Expr_Node.F_Name;
411
432
433
+ if Name_Node.Kind in Ada_Dotted_Name_Range then
434
+ declare
435
+ Dot_Name : constant Dotted_Name := Name_Node.As_Dotted_Name;
436
+ begin
437
+ -- If the prefix is a parameter then increase the
438
+ -- Active_Position by 1
439
+ if Dot_Name.P_Is_Dot_Call (Imprecise_Fallback => True) then
440
+ Active_Position := Active_Position + 1 ;
441
+ end if ;
442
+ end ;
443
+ end if ;
444
+
412
445
if Suffix_Node = Libadalang.Analysis.No_Ada_Node then
413
446
return ;
414
447
end if ;
@@ -417,10 +450,8 @@ package body LSP.Lal_Utils is
417
450
if Suffix_Node.Kind in Ada_Assoc_List_Range then
418
451
for Assoc of Suffix_Node.As_Assoc_List loop
419
452
Designator := Assoc.As_Param_Assoc.F_Designator;
420
- for Parent of Node_Parents loop
421
- exit when Assoc = Parent;
422
- end loop ;
423
453
Active_Position := Active_Position + 1 ;
454
+ exit when Is_Active (Assoc.As_Ada_Node);
424
455
end loop ;
425
456
end if ;
426
457
-- The active position index starts at 0
0 commit comments