Skip to content

Commit 3adb338

Browse files
committed
Merge branch 'topic/vadim/docs' into 'master'
Testcases for objects and exceptions See merge request eng/ide/gnatdoc!203
2 parents 72556e7 + 6f19e2f commit 3adb338

File tree

11 files changed

+366
-1
lines changed

11 files changed

+366
-1
lines changed

source/gnatdoc-comments-helpers.adb

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,7 @@ package body GNATdoc.Comments.Helpers is
496496
| Ada_Generic_Package_Decl
497497
| Ada_Generic_Subp_Decl
498498
| Ada_Incomplete_Type_Decl
499+
| Ada_Number_Decl
499500
| Ada_Object_Decl
500501
| Ada_Package_Body
501502
| Ada_Package_Decl
@@ -511,7 +512,7 @@ package body GNATdoc.Comments.Helpers is
511512

512513
All_Decls : constant Libadalang.Analysis.Defining_Name_Array :=
513514
Name.P_All_Parts;
514-
Most_Visible_Decl : constant Libadalang.Analysis.Defining_Name :=
515+
Most_Visible_Decl : Libadalang.Analysis.Defining_Name :=
515516
(if Origin.Is_Null
516517
then Name.As_Defining_Name else Name.P_Most_Visible_Part (Origin));
517518
Most_Visible_Index : Positive := All_Decls'First;
@@ -527,6 +528,18 @@ package body GNATdoc.Comments.Helpers is
527528
Comment : Structured_Comment;
528529

529530
begin
531+
-- LAL 20250922: `P_Most_Visible_Part` returns `null` for named
532+
-- numbers.
533+
534+
if Most_Visible_Decl.Is_Null then
535+
if Name.P_Basic_Decl.Kind = Ada_Number_Decl then
536+
Most_Visible_Decl := Name.As_Defining_Name;
537+
538+
else
539+
raise Program_Error;
540+
end if;
541+
end if;
542+
530543
-- Lookup for index of most visible declaration
531544

532545
for J in All_Decls'Range loop
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
2+
package body Exceptions is
3+
4+
procedure Dummy is
5+
begin
6+
begin
7+
raise Test_Exception;
8+
9+
exception
10+
when Test_Exception =>
11+
null;
12+
end;
13+
end Dummy;
14+
15+
end Exceptions;
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
package Exceptions is
3+
4+
Test_Exception : exception;
5+
-- Description of the exception
6+
7+
private
8+
9+
procedure Dummy;
10+
11+
end Exceptions;
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
with Exceptions; use Exceptions;
2+
3+
package body Exceptions_Package is
4+
5+
procedure Dummy is
6+
begin
7+
begin
8+
raise Test_Exception;
9+
10+
exception
11+
when Test_Exception =>
12+
null;
13+
end;
14+
end Dummy;
15+
16+
end Exceptions_Package;
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
package Exceptions_Package is
3+
4+
procedure Dummy;
5+
6+
end Exceptions_Package;

testsuite/als_helper/locations.json

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,50 @@
8787
{"file": "discriminant_record_types_package.adb", "line": 36, "column": 26},
8888
// reference: `Known_Discriminant_Private_Null_Record`
8989

