Skip to content

Commit

Permalink
U409-026: Fix previous_part for protected bodies.
Browse files Browse the repository at this point in the history
  • Loading branch information
Roldak committed Apr 16, 2021
1 parent df0a14b commit 7e5f283
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 1 deletion.
3 changes: 2 additions & 1 deletion ada/ast.py
Original file line number Diff line number Diff line change
Expand Up @@ -2505,7 +2505,8 @@ def protected_previous_part():
Return the ProtectedDecl corresponding to this node.
"""
return Entity.defining_name.env_elements.at(0)._.match(
lambda prot_decl=T.ProtectedTypeDecl: prot_decl,
lambda prot_type=T.ProtectedTypeDecl: prot_type,
lambda prot_decl=T.SingleProtectedDecl: prot_decl,
lambda _: No(T.BasicDecl.entity)
)

Expand Down
15 changes: 15 additions & 0 deletions testsuite/tests/navigation/protected_body/prot.adb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package body Prot is
protected body P is
entry E (I : in out Integer) when Flag is
begin
I := Var + I;
Var := I; -- FLAG
end E;

procedure P (I : Integer) is
begin
Flag := I > 0;
end P;
end P;
--% node.p_decl_part()
end Prot;
11 changes: 11 additions & 0 deletions testsuite/tests/navigation/protected_body/prot.ads
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package Prot is
Var : Integer;

protected P is
entry E (I : in out Integer);
procedure P (I : Integer);
private
Flag : Boolean;
end P;

end Prot;
5 changes: 5 additions & 0 deletions testsuite/tests/navigation/protected_body/test.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Eval 'node.p_decl_part()' on node <ProtectedBody ["P"] prot.adb:2:4-13:10>
Result: <SingleProtectedDecl ["P"] prot.ads:4:4-9:10>



2 changes: 2 additions & 0 deletions testsuite/tests/navigation/protected_body/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
driver: inline-playground
input_sources: [prot.adb, prot.ads]
6 changes: 6 additions & 0 deletions user_manual/changes/U409-026.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
type: bugfix
title: Fix navigation of protected bodies
description: |
This change fixes a bug where calling ``P_Decl_Part`` on a protected body
which corresponding declaration was a SingleProtectedDecl would fail.
date: 2021-04-09

0 comments on commit 7e5f283

Please sign in to comment.