@@ -34,40 +34,45 @@ package Gnatcheck.Ids is
3434 (Index_Type => Natural, Element_Type => Rule_Id);
3535 -- A simple vector to store rule identifiers
3636
37+ -- ----------------
38+ -- Constant ids --
39+ -- ----------------
40+
41+ No_Rule_Id : constant Rule_Id := Find (All_Rule_Ids, To_Text (" " ));
42+ -- The empty identifier, used to express "no rule"
43+
44+ Restrictions_Id : constant Rule_Id :=
45+ Find (All_Rule_Ids, To_Text (" restrictions" ));
46+ Style_Checks_Id : constant Rule_Id :=
47+ Find (All_Rule_Ids, To_Text (" style_checks" ));
48+ Warnings_Id : constant Rule_Id :=
49+ Find (All_Rule_Ids, To_Text (" warnings" ));
50+ -- Fake identifiers, used to represent the compiler checks
51+
3752 -- -------------------------
3853 -- Operation on rule ids --
3954 -- -------------------------
4055
41- function Find_Rule_Id (Rule_Name : String) return Rule_Id;
56+ function Find_Rule_Id (Rule_Name : String) return Rule_Id is
57+ (Find (All_Rule_Ids, To_Lower (To_Text (Rule_Name)), True));
4258 -- This function maps the `Find` function of `Langkit_Support.Symbols`
4359 -- to the `Rule_Id` type, allowing user to get or create a rule identifier
4460 -- from a simple string. Note that the input string is normalized before
4561 -- the getting or creation of the rule identifier.
4662
47- function Get_Id_Text (Id : Rule_Id) return String;
63+ function Get_Id_Text (Id : Rule_Id) return String is
64+ (Image (To_Symbol (All_Rule_Ids, Id)));
4865 -- Get the text associated with the given `Rule_Id`, this text represents
4966 -- the normalized name of the rule identified by `Id`.
5067
51- function Is_Compiler_Rule (Id : Rule_Id) return Boolean;
68+ function Is_Compiler_Rule (Id : Rule_Id) return Boolean is
69+ (Id = Restrictions_Id
70+ or else Id = Warnings_Id
71+ or else Id = Style_Checks_Id);
5272 -- Get whether the given rule identifier represents a compiler-based check
5373
5474 function Hash (Id : Rule_Id) return Ada.Containers.Hash_Type is
5575 (Hash (To_Symbol (All_Rule_Ids, Thin_Symbol (Id))));
5676 -- Shortcut fonction to hash a rule identifier
5777
58- -- ----------------
59- -- Constant ids --
60- -- ----------------
61-
62- No_Rule_Id : constant Rule_Id := Find (All_Rule_Ids, To_Text (" " ));
63- -- The empty identifier, used to express "no rule"
64-
65- Restrictions_Id : constant Rule_Id :=
66- Find (All_Rule_Ids, To_Text (" restrictions" ));
67- Style_Checks_Id : constant Rule_Id :=
68- Find (All_Rule_Ids, To_Text (" style_checks" ));
69- Warnings_Id : constant Rule_Id :=
70- Find (All_Rule_Ids, To_Text (" warnings" ));
71- -- Fake identifiers, used to represent the compiler checks
72-
7378end Gnatcheck.Ids ;
0 commit comments