90+
{"file": "objects.ads", "line": 4, "column": 4},
91+
// declaration: `Named_Number`
92+
{"file": "objects.adb", "line": 7, "column": 30},
93+
// reference: `Named_Number`
94+
{"file": "objects_package.adb", "line": 8, "column": 30},
95+
// reference: `Named_Number`
96+
97+
{"file": "objects.ads", "line": 7, "column": 4},
98+
// declaration `Public_Constant`
99+
{"file": "objects.adb", "line": 14, "column": 30},
100+
// reference `Public_Constant`
101+
{"file": "objects_package.adb", "line": 15, "column": 30},
102+
// reference `Public_Constant`
103+
104+
{"file": "objects.ads", "line": 10, "column": 4},
105+
// declaration `Private_Constant`
106+
{"file": "objects.ads", "line": 21, "column": 4},
107+
// declaration `Private_Constant`
108+
{"file": "objects.adb", "line": 21, "column": 30},
109+
// reference `Private_Constant`
110+
{"file": "objects_package.adb", "line": 22, "column": 30},
111+
// reference `Private_Constant`
112+
113+
{"file": "objects.ads", "line": 13, "column": 4},
114+
// declaration of the object
115+
{"file": "objects.adb", "line": 28, "column": 30},
116+
// reference of the object
117+
{"file": "objects_package.adb", "line": 29, "column": 30},
118+
// reference of the object
119+
120+
{"file": "objects.ads", "line": 16, "column": 4},
121+
// declaration of the object with default value
122+
{"file": "objects.adb", "line": 35, "column": 30},
123+
// reference of the object with default value
124+
{"file": "objects_package.adb", "line": 36, "column": 30},
125+
// reference of the object with default value
126+
127+
{"file": "exceptions.ads", "line": 4, "column": 4},
128+
// declaration of the exception
129+
{"file": "exceptions.adb", "line": 7, "column": 16},
130+
// reference of the exception
131+
{"file": "exceptions_package.adb", "line": 8, "column": 16},
132+
// reference of the exception
133+
90134
// {"file": "pkg1.ads", "line": 5, "column": 9}, // package specification name
91135
// {"file": "pkg1.ads", "line": 9, "column": 5}, // package specification end name
92136
// {"file": "pkg1.adb", "line": 5, "column": 14}, // package body name

testsuite/als_helper/objects.adb

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
2+
package body Objects is
3+
4+
procedure Dummy is
5+
begin
6+
declare
7+
Object : Integer := Named_Number;
8+
9+
begin
10+
null;
11+
end;
12+
13+
declare
14+
Object : Integer := Public_Constant;
15+
16+
begin
17+
null;
18+
end;
19+
20+
declare
21+
Object : Integer := Private_Constant;
22+
23+
begin
24+
null;
25+
end;
26+
27+
declare
28+
Object : Integer := Value;
29+
30+
begin
31+
null;
32+
end;
33+
34+
declare
35+
Object : Integer := Value_Default;
36+
37+
begin
38+
null;
39+
end;
40+
end Dummy;
41+
42+
end Objects;

testsuite/als_helper/objects.ads

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
2+
package Objects is
3+
4+
Named_Number : constant := 2;
5+
-- Description of the named number
6+
7+
Public_Constant : constant Integer := 3;
8+
-- Description of the `Public_Constant`
9+
10+
Private_Constant : constant Integer;
11+
-- Public description of the `Private_Constant`
12+
13+
Value : Integer;
14+
-- Description of the object
15+
16+
Value_Default : Integer := 1;
17+
-- Description of the object with default value
18+
19+
private
20+
21+
Private_Constant : constant Integer := 4;
22+
-- Private description of the `Private_Constant`
23+
24+
procedure Dummy;
25+
26+
end Objects;
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
with Objects; use Objects;
2+
3+
package body Objects_Package is
4+
5+
procedure Dummy is
6+
begin
7+
declare
8+
Object : Integer := Named_Number;
9+
10+
begin
11+
null;
12+
end;
13+
14+
declare
15+
Object : Integer := Public_Constant;
16+
17+
begin
18+
null;
19+
end;
20+
21+
declare
22+
Object : Integer := Private_Constant;
23+
24+
begin
25+
null;
26+
end;
27+
28+
declare
29+
Object : Integer := Value;
30+
31+
begin
32+
null;
33+
end;
34+
35+
declare
36+
Object : Integer := Value_Default;
37+
38+
begin
39+
null;
40+
end;
41+
end Dummy;
42+
43+
end Objects_Package;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
package Objects_Package is
3+
4+
private
5+
6+
procedure Dummy;
7+
8+
end Objects_Package;

0 commit comments

Comments
 (0)