1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- D I A G N O S T I C S . R E P O S I T O R Y --
-- --
-- B o d y --
-- --
-- Copyright (C) 1992-2025, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING3. If not, go to --
-- http://www.gnu.org/licenses for a complete copy of the license. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with JSON_Utils; use JSON_Utils;
with Output; use Output;
package body Errid is
---------------
-- To_String --
---------------
function To_String (Id : Diagnostic_Id) return String is
begin
if Id = No_Diagnostic_Id then
return "GNAT0000";
else
return Id'Img;
end if;
end To_String;
---------------------------------
-- Print_Diagnostic_Repository --
---------------------------------
procedure Print_Diagnostic_Repository is
First : Boolean := True;
begin
Write_Char ('{');
Begin_Block;
NL_And_Indent;
Write_Str ("""" & "Diagnostics" & """" & ": " & "[");
Begin_Block;
-- Avoid printing the first switch, which is a placeholder
for I in Diagnostic_Entries'First .. Diagnostic_Entries'Last loop
if First then
First := False;
else
Write_Char (',');
end if;
NL_And_Indent;
Write_Char ('{');
Begin_Block;
NL_And_Indent;
Write_String_Attribute ("Id", To_String (I));
Write_Char (',');
NL_And_Indent;
if Diagnostic_Entries (I).Human_Id /= null then
Write_String_Attribute ("Human_Id",
Diagnostic_Entries (I).Human_Id.all);
else
Write_String_Attribute ("Human_Id", "null");
end if;
Write_Char (',');
NL_And_Indent;
if Diagnostic_Entries (I).Status = Active then
Write_String_Attribute ("Status", "Active");
else
Write_String_Attribute ("Status", "Deprecated");
end if;
Write_Char (',');
NL_And_Indent;
if Diagnostic_Entries (I).Documentation /= null then
Write_String_Attribute ("Documentation",
Diagnostic_Entries (I).Documentation.all);
else
Write_String_Attribute ("Documentation", "null");
end if;
Write_Char (',');
NL_And_Indent;
if Diagnostic_Entries (I).Switch /= No_Switch_Id then
Write_Char (',');
NL_And_Indent;
Write_String_Attribute
("Switch",
Get_Switch (Diagnostic_Entries (I).Switch).Human_Id.all);
else
Write_String_Attribute ("Switch", "null");
end if;
End_Block;
NL_And_Indent;
Write_Char ('}');
end loop;
End_Block;
NL_And_Indent;
Write_Char (']');
End_Block;
NL_And_Indent;
Write_Char ('}');
Write_Eol;
end Print_Diagnostic_Repository;
end Errid;
|