Skip to content

Commit 0809c44

Browse files
committed
Merge branch 'topic/tasking' into 'master'
Topic/tasking See merge request eng/ide/gnatdoc!23
2 parents 691a913 + 2bb1fb4 commit 0809c44

14 files changed

+915
-151
lines changed

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@ check_extractor:
1717
(cd testsuite/extractor && ../../.objs/test_extractor gnat.json exceptions.ads | diff -u --strip-trailing-cr exceptions.out -)
1818
(cd testsuite/extractor && ../../.objs/test_extractor gnat.json records.ads | diff -u --strip-trailing-cr records.out -)
1919
(cd testsuite/extractor && ../../.objs/test_extractor gnat.json tasks.ads | diff -u --strip-trailing-cr tasks.out -)
20-
(cd testsuite/extractor && ../../.objs/test_extractor gnat.json protecteds.ads | diff -u --strip-trailing-cr protecteds.out -)
20+
(cd testsuite/extractor && ../../.objs/test_extractor gnat.json protecteds.ads | diff -u --strip-trailing-cr protecteds.ads.out -)
21+
(cd testsuite/extractor && ../../.objs/test_extractor gnat.json protecteds.adb | diff -u --strip-trailing-cr protecteds.adb.out -)

source/backend/streams.adb

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
-- of the license. --
1616
------------------------------------------------------------------------------
1717

18-
with VSS.Stream_Element_Vectors.Conversions;
18+
with VSS.Strings.Conversions;
1919

2020
package body Streams is
2121

@@ -25,7 +25,8 @@ package body Streams is
2525

2626
procedure Close (Self : in out Output_Text_Stream'Class) is
2727
begin
28-
GNATCOLL.VFS.Close (Self.Writable);
28+
VSS.Text_Streams.File_Output.File_Output_Text_Stream
29+
(Self).Close;
2930
end Close;
3031

3132
----------
@@ -36,28 +37,9 @@ package body Streams is
3637
(Self : in out Output_Text_Stream'Class;
3738
File : GNATCOLL.VFS.Virtual_File) is
3839
begin
39-
Self.Encoder.Initialize ("utf-8");
40-
Self.Writable := File.Write_File;
40+
Self.Create
41+
(VSS.Strings.Conversions.To_Virtual_String (File.Display_Full_Name),
42+
"utf-8");
4143
end Open;
4244

43-
---------
44-
-- Put --
45-
---------
46-
47-
overriding procedure Put
48-
(Self : in out Output_Text_Stream;
49-
Item : VSS.Characters.Virtual_Character;
50-
Success : in out Boolean)
51-
is
52-
pragma Unreferenced (Success);
53-
54-
Data : constant String :=
55-
VSS.Stream_Element_Vectors.Conversions.Unchecked_To_String
56-
(Self.Encoder.Encode (Item));
57-
58-
begin
59-
GNATCOLL.VFS.Write (Self.Writable, Data);
60-
-- Note, any errors are reported at the time of file close only.
61-
end Put;
62-
6345
end Streams;

source/backend/streams.ads

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,8 @@
1717

1818
with GNATCOLL.VFS;
1919

20-
private with VSS.Characters;
21-
private with VSS.Strings.Converters.Encoders;
2220
with VSS.Text_Streams;
21+
private with VSS.Text_Streams.File_Output;
2322

2423
package Streams is
2524

@@ -35,14 +34,7 @@ package Streams is
3534
private
3635

3736
type Output_Text_Stream is
38-
limited new VSS.Text_Streams.Output_Text_Stream with record
39-
Encoder : VSS.Strings.Converters.Encoders.Virtual_String_Encoder;
40-
Writable : GNATCOLL.VFS.Writable_File;
41-
end record;
42-
43-
overriding procedure Put
44-
(Self : in out Output_Text_Stream;
45-
Item : VSS.Characters.Virtual_Character;
46-
Success : in out Boolean);
37+
limited new VSS.Text_Streams.File_Output.File_Output_Text_Stream with
38+
null record;
4739

4840
end Streams;

source/frontend/gnatdoc-frontend.adb

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,10 @@ package body GNATdoc.Frontend is
130130
with
131131
Pre => Node.Kind in Ada_Single_Protected_Decl | Ada_Protected_Type_Decl;
132132

133+
procedure Process_Protected_Body
134+
(Node : Protected_Body'Class;
135+
Enclosing : not null GNATdoc.Entities.Entity_Information_Access);
136+
133137
procedure Process_Entry_Decl
134138
(Node : Entry_Decl'Class;
135139
Enclosing : not null GNATdoc.Entities.Entity_Information_Access);
@@ -439,6 +443,11 @@ package body GNATdoc.Frontend is
439443

440444
return Over;
441445

446+
when Ada_Protected_Body =>
447+
Process_Protected_Body (Node.As_Protected_Body, Enclosing);
448+
449+
return Over;
450+
442451
when Ada_Ada_Node_List
443452
| Ada_Public_Part | Ada_Private_Part
444453
| Ada_Declarative_Part
@@ -460,6 +469,12 @@ package body GNATdoc.Frontend is
460469

461470
return Over;
462471

472+
when Ada_Component_Decl =>
473+
-- Component declaration inside private part of the protected
474+
-- object/type declaration is ignored here.
475+
476+
return Over;
477+
463478
when others =>
464479
Ada.Text_IO.Put_Line (Image (Node) & " <<<<<");
465480

@@ -945,6 +960,37 @@ package body GNATdoc.Frontend is
945960
end if;
946961
end Process_Private_Type_Def;
947962

963+
----------------------------
964+
-- Process_Protected_Body --
965+
----------------------------
966+
967+
procedure Process_Protected_Body
968+
(Node : Protected_Body'Class;
969+
Enclosing : not null GNATdoc.Entities.Entity_Information_Access)
970+
is
971+
Name : constant Defining_Name := Node.F_Name;
972+
Entity : constant not null
973+
GNATdoc.Entities.Entity_Information_Access :=
974+
new GNATdoc.Entities.Entity_Information'
975+
(Name => To_Virtual_String (Name.F_Name.Text),
976+
Qualified_Name => To_Virtual_String (Name.P_Fully_Qualified_Name),
977+
Signature => Signature (Name),
978+
Enclosing =>
979+
Signature (Node.P_Parent_Basic_Decl.P_Defining_Name),
980+
Documentation => Extract (Node, GNATdoc.Options.Extractor_Options),
981+
others => <>);
982+
983+
begin
984+
Enclosing.Protected_Types.Insert (Entity);
985+
GNATdoc.Entities.To_Entity.Insert (Entity.Signature, Entity);
986+
987+
if GNATdoc.Entities.Globals'Access /= Enclosing then
988+
GNATdoc.Entities.Globals.Packages.Insert (Entity);
989+
end if;
990+
991+
Process_Children (Node.F_Decls, Entity);
992+
end Process_Protected_Body;
993+
948994
----------------------------
949995
-- Process_Protected_Decl --
950996
----------------------------
@@ -1101,7 +1147,7 @@ package body GNATdoc.Frontend is
11011147
do
11021148
case Name.P_Basic_Decl.Kind is
11031149
when Ada_Package_Body | Ada_Subp_Body | Ada_Expr_Function
1104-
| Ada_Subp_Renaming_Decl
1150+
| Ada_Subp_Renaming_Decl | Ada_Protected_Body
11051151
=>
11061152
Result.Append ('$');
11071153

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
------------------------------------------------------------------------------
2+
-- GNAT Documentation Generation Tool --
3+
-- --
4+
-- Copyright (C) 2022, AdaCore --
5+
-- --
6+
-- This is free software; you can redistribute it and/or modify it under --
7+
-- terms of the GNU General Public License as published by the Free Soft- --
8+
-- ware Foundation; either version 3, or (at your option) any later ver- --
9+
-- sion. This software is distributed in the hope that it will be useful, --
10+
-- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- --
11+
-- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public --
12+
-- License for more details. You should have received a copy of the GNU --
13+
-- General Public License distributed with this software; see file --
14+
-- COPYING3. If not, go to http://www.gnu.org/licenses for a complete copy --
15+
-- of the license. --
16+
------------------------------------------------------------------------------
17+
18+
package body GNATdoc.Comments.Builders.Protecteds is
19+
20+
use Libadalang.Analysis;
21+
use Libadalang.Common;
22+
23+
-----------
24+
-- Build --
25+
-----------
26+
27+
procedure Build
28+
(Self : in out Protected_Components_Builder;
29+
Documentation : not null GNATdoc.Comments.Structured_Comment_Access;
30+
Options : GNATdoc.Comments.Options.Extractor_Options;
31+
Node : Libadalang.Analysis.Basic_Decl'Class)
32+
is
33+
function Process (Node : Ada_Node'Class) return Visit_Status;
34+
35+
-------------
36+
-- Process --
37+
-------------
38+
39+
function Process (Node : Ada_Node'Class) return Visit_Status is
40+
begin
41+
case Node.Kind is
42+
when Ada_Known_Discriminant_Part | Ada_Discriminant_Spec_List
43+
| Ada_Private_Part | Ada_Decl_List
44+
=>
45+
-- Nodes that contains significant nodes inside thier
46+
-- subtrees.
47+
48+
return Into;
49+
50+
when Ada_Pragma_Node =>
51+
-- Nodes that doesn't contains significant information.
52+
53+
return Over;
54+
55+
when Ada_Component_Decl =>
56+
Self.Process_Component_Declaration (Node.As_Component_Decl);
57+
58+
for Name of Node.As_Component_Decl.F_Ids loop
59+
Self.Process_Defining_Name (Field, Name);
60+
end loop;
61+
62+
return Over;
63+
64+
when Ada_Discriminant_Spec =>
65+
Self.Process_Component_Declaration (Node.As_Discriminant_Spec);
66+
67+
for Name of Node.As_Discriminant_Spec.F_Ids loop
68+
Self.Process_Defining_Name (Field, Name);
69+
end loop;
70+
71+
return Over;
72+
73+
when Ada_Subp_Decl | Ada_Entry_Decl =>
74+
Self.Restart_Component_Group (Node.Sloc_Range.Start_Line);
75+
76+
return Over;
77+
78+
when others =>
79+
raise Program_Error with Ada_Node_Kind_Type'Image (Node.Kind);
80+
end case;
81+
end Process;
82+
83+
Discriminants : constant Discriminant_Part :=
84+
(case Node.Kind is
85+
when Ada_Protected_Type_Decl =>
86+
Node.As_Protected_Type_Decl.F_Discriminants,
87+
when others => No_Discriminant_Part);
88+
Definition : constant Protected_Def :=
89+
(case Node.Kind is
90+
when Ada_Single_Protected_Decl =>
91+
Node.As_Single_Protected_Decl.F_Definition,
92+
when Ada_Protected_Type_Decl =>
93+
Node.As_Protected_Type_Decl.F_Definition,
94+
when others => No_Protected_Def);
95+
96+
begin
97+
Self.Initialize (Documentation, Options, Node);
98+
99+
-- Process discriminants of the protected type declaration.
100+
101+
if not Discriminants.Is_Null then
102+
Discriminants.Traverse (Process'Access);
103+
104+
-- Detect first line of the next declartion after discriminants part
105+
106+
declare
107+
Token : Token_Reference := Discriminants.Token_End;
108+
109+
begin
110+
loop
111+
Token := Next (Token);
112+
113+
exit when Token = No_Token;
114+
115+
case Kind (Data (Token)) is
116+
when Ada_Whitespace | Ada_Comment =>
117+
-- Ignore whitespace separators and comments
118+
119+
null;
120+
121+
when Ada_Is | Ada_With =>
122+
-- Ignore 'is' and 'with' keyword that starts aspects
123+
-- specification, interface list of public parts of
124+
-- protected specification: they may be left on the
125+
-- same line with last discriminant.
126+
127+
null;
128+
129+
when others =>
130+
exit;
131+
end case;
132+
end loop;
133+
134+
if Token /= No_Token then
135+
Self.Restart_Component_Group
136+
(Sloc_Range (Data (Token)).End_Line);
137+
end if;
138+
end;
139+
end if;
140+
141+
-- Components of the private type can be declared in the private part
142+
-- only. Public part can contains subprograms/entries only, thus ignore
143+
-- hole public part.
144+
--
145+
-- ??? Should it be controlled by the "generate private" option ???
146+
147+
if not Definition.F_Private_Part.Is_Null then
148+
Definition.F_Private_Part.Traverse (Process'Access);
149+
Self.Restart_Component_Group (Node.Sloc_Range.End_Line);
150+
end if;
151+
152+
Self.Fill_Structured_Comment (Node, Options.Pattern);
153+
end Build;
154+
155+
end GNATdoc.Comments.Builders.Protecteds;
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
------------------------------------------------------------------------------
2+
-- GNAT Documentation Generation Tool --
3+
-- --
4+
-- Copyright (C) 2022, AdaCore --
5+
-- --
6+
-- This is free software; you can redistribute it and/or modify it under --
7+
-- terms of the GNU General Public License as published by the Free Soft- --
8+
-- ware Foundation; either version 3, or (at your option) any later ver- --
9+
-- sion. This software is distributed in the hope that it will be useful, --
10+
-- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- --
11+
-- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public --
12+
-- License for more details. You should have received a copy of the GNU --
13+
-- General Public License distributed with this software; see file --
14+
-- COPYING3. If not, go to http://www.gnu.org/licenses for a complete copy --
15+
-- of the license. --
16+
------------------------------------------------------------------------------
17+
18+
-- Structured comment builder for protected types and objects. It creates
19+
-- sections for components (and discriminants).
20+
21+
with Libadalang.Analysis;
22+
with Libadalang.Common;
23+
24+
package GNATdoc.Comments.Builders.Protecteds is
25+
26+
use all type Libadalang.Common.Ada_Node_Kind_Type;
27+
28+
type Protected_Components_Builder is
29+
new Abstract_Components_Builder with private;
30+
31+
procedure Build
32+
(Self : in out Protected_Components_Builder;
33+
Documentation : not null GNATdoc.Comments.Structured_Comment_Access;
34+
Options : GNATdoc.Comments.Options.Extractor_Options;
35+
Node : Libadalang.Analysis.Basic_Decl'Class)
36+
with Pre =>
37+
Node.Kind in Ada_Single_Protected_Decl | Ada_Protected_Type_Decl;
38+
39+
private
40+
41+
type Protected_Components_Builder is
42+
new Abstract_Components_Builder with null record;
43+
44+
end GNATdoc.Comments.Builders.Protecteds;

0 commit comments

Comments
 (0)