1---------------------------------------------------------------------
2--  Framework.Plugs - Package body                                  --
3--                                                                  --
4--  This software  is (c) The European Organisation  for the Safety --
5--  of Air  Navigation (EUROCONTROL) and Adalog  2004-2014.         --
6--  The Ada Controller is  free software; you can  redistribute  it --
7--  and/or modify it under  terms of the GNU General Public License --
8--  as published by the Free Software Foundation; either version 2, --
9--  or (at your option) any later version. This unit is distributed --
10--  in the hope  that it will be useful,  but WITHOUT ANY WARRANTY; --
11--  without even the implied warranty of MERCHANTABILITY or FITNESS --
12--  FOR A  PARTICULAR PURPOSE.  See the GNU  General Public License --
13--  for more details.   You should have received a  copy of the GNU --
14--  General Public License distributed  with this program; see file --
15--  COPYING.   If not, write  to the  Free Software  Foundation, 59 --
16--  Temple Place - Suite 330, Boston, MA 02111-1307, USA.           --
17--                                                                  --
18--  As  a special  exception, if  other files  instantiate generics --
19--  from the units  of this program, or if you  link this unit with --
20--  other files  to produce  an executable, this  unit does  not by --
21--  itself cause the resulting executable  to be covered by the GNU --
22--  General  Public  License.   This  exception  does  not  however --
23--  invalidate any  other reasons why the executable  file might be --
24--  covered by the GNU Public License.                              --
25--                                                                  --
26--  This  software is  distributed  in  the hope  that  it will  be --
27--  useful,  but WITHOUT  ANY  WARRANTY; without  even the  implied --
28--  warranty  of  MERCHANTABILITY   or  FITNESS  FOR  A  PARTICULAR --
29--  PURPOSE.                                                        --
30----------------------------------------------------------------------
31
32-- ASIS
33with
34  Asis.Elements;
35
36-- All general rules
37with
38  Rules.Abnormal_Function_Return,
39  Rules.Allocators,
40  Rules.Array_Declarations,
41  Rules.Aspects,
42  Rules.Assignments,
43  Rules.Barrier_Expressions,
44  Rules.Max_Call_Depth,
45  Rules.Case_Statement,
46  Rules.Characters,
47  Rules.Declarations,
48  Rules.Default_Parameter,
49  Rules.Derivations,
50  Rules.Directly_Accessed_Globals,
51  Rules.Duplicate_Initialization_Calls,
52  Rules.Entities,
53  Rules.Entity_Inside_Exception,
54  Rules.Exception_Propagation,
55  Rules.Expressions,
56  Rules.Local_Access,
57  Rules.Generic_Aliasing,
58  Rules.Global_References,
59  Rules.Header_Comments,
60  Rules.Improper_Initialization,
61  Rules.Instantiations,
62  Rules.Insufficient_Parameters,
63  Rules.Local_Hiding,
64  Rules.Max_Blank_Lines,
65  Rules.Dependencies,
66  Rules.Max_Line_Length,
67  Rules.Max_Nesting,
68  Rules.Max_Size,
69  Rules.Max_Statement_Nesting,
70  Rules.Movable_Accept_Statements,
71  Rules.Naming_Convention,
72  Rules.No_Operator_Usage,
73  Rules.Non_Static,
74  Rules.Not_Elaboration_Calls,
75  Rules.Not_Selected_Name,
76  Rules.Object_Declarations,
77  Rules.Unit_Pattern,
78  Rules.Parameter_Aliasing,
79  Rules.Parameter_Declarations,
80  Rules.Positional_Associations,
81  Rules.Potentially_Blocking_Operations,
82  Rules.Pragmas,
83  Rules.Record_Declarations,
84  Rules.Reduceable_Scope,
85  Rules.Representation_Clauses,
86  Rules.Return_Type,
87  Rules.Side_Effect_Parameters,
88  Rules.Silent_Exceptions,
89  Rules.Simplifiable_Expressions,
90  Rules.Simplifiable_Statements,
91  Rules.Comments,
92  Rules.Statements,
93  Rules.Style,
94  Rules.Terminating_Tasks,
95  Rules.Type_Initial_Values,
96  Rules.Type_Usage,
97  Rules.Units,
98  Rules.Unnecessary_Use_Clause,
99  Rules.Unsafe_Elaboration,
100  Rules.Unsafe_Paired_Calls,
101  Rules.Unsafe_Unchecked_Conversion,
102  Rules.Usage,
103  Rules.Use_Clauses,
104  Rules.With_Clauses;
105package body Framework.Plugs is
106
107   ----------------
108   -- Enter_Unit --
109   ----------------
110
111   -- This procedure is called before any processing of a library unit.
112   -- Plug calls here for rules that need initialization for every unit.
113
114   procedure Enter_Unit (Unit : in Asis.Compilation_Unit) is
115   begin
116      Rules.Max_Blank_Lines.    Enter_Unit               (Unit);
117      Rules.Dependencies.       Enter_Unit               (Unit);
118      Rules.Declarations.       Process_Unit             (Unit);
119      Rules.Statements.         Enter_Unit               (Unit);
120      Rules.Unit_Pattern.       Process_Compilation_Unit (Unit);
121      Rules.Units.              Process_Unit             (Unit);
122      Rules.Unsafe_Elaboration. Process_Unit             (Unit);
123   end Enter_Unit;
124
125
126   --------------------------
127   -- Exit_Context_Clauses --
128   --------------------------
129
130   -- This procedure is called after all context clauses have been traversed,
131   -- before traversing the unit itself
132
133   procedure Exit_Context_Clauses (Unit : in Asis.Compilation_Unit) is
134   begin
135      Rules.Dependencies.Exit_Context_Clauses (Unit);
136   end Exit_Context_Clauses;
137
138   ---------------
139   -- Exit_Unit --
140   ---------------
141
142   -- This procedure is called after all processing of a library unit.
143   -- Plug calls here for rules that need finalization for every unit.
144
145   procedure Exit_Unit (Unit : in Asis.Compilation_Unit) is
146   begin
147      Rules.Max_Size.     Process_Unit      (Unit);
148      Rules.With_Clauses. Process_Unit_Exit (Unit);
149   end Exit_Unit;
150
151   -----------------
152   -- Enter_Scope --
153   -----------------
154
155   -- This procedure is called whenever we enter (Pre_Procedure) into a
156   -- construct where elements can be declared. Since this happen in various
157   -- places in the tree and is likely to be quite common use, it is easier to
158   -- plug calls here rather than in every place that might require it.
159
160   procedure Enter_Scope (Element : in Asis.Element) is
161   begin
162      Rules.Max_Nesting.Process_Scope_Enter (Element);
163      Rules.Statements. Process_Scope_Enter (Element);
164   end Enter_Scope;
165
166   ----------------
167   -- Exit_Scope --
168   ----------------
169
170   -- This procedure is called whenever we exit (Post_Procedure) from a
171   -- construct where elements can be declared. Since this happen in various
172   -- places in the tree and is likely to be quite common use, it is easier to
173   -- plug calls here rather than in every place that might require it.
174
175   procedure Exit_Scope (Element : in Asis.Element) is
176   begin
177      Rules.Max_Nesting.            Process_Scope_Exit (Element);
178      Rules.No_Operator_Usage.      Process_Scope_Exit;
179      Rules.Object_Declarations.    Process_Scope_Exit;
180      Rules.Reduceable_Scope.       Process_Scope_Exit (Element);
181      Rules.Statements.             Process_Scope_Exit (Element);
182      Rules.Type_Initial_Values.    Process_Scope_Exit (Element);
183      Rules.Unnecessary_Use_Clause. Process_Scope_Exit (Element);
184   end Exit_Scope;
185
186   --------------------------
187   -- Enter_Statement_List --
188   --------------------------
189
190   -- Plug calls here to rules that need to process a Sequence_of_statements.
191   -- Element is one of the elements to which Thick_Queries.Statements applies
192   -- (i.e. a statement container)
193   procedure Enter_Statement_List (Element : in Asis.Element) is
194   begin
195      Rules.Assignments. Process_Statement_Container (Element);
196   end Enter_Statement_List;
197
198   ---------------------
199   -- True_Identifier --
200   ---------------------
201
202   --  Plug calls here to rules that need to process all occurrences
203   --  of "true" identifiers, including operator symbols and
204   --  enumeration literals, but excluding identifiers that are pragma
205   --  names or attributes selectors
206
207   procedure True_Identifier (Element : in Asis.Expression) is
208   begin
209      Rules.Directly_Accessed_Globals. Process_Identifier (Element);
210      Rules.Entities.                  Process_Identifier (Element);
211      Rules.Not_Selected_Name.         Process_Identifier (Element);
212      Rules.Reduceable_Scope.          Process_Identifier (Element);
213      Rules.Unnecessary_Use_Clause.    Process_Identifier (Element);
214      Rules.Style.                     Process_Identifier (Element);
215      Rules.Usage.                     Process_Identifier (Element);
216      Rules.With_Clauses.              Process_Identifier (Element);
217   end True_Identifier;
218
219   -------------------
220   -- Pre_Procedure --
221   -------------------
222
223   procedure Pre_Procedure (Element : in Asis.Element) is
224      use Asis, Asis.Elements;
225   begin
226      case Element_Kind (Element) is
227         when A_Clause =>
228            Rules.Style. Process_Element (Element);
229
230            case Clause_Kind (Element) is
231               when A_Use_Package_Clause =>
232                  Rules.Reduceable_Scope. Process_Use_Clause (Element);
233                  Rules.Use_Clauses.      Process_Use_Clause (Element, Is_Type => False);
234               when A_Use_Type_Clause =>
235                  Rules.Use_Clauses. Process_Use_Clause (Element, Is_Type => True);
236               when A_Representation_Clause =>
237                  Rules.Object_Declarations.    Process_Representation_Clause (Element);
238                  Rules.Representation_Clauses. Process_Clause                (Element);
239               when A_With_Clause =>
240                  Rules.Dependencies.       Process_With_Clause (Element);
241                  Rules.Local_Hiding.       Process_With_Clause (Element);
242                  Rules.Units.              Process_With_Clause (Element);
243                  Rules.With_Clauses.       Process_With_Clause (Element);
244               when others =>
245                  null;
246            end case;
247
248         when A_Defining_Name =>
249            case Defining_Name_Kind (Element) is
250               when A_Defining_Identifier =>
251                  Rules.Local_Hiding.      Process_Defining_Name (Element);
252                  Rules.Naming_Convention. Process_Defining_Name (Element);
253                  Rules.Reduceable_Scope.  Process_Defining_Name (Element);
254                  Rules.Style.             Process_Identifier    (Element);
255
256               when A_Defining_Enumeration_Literal =>
257                  Rules.Local_Hiding.      Process_Defining_Name (Element);
258                  Rules.Naming_Convention. Process_Defining_Name (Element);
259                  Rules.Style.             Process_Identifier    (Element);
260
261               when A_Defining_Operator_Symbol =>
262                  Rules.Local_Hiding.      Process_Defining_Name (Element);
263                  Rules.Reduceable_Scope.  Process_Defining_Name (Element);
264                  Rules.Style.             Process_Identifier    (Element);
265
266               when others =>
267                  null;
268            end case;
269
270         when A_Declaration =>
271            Rules.Aspects.               Process_Declaration (Element);
272            Rules.Declarations.          Process_Declaration (Element);
273            Rules.Exception_Propagation. Process_Declaration (Element);
274            Rules.Style.                 Process_Element     (Element);
275
276            case Declaration_Kind (Element) is
277               when An_Ordinary_Type_Declaration =>
278                  Rules.Unit_Pattern.        Process_Type_Declaration (Element);
279                  Rules.Type_Initial_Values. Process_Type_Declaration (Element);
280                  Rules.Usage.               Process_Declaration      (Element);
281
282               when A_Private_Type_Declaration
283                  | A_Private_Extension_Declaration
284                    =>
285                  Rules.Type_Initial_Values. Process_Type_Declaration (Element);
286
287               when A_Subtype_Declaration =>
288                  Rules.Usage. Process_Declaration (Element);
289
290               when A_Variable_Declaration =>
291                  Rules.Array_Declarations.        Process_Object_Declaration   (Element);
292                  Rules.Directly_Accessed_Globals. Process_Variable_Declaration (Element);
293                  Rules.Non_Static.                Process_Object_Declaration   (Element);
294                  Rules.Object_Declarations.       Process_Declaration          (Element);
295                  Rules.Usage.                     Process_Declaration          (Element);
296
297               when A_Constant_Declaration =>
298                  Rules.Array_Declarations.  Process_Object_Declaration   (Element);
299                  Rules.Type_Initial_Values. Process_Constant_Declaration (Element);
300                  Rules.Non_Static.          Process_Object_Declaration   (Element);
301                  Rules.Object_Declarations. Process_Declaration          (Element);
302                  Rules.Usage.               Process_Declaration          (Element);
303
304               when A_Deferred_Constant_Declaration
305                 | A_Number_Declaration
306                 =>
307                  Rules.Usage. Process_Declaration (Element);
308
309               when A_Function_Body_Declaration =>
310                  Rules.Abnormal_Function_Return. Process_Function_Body        (Element);
311                  Rules.Comments.                 Process_Program_Unit         (Element);
312                  Rules.Exception_Propagation.    Process_SP_Declaration       (Element);
313                  Rules.Global_References.        Process_Body                 (Element);
314                  Rules.Improper_Initialization.  Process_Structure            (Element);
315                  Rules.Max_Size.                 Process_Element              (Element);
316                  Rules.Parameter_Declarations.   Process_Declaration          (Element);
317                  Rules.Return_Type.              Process_Function_Declaration (Element);
318                  Rules.Statements.               Process_Function_Body        (Element);
319                  Rules.Style.                    Process_Construct            (Element);
320                  Rules.Style.                    Process_Declaration          (Element);
321                  Rules.Unit_Pattern.             Process_Program_Unit         (Element);
322                  Rules.Usage.                    Process_Declaration          (Element);
323
324               when A_Procedure_Body_Declaration =>
325                  Rules.Comments.                Process_Program_Unit   (Element);
326                  Rules.Exception_Propagation.   Process_SP_Declaration (Element);
327                  Rules.Global_References.       Process_Body           (Element);
328                  Rules.Improper_Initialization. Process_Structure      (Element);
329                  Rules.Max_Size.                Process_Element        (Element);
330                  Rules.Parameter_Declarations.  Process_Declaration    (Element);
331                  Rules.Style.                   Process_Construct      (Element);
332                  Rules.Style.                   Process_Declaration    (Element);
333                  Rules.Unit_Pattern.            Process_Program_Unit   (Element);
334                  Rules.Usage.                   Process_Declaration    (Element);
335
336               when An_Entry_Body_Declaration =>
337                  Rules.Barrier_Expressions.     Process_Entry_Declaration (Element);
338                  Rules.Comments.                Process_Program_Unit      (Element);
339                  Rules.Global_References.       Process_Body              (Element);
340                  Rules.Improper_Initialization. Process_Structure         (Element);
341                  Rules.Max_Size.                Process_Element           (Element);
342                  Rules.Style.                   Process_Construct         (Element);
343                  Rules.Style.                   Process_Declaration       (Element);
344                  Rules.Unit_Pattern.            Process_Program_Unit      (Element);
345
346               when A_Package_Declaration =>
347                  Rules.Max_Size.     Process_Element      (Element);
348                  Rules.Style.        Process_Construct    (Element);
349                  Rules.Unit_Pattern. Process_Program_Unit (Element);
350                  Rules.Usage.        Process_Declaration  (Element);
351
352               when A_Task_Type_Declaration
353                 | A_Protected_Type_Declaration
354                  =>
355                  Rules.Derivations. Process_Synchronized (Element);
356                  Rules.Max_Size.    Process_Element      (Element);
357                  Rules.Style.       Process_Construct    (Element);
358                  Rules.Usage.       Process_Declaration  (Element);
359
360               when A_Package_Body_Declaration =>
361                  Rules.Comments.                Process_Program_Unit (Element);
362                  Rules.Improper_Initialization. Process_Structure    (Element);
363                  Rules.Max_Size.                Process_Element      (Element);
364                  Rules.Unit_Pattern.            Process_Program_Unit (Element);
365                  Rules.Style.                   Process_Construct    (Element);
366
367               when A_Generic_Package_Declaration =>
368                  Rules.Max_Size.     Process_Element      (Element);
369                  Rules.Style.        Process_Construct    (Element);
370                  Rules.Style.        Process_Declaration  (Element);
371                  Rules.Unit_Pattern. Process_Program_Unit (Element);
372                  Rules.Usage.        Process_Declaration  (Element);
373
374               when A_Protected_Body_Declaration =>
375                  Rules.Max_Size.                       Process_Element        (Element);
376                 Rules.Style.                           Process_Construct      (Element);
377                 Rules.Potentially_Blocking_Operations. Process_Protected_Body (Element);
378
379               when A_Single_Task_Declaration
380                 | A_Single_Protected_Declaration
381                 =>
382                  Rules.Derivations. Process_Synchronized (Element);
383                  Rules.Max_Size.    Process_Element      (Element);
384                  Rules.Style.       Process_Construct    (Element);
385                  Rules.Usage.       Process_Declaration  (Element);
386
387               when A_Task_Body_Declaration
388                 =>
389                  Rules.Comments.                Process_Program_Unit (Element);
390                  Rules.Exception_Propagation.   Process_Task_Body    (Element);
391                  Rules.Global_References.       Process_Body         (Element);
392                  Rules.Improper_Initialization. Process_Structure    (Element);
393                  Rules.Max_Size.                Process_Element      (Element);
394                  Rules.Style.                   Process_Construct    (Element);
395                  Rules.Terminating_Tasks.       Process_Task_Body    (Element);
396
397               when An_Exception_Declaration =>
398                  Rules.Usage. Process_Declaration (Element);
399
400               when A_Package_Instantiation =>
401                  Rules.Default_Parameter.      Process_Call_Or_Instantiation (Element);
402                  Rules.Exception_Propagation.  Process_Instantiation         (Element);
403                  Rules.Generic_Aliasing.       Process_Instantiation         (Element);
404                  Rules.Instantiations.         Process_Instantiation         (Element);
405                  Rules.Non_Static.             Process_Instantiation         (Element);
406                  Rules.Reduceable_Scope.       Process_Instantiation         (Element);
407                  Rules.Return_Type.            Process_Instantiation         (Element);
408                  Rules.Side_Effect_Parameters. Process_Call_Or_Instantiation (Element);
409                  Rules.Unnecessary_Use_Clause. Process_Instantiation         (Element);
410                  Rules.Usage.                  Process_Instantiation         (Element);
411                  Rules.With_Clauses.           Process_Instantiation         (Element);
412
413               when A_Formal_Package_Declaration =>
414                  Rules.Default_Parameter.      Process_Call_Or_Instantiation (Element);
415                  Rules.Side_Effect_Parameters. Process_Call_Or_Instantiation (Element);
416                  Rules.Unnecessary_Use_Clause. Process_Instantiation         (Element);
417
418               when A_Procedure_Instantiation =>
419                  Rules.Default_Parameter.      Process_Call_Or_Instantiation (Element);
420                  Rules.Exception_Propagation.  Process_Instantiation         (Element);
421                  Rules.Generic_Aliasing.       Process_Instantiation         (Element);
422                  Rules.Instantiations.         Process_Instantiation         (Element);
423                  Rules.Parameter_Declarations. Process_Declaration           (Element);
424                  Rules.Non_Static.             Process_Instantiation         (Element);
425                  Rules.Reduceable_Scope.       Process_Instantiation         (Element);
426                  Rules.Return_Type.            Process_Instantiation         (Element);
427                  Rules.Side_Effect_Parameters. Process_Call_Or_Instantiation (Element);
428                  Rules.Unnecessary_Use_Clause. Process_Instantiation         (Element);
429                  Rules.Usage.                  Process_Instantiation         (Element);
430                  Rules.With_Clauses.           Process_Instantiation         (Element);
431
432               when A_Function_Instantiation =>
433                  Rules.Default_Parameter.           Process_Call_Or_Instantiation (Element);
434                  Rules.Exception_Propagation.       Process_Instantiation         (Element);
435                  Rules.Generic_Aliasing.            Process_Instantiation         (Element);
436                  Rules.Instantiations.              Process_Instantiation         (Element);
437                  Rules.Parameter_Declarations.      Process_Declaration           (Element);
438                  Rules.Non_Static.                  Process_Instantiation         (Element);
439                  Rules.Reduceable_Scope.            Process_Instantiation         (Element);
440                  Rules.Return_Type.                 Process_Instantiation         (Element);
441                  Rules.Side_Effect_Parameters.      Process_Call_Or_Instantiation (Element);
442                  Rules.Unnecessary_Use_Clause.      Process_Instantiation         (Element);
443                  Rules.Unsafe_Unchecked_Conversion. Process_Instantiation         (Element);
444                  Rules.Usage.                       Process_Instantiation         (Element);
445                  Rules.With_Clauses.                Process_Instantiation         (Element);
446
447               when A_Procedure_Declaration
448                  | A_Procedure_Body_Stub
449                    =>
450                  Rules.Parameter_Declarations. Process_Declaration (Element);
451                  Rules.Style.                  Process_Declaration (Element);
452                  Rules.Usage.                  Process_Declaration (Element);
453
454               when A_Function_Declaration
455                  | An_Expression_Function_Declaration   -- Ada 2012
456                  | A_Function_Body_Stub
457                    =>
458                  Rules.Parameter_Declarations. Process_Declaration          (Element);
459                  Rules.Return_Type.            Process_Function_Declaration (Element);
460                  Rules.Style.                  Process_Declaration          (Element);
461                  Rules.Usage.                  Process_Declaration          (Element);
462
463               when An_Entry_Declaration =>
464                  Rules.Parameter_Declarations. Process_Declaration (Element);
465                  Rules.Style.                  Process_Declaration (Element);
466
467               when A_Generic_Procedure_Declaration =>
468                  Rules.Parameter_Declarations. Process_Declaration (Element);
469                  Rules.Style.                  Process_Declaration (Element);
470                  Rules.Usage.                  Process_Declaration (Element);
471
472               when A_Generic_Function_Declaration =>
473                  Rules.Parameter_Declarations. Process_Declaration          (Element);
474                  Rules.Return_Type.            Process_Function_Declaration (Element);
475                  Rules.Style.                  Process_Declaration          (Element);
476                  Rules.Usage.                  Process_Declaration          (Element);
477
478               when A_Procedure_Renaming_Declaration =>
479                  Rules.Style. Process_Declaration (Element);
480
481               when A_Function_Renaming_Declaration =>
482                  Rules.Return_Type. Process_Function_Declaration (Element);
483                  Rules.Style.       Process_Declaration          (Element);
484
485               when A_Formal_Procedure_Declaration   =>
486                  Rules.Style. Process_Declaration (Element);
487
488               when A_Formal_Function_Declaration =>
489                  Rules.Return_Type. Process_Function_Declaration (Element);
490                  Rules.Style.       Process_Declaration          (Element);
491
492               when others =>
493                 null;
494            end case;
495
496         when A_Definition =>
497            case Definition_Kind (Element) is
498               when A_Type_Definition =>
499                  case Type_Kind (Element) is
500                     when A_Signed_Integer_Type_Definition
501                        | A_Modular_Type_Definition
502                        =>
503                        Rules.No_Operator_Usage. Process_Type_Definition (Element);
504                     when A_Derived_Type_Definition =>
505                        Rules.No_Operator_Usage. Process_Type_Definition (Element);
506                        Rules.Derivations.       Process_Derivation (Element);
507                     when A_Derived_Record_Extension_Definition
508                        | An_Interface_Type_Definition
509                        =>
510                        Rules.Derivations. Process_Derivation (Element);
511                     when A_Constrained_Array_Definition =>
512                        Rules.Array_Declarations. Process_Array_Definition             (Element);
513                        Rules.No_Operator_Usage.  Process_Array_Definition             (Element);
514                        Rules.Non_Static.         Process_Constrained_Array_Definition (Element);
515                        Rules.Type_Usage.         Process_Array_Definition             (Element);
516                     when An_Unconstrained_Array_Definition =>
517                        Rules.Array_Declarations. Process_Array_Definition (Element);
518                        Rules.No_Operator_Usage.  Process_Array_Definition (Element);
519                        Rules.Type_Usage.         Process_Array_Definition (Element);
520                     when others =>
521                        null;
522                  end case;
523
524               when A_Formal_Type_Definition =>
525                  case Formal_Type_Kind (Element) is
526                     when A_Formal_Derived_Type_Definition
527                        | A_Formal_Interface_Type_Definition
528                        =>
529                        Rules.Derivations. Process_Derivation (Element);
530                     when others =>
531                        null;
532                  end case;
533
534               when A_Subtype_Indication =>
535                  Rules.Declarations. Process_Definition (Element);
536
537               when A_Constraint =>
538                  case Constraint_Kind (Element) is
539                     when A_Discriminant_Constraint =>
540                        Rules.Non_Static. Process_Discriminant_Constraint (Element);
541                     when An_Index_Constraint =>
542                        Rules.Array_Declarations. Process_Index_Constraint (Element);
543                        Rules.Non_Static.         Process_Index_Constraint (Element);
544                     when others =>
545                        null;
546                  end case;
547
548               when An_Others_Choice =>
549                  Rules.Statements.Process_Others (Element);
550
551               when A_Discrete_Range
552                 | A_Discrete_Subtype_Definition
553                 =>
554                  Rules.Declarations.            Process_Definition (Element);
555                  Rules.Expressions.             Process_Range      (Element);
556                  Rules.Simplifiable_Expressions.Process_Range      (Element);
557
558               when A_Record_Definition =>
559                  Rules.Record_Declarations.Process_Record_Definition (Element);
560
561               when A_Variant_Part =>
562                  Rules.Declarations.Process_Definition (Element);
563
564               when An_Access_Definition =>
565                  Rules.Declarations.Process_Access_Definition (Element);
566
567               when others =>
568                  null;
569            end case;
570
571         when An_Exception_Handler =>
572            Rules.Entity_Inside_Exception. Process_Exception_Handler   (Element);
573            Rules.Silent_Exceptions.       Process_Exception_Handler   (Element);
574            Rules.Simplifiable_Statements. Process_Exception_Handler   (Element);
575
576         when A_Statement =>
577            Rules.Style.                   Process_Element   (Element);
578            Rules.Max_Size.                Process_Element   (Element);
579            Rules.Max_Statement_Nesting.   Process_Statement (Element);
580            Rules.Simplifiable_Statements. Process_Statement (Element);
581            Rules.Statements.              Process_Statement (Element);
582
583            case Statement_Kind (Element) is
584               when An_Assignment_Statement =>
585                  Rules.Assignments.Process_Assignment (Element);
586
587               when A_Procedure_Call_Statement =>
588                  Rules.Max_Call_Depth.                 Process_Call                  (Element);
589                  Rules.Default_Parameter.              Process_Call_Or_Instantiation (Element);
590                  Rules.Duplicate_Initialization_Calls. Process_Procedure_Call        (Element);
591                  Rules.Expressions.                    Process_Call                  (Element);
592                  Rules.Exception_Propagation.          Process_Call                  (Element);
593                  Rules.Insufficient_Parameters.        Process_Call                  (Element);
594                  Rules.Not_Elaboration_Calls.          Process_Call                  (Element);
595                  Rules.Parameter_Aliasing.             Process_Call                  (Element);
596                  Rules.Side_Effect_Parameters.         Process_Call_Or_Instantiation (Element);
597                  Rules.Unsafe_Paired_Calls.            Process_Call                  (Element);
598
599               when An_Entry_Call_Statement =>
600                  Rules.Max_Call_Depth.          Process_Call                  (Element);
601                  Rules.Default_Parameter.       Process_Call_Or_Instantiation (Element);
602                  Rules.Exception_Propagation.   Process_Call                  (Element);
603                  Rules.Expressions.             Process_Call                  (Element);
604                  Rules.Insufficient_Parameters. Process_Call                  (Element);
605                  Rules.Not_Elaboration_Calls.   Process_Call                  (Element);
606                  Rules.Parameter_Aliasing.      Process_Call                  (Element);
607                  Rules.Side_Effect_Parameters.  Process_Call_Or_Instantiation (Element);
608                  Rules.Unsafe_Paired_Calls.     Process_Call                  (Element);
609
610               when An_If_Statement =>
611                  Rules.Style.                   Process_If_Statement       (Element);
612                  Rules.Style.                   Process_Compound_Statement (Element);
613
614               when A_Case_Statement =>
615                  Rules.Case_Statement. Process_Case_Statement     (Element);
616                  Rules.Style.          Process_Compound_Statement (Element);
617
618               when An_Accept_Statement =>
619                  Rules.Declarations.              Process_Statement           (Element);
620                  Rules.Improper_Initialization.   Process_Structure           (Element);
621                  Rules.Movable_Accept_Statements. Process_Accept_Statement    (Element);
622                  Rules.Style.                     Process_Compound_Statement  (Element);
623
624               when A_Block_Statement =>
625                  Rules.Declarations.            Process_Statement           (Element);
626                  Rules.Improper_Initialization. Process_Structure           (Element);
627                  Rules.Style.                   Process_Compound_Statement  (Element);
628
629               when A_Loop_Statement
630                 | A_For_Loop_Statement
631                 =>
632                  Rules.Statements.            Pre_Process_Loop            (Element);
633                  Rules.Style.                 Process_Compound_Statement  (Element);
634
635               when A_While_Loop_Statement =>
636                  Rules.Statements.           Pre_Process_Loop            (Element);
637                  Rules.Style.                Process_Compound_Statement  (Element);
638
639               when An_Extended_Return_Statement =>
640                  Rules.Declarations.            Process_Statement (Element);
641                  Rules.Improper_Initialization. Process_Structure (Element);
642
643               when A_Selective_Accept_Statement
644                 | A_Timed_Entry_Call_Statement
645                 | A_Conditional_Entry_Call_Statement
646                 | An_Asynchronous_Select_Statement
647                 =>
648                  Rules.Style. Process_Compound_Statement (Element);
649
650               when others =>
651                  null;
652            end case;
653
654         when A_Path =>
655            case Path_Kind (Element) is
656               when A_Case_Path =>
657                  Rules.Case_Statement. Process_Path (Element);
658               when others =>
659                  null;
660            end case;
661
662
663         when An_Expression =>
664            Rules.Expressions. Process_Expression (Element);
665
666            case Expression_Kind (Element) is
667               when An_Attribute_Reference =>
668                  Rules.Entities.     Process_Attribute (Element);
669                  Rules.Local_Access. Process_Attribute (Element);
670                  Rules.Style.        Process_Attribute (Element);
671                  Rules.Type_Usage.   Process_Attribute (Element);
672
673               when An_Operator_Symbol =>
674                  Rules.No_Operator_Usage. Process_Operator (Element);
675
676               when An_In_Membership_Test
677                  | A_Not_In_Membership_Test
678                  =>
679                  Rules.No_Operator_Usage. Process_Membership (Element);
680
681               when An_Allocation_From_Subtype
682                 | An_Allocation_From_Qualified_Expression
683                 =>
684                  Rules.Allocators.Process_Allocator            (Element);
685                  Rules.Not_Elaboration_Calls.Process_Allocator (Element);
686
687                when A_Function_Call =>
688                  Rules.Default_Parameter.        Process_Call_Or_Instantiation (Element);
689                  Rules.Exception_Propagation.    Process_Call                  (Element);
690                  Rules.Expressions.              Process_Call                  (Element);
691                  Rules.Insufficient_Parameters.  Process_Call                  (Element);
692                  Rules.Max_Call_Depth.           Process_Call                  (Element);
693                  Rules.Not_Elaboration_Calls.    Process_Call                  (Element);
694                  Rules.Side_Effect_Parameters.   Process_Call_Or_Instantiation (Element);
695                  Rules.Simplifiable_Expressions. Process_Call                  (Element);
696
697               when A_Parenthesized_Expression =>
698                  Rules.Simplifiable_Expressions. Process_Parenthesized (Element);
699
700               when An_Integer_Literal
701                  | A_Real_Literal
702                  | A_Character_Literal
703                  | A_String_Literal
704                 =>
705                  Rules.Style. Process_Literal (Element);
706
707               when A_Type_Conversion =>
708                  Rules.Simplifiable_Expressions. Process_Conversion (Element);
709
710               when An_Indexed_Component =>
711                  Rules.Non_Static. Process_Index_Expression (Element);
712
713               when others =>
714                  null;
715            end case;
716
717         when An_Association =>
718            Rules.Positional_Associations. Process_Association (Element);
719
720         when A_Pragma =>
721            Rules.Object_Declarations. Process_Pragma (Element);
722            Rules.Pragmas.             Process_Pragma (Element);
723            Rules.Style.               Process_Pragma (Element);
724
725         when others =>
726            null;
727      end case;
728   end Pre_Procedure;
729
730   --------------------
731   -- Post_Procedure --
732   --------------------
733
734   procedure Post_Procedure (Element : in Asis.Element) is
735      use Asis, Asis.Elements;
736   begin
737      case Element_Kind (Element) is
738         when A_Clause =>
739            case Clause_Kind (Element) is
740               when A_Use_Package_Clause =>
741                  Rules.Unnecessary_Use_Clause. Process_Use_Clause (Element);
742               when others =>
743                  null;
744            end case;
745
746         when A_Declaration =>
747            case Declaration_Kind (Element) is
748               when A_Package_Body_Declaration =>
749                  Rules.Directly_Accessed_Globals. Post_Process_Package_Body (Element);
750               when A_Renaming_Declaration =>
751                  Rules.Style. Process_Renaming (Element);
752               when others =>
753                  null;
754            end case;
755
756         when A_Statement =>
757            case Statement_Kind (Element) is
758               when A_Loop_Statement
759                 | A_While_Loop_Statement
760                 | A_For_Loop_Statement
761                 =>
762                  Rules.Statements. Post_Process_Loop (Element);
763               when others =>
764                  null;
765            end case;
766
767        when others =>
768            null;
769      end case;
770   end Post_Procedure;
771
772   ---------------------
773   -- Text_Enter_Unit --
774   ---------------------
775
776   procedure Text_Enter_Unit (Unit : in Asis.Compilation_Unit) is
777      pragma Unreferenced (Unit);
778   begin
779      Rules.Header_Comments. Enter_Unit;
780   end Text_Enter_Unit;
781
782   -------------------
783   -- Text_Analysis --
784   -------------------
785
786   procedure Text_Analysis (Line : Asis.Program_Text; Loc : Location) is
787   begin
788      Rules.Characters.       Process_Line (Line, Loc);
789      Rules.Header_Comments.  Process_Line (Line, Loc);
790      Rules.Max_Blank_Lines.  Process_Line (Line, Loc);
791      Rules.Max_Line_Length.  Process_Line (Line, Loc);
792      Rules.Comments.         Process_Line (Line, Loc);
793      Rules.Style.            Process_Line (Line, Loc);
794   end Text_Analysis;
795
796end Framework.Plugs;
797