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