Skip to content

Commit 8a8ca57

Browse files
U427-019: Improve error handling for signatureHelp
When computing the signatures for a Call_Expr with a closing parenthesis, then mutliple Error_Stmt nodes can be added. Ignore then and try to find the Call_Expr in the siblings.
1 parent 095ae49 commit 8a8ca57

File tree

1 file changed

+28
-5
lines changed

1 file changed

+28
-5
lines changed

source/ada/lsp-lal_utils.adb

+28-5
Original file line numberDiff line numberDiff line change
@@ -365,12 +365,35 @@ package body LSP.Lal_Utils is
365365
Active_Position := 0;
366366
Name_Node := Libadalang.Analysis.No_Name;
367367

368-
-- Find the first Call_Expr node in the parents
369-
while not Cur_Node.Is_Null loop
370-
exit when Cur_Node.Kind in Ada_Call_Expr_Range;
368+
if not Cur_Node.Is_Null
369+
and then Cur_Node.Kind in Ada_Error_Stmt_Range
370+
then
371+
-- In case of Error_Stmt, find the nearest previous sibling
372+
-- which is not also an Error_Stmt
373+
while not Cur_Node.Is_Null
374+
and then Cur_Node.Kind in Ada_Error_Stmt_Range
375+
loop
376+
Cur_Node := Cur_Node.Previous_Sibling;
377+
end loop;
371378

372-
Cur_Node := Cur_Node.Parent;
373-
end loop;
379+
-- Find the nearest Call_Expr node in the children
380+
if not Cur_Node.Is_Null then
381+
for Child_Node of Cur_Node.Children loop
382+
if Child_Node.Kind in Ada_Call_Expr_Range then
383+
Cur_Node := Child_Node;
384+
exit;
385+
end if;
386+
end loop;
387+
end if;
388+
else
389+
390+
-- Find the nearest Call_Expr node in the parents
391+
while not Cur_Node.Is_Null loop
392+
exit when Cur_Node.Kind in Ada_Call_Expr_Range;
393+
394+
Cur_Node := Cur_Node.Parent;
395+
end loop;
396+
end if;
374397

375398
if Cur_Node.Is_Null then
376399
return;

0 commit comments

Comments
 (0)