libgpr2_24.0.0_eda3c693/langkit/generated/src/gpr_parser_support-diagnostics.ads

 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
--
--  Copyright (C) 2014-2022, AdaCore
--  SPDX-License-Identifier: Apache-2.0
--

with Ada.Containers.Vectors;
with Ada.Exceptions;

with Gpr_Parser_Support.Slocs; use Gpr_Parser_Support.Slocs;
with Gpr_Parser_Support.Text; use Gpr_Parser_Support.Text;

--  This package provides a data type for diagnostics produced by Langkit
--  generated libraries.

package Gpr_Parser_Support.Diagnostics is

   type Diagnostic is record
      Sloc_Range : Source_Location_Range;
      --  The source location range that the diagnostic message refers to

      Message    : Unbounded_Text_Type;
      --  Message for this diagnostic
   end record;

   function To_Pretty_String (D : Diagnostic) return String;
   --  Pretty prints the given diagnostic.
   --
   --  .. note:: This is only intended for quick pretty printing in debugging
   --     for example. If you want more powerful and pretty output of
   --     diagnostics, use :ada:ref`Gpr_Parser_Support.Diagnostics.Output`.

   package Diagnostics_Vectors is new Ada.Containers.Vectors
     (Index_Type   => Positive,
      Element_Type => Diagnostic);

   type Diagnostics_Array is array (Positive range <>) of Diagnostic;

   function Create
     (Sloc_Range : Source_Location_Range;
      Message    : Wide_Wide_String) return Diagnostic;
   --  Shortcut to create a diagnostic

   procedure Append
     (Diagnostics : in out Diagnostics_Vectors.Vector;
      Sloc_Range  : Source_Location_Range := No_Source_Location_Range;
      Message     : Wide_Wide_String);
   --  Shortcut to append a diagnostic to a vector

   procedure Append
     (Diagnostics : in out Diagnostics_Vectors.Vector;
      Sloc_Range  : Source_Location_Range := No_Source_Location_Range;
      Exc         : Ada.Exceptions.Exception_Occurrence);
   --  Shortcut to append an exception message to a vector

end Gpr_Parser_Support.Diagnostics;