Skip to content

Commit

Permalink
properties/complete: be resilient with incomplete lists
Browse files Browse the repository at this point in the history
Rework a couple of checks so that we do not assume that, for invalid
source code, trailing list separators are included in the range of
tokens for their list node.

    when M |
    --  '|' may not be part of the AlternativesList node for this
    --  CaseStmtAlternative node, so "node" may be the
    --  CaseStmtAlternative node here.

    procedure P (D: B;
    --  ';' may not be part of the ParamSpecList node, so "node" may
    --  be the Id node for 'B'.
  • Loading branch information
pmderodat committed Jul 17, 2024
1 parent 36479e5 commit 83cb991
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion testsuite/tests/properties/complete/case.adb
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ procedure Pcase is
begin
case D is
when M |
--% list(node.p_complete)
end case;
--% list(node.f_alternatives[0].f_choices.p_complete)
end P3;

procedure P4 (D : Week) is
Expand Down
4 changes: 2 additions & 2 deletions testsuite/tests/properties/complete/subtype_indication.adb
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ procedure Subtype_Indication is
F : Ba;
--% list(node.f_type_expr.f_name.p_complete)

procedure P (D: B;
--% list(node[0].f_type_expr.f_name.p_complete)
procedure P (D: B
--% list(node.p_complete)

type T is record
A : B;
Expand Down
12 changes: 6 additions & 6 deletions testsuite/tests/properties/complete/test.out
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,10 @@ Result: [<CompletionItem decl=<ParamSpec ["D"] case.adb:12:18-12:26> is_dot_call
<CompletionItem decl=<ConcreteTypeDecl ["Wide_Wide_String"] __standard:109:3-110:44> is_dot_call=False is_visible=True weight=0>,
<CompletionItem decl=<PackageDecl ["Standard"] __standard:1:1-130:14> is_dot_call=False is_visible=True weight=0>]

Working on node <AlternativesList case.adb:23:15-23:18>
=======================================================
Working on node <CaseStmt case.adb:22:7-26:4>
=============================================

Eval 'list(node.p_complete)'
Eval 'list(node.f_alternatives[0].f_choices.p_complete)'
Result: [<CompletionItem decl=<ParamSpec ["D"] case.adb:20:18-20:26> is_dot_call=False is_visible=True weight=0>,
<CompletionItem decl=<EnumLiteralDecl ["F"] case.adb:2:32-2:33> is_dot_call=False is_visible=True weight=100>,
<CompletionItem decl=<EnumLiteralDecl ["M"] case.adb:2:18-2:19> is_dot_call=False is_visible=True weight=100>,
Expand Down Expand Up @@ -943,10 +943,10 @@ Result: [<CompletionItem decl=<ObjectDecl ["A"] subtype_indication.adb:2:4-2:10>
<CompletionItem decl=<ConcreteTypeDecl ["Wide_Wide_String"] __standard:109:3-110:44> is_dot_call=False is_visible=True weight=100>,
<CompletionItem decl=<PackageDecl ["Standard"] __standard:1:1-130:14> is_dot_call=False is_visible=True weight=50>]

Working on node <ParamSpecList subtype_indication.adb:30:17-30:22>
==================================================================
Working on node <Id "B" subtype_indication.adb:30:20-30:21>
===========================================================

Eval 'list(node[0].f_type_expr.f_name.p_complete)'
Eval 'list(node.p_complete)'
Result: [<CompletionItem decl=<ParamSpec ["D"] subtype_indication.adb:30:17-30:21> is_dot_call=False is_visible=True weight=0>,
<CompletionItem decl=<ObjectDecl ["A"] subtype_indication.adb:2:4-2:10> is_dot_call=False is_visible=True weight=0>,
<CompletionItem decl=<ObjectDecl ["B"] subtype_indication.adb:10:4-10:10> is_dot_call=False is_visible=True weight=0>,
Expand Down

0 comments on commit 83cb991

Please sign in to comment.