ocarina-analyzer-aadl-names.adb 27.1 KB
Newer Older
1
2
3
4
5
6
7
8
------------------------------------------------------------------------------
--                                                                          --
--                           OCARINA COMPONENTS                             --
--                                                                          --
--          O C A R I N A . A N A L Y Z E R . A A D L . N A M E S           --
--                                                                          --
--                                 B o d y                                  --
--                                                                          --
jhugues's avatar
jhugues committed
9
--       Copyright (C) 2009 Telecom ParisTech, 2010-2012 ESA & ISAE.        --
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
--                                                                          --
-- Ocarina  is free software;  you  can  redistribute  it and/or  modify    --
-- it under terms of the GNU General Public License as published by the     --
-- Free Software Foundation; either version 2, or (at your option) any      --
-- later version. Ocarina is distributed  in  the  hope  that it will be    --
-- useful, but WITHOUT 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 Ocarina; see file COPYING.   --
-- If not, write to the Free Software Foundation, 51 Franklin Street, Fifth --
-- Floor, Boston, MA 02111-1301, USA.                                       --
--                                                                          --
-- As a special exception,  if other files  instantiate  generics from this --
-- unit, or you link  this unit with other files  to produce an executable, --
-- this  unit  does not  by itself cause  the resulting  executable to be   --
-- covered  by the  GNU  General  Public  License. This exception does not  --
-- however invalidate  any other reasons why the executable file might be   --
-- covered by the GNU Public License.                                       --
--                                                                          --
jhugues's avatar
jhugues committed
29
30
--                 Ocarina is maintained by the TASTE project               --
--                      (taste-users@lists.tuxfamily.org)                   --
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
--                                                                          --
------------------------------------------------------------------------------

with Ocarina.Analyzer.Messages;
with Ocarina.Analyzer.AADL.Naming_Rules;

with Ocarina.ME_AADL.AADL_Tree.Nodes;
with Ocarina.ME_AADL.AADL_Tree.Nutils;
with Ocarina.ME_AADL.AADL_Tree.Entities;

package body Ocarina.Analyzer.AADL.Names is

   use Ocarina.Analyzer.Messages;
   use Ocarina.Analyzer.AADL.Naming_Rules;

   use Ocarina.Me_AADL.AADL_Tree.Nodes;
   use Ocarina.Me_AADL.AADL_Tree.Nutils;
   use Ocarina.Me_AADL.AADL_Tree.Entities;

   function Check_Names_In_Package (Node : Node_Id) return Boolean;
   function Check_Names_In_Property_Set (Node : Node_Id) return Boolean;

   function Check_Declaration_Names_In_Component_Type
     (Node : Node_Id)
     return Boolean;
   --  Check the declarations inside a component type, including all
   --  its parents (in case of an extension).

   function Check_Declaration_Names_In_Component_Implementation
     (Node : Node_Id)
     return Boolean;
   --  Check the declarations inside a component implementation,
   --  including all its parents (in case of an extension) and
   --  corresponding type.

   function Check_Declaration_Names_In_Feature_Group_Type
     (Node : Node_Id)
     return Boolean;
   --  Check the declarations inside a port group type (AADL_V1) or
   --  inside a feature group type (AADL_V2), including all
   --  its parents (in case of an extension).

   function Check_Names_In_Component_Type (Node : Node_Id) return Boolean;
   --  Same as above but with a component type

   function Check_Names_In_Component_Implementation
     (Node : Node_Id)
     return Boolean;
   --  Same as above but with a component type

   function Check_Names_In_Feature_Group
     (Node : Node_Id)
     return Boolean;
   --  Same as above but with a component type

   function Check_Property_Association_Names (Node : Node_Id) return Boolean;

   function Check_Import_Declaration
     (Name_Visibility_Node : Node_Id;
      Package_Node         : Node_Id)
     return Boolean;
   --  Check if package or property in with sublcause
   --  exists in global scope

   ------------------------------
   -- Check_Import_Declaration --
   ------------------------------

   function Check_Import_Declaration
     (Name_Visibility_Node : Node_Id;
      Package_Node         : Node_Id)
     return Boolean
   is
      pragma Assert
        (Kind (Name_Visibility_Node) = K_Name_Visibility_Declaration);

      Identifier        : Node_Id;
      In_Node           : Node_Id;
      List_Node         : Node_Id;
      Import_Node       : Node_Id;
      Success           : Boolean  := True;
   begin
      Pop_Scope;

      if not Is_Empty (List_Items (Name_Visibility_Node)) then
         List_Node := First_Node (List_Items (Name_Visibility_Node));
      end if;

      while Present (List_Node) loop
         case Kind (List_Node) is
            when K_Import_Declaration =>
               if not Is_Empty (List_Items (List_Node)) then
                  Import_Node := First_Node (List_Items (List_Node));
               end if;

               while Present (Import_Node) loop
                  if Kind (Import_Node) = K_Package_Name then
                     Identifier := Build_Package_Identifier (Import_Node);

                     In_Node := Node_Explicitly_In_Scope (Identifier,
                                                          Current_Scope);
                  else
                     In_Node := Node_Explicitly_In_Scope (Import_Node,
                                                          Current_Scope);

                  end if;

                  if In_Node = No_Node then
                     Success := False;

                     Display_Analyzer_Error
                       (Import_Node,
                        "is not a package or a property set visible"
                          & " or existing");
                  end if;
                  Import_Node := Next_Node (Import_Node);
               end loop;

            when K_Alias_Declaration =>
               declare
                  Alias : Node_Id := No_Node;
               begin
                  if Present (Reference (List_Node)) then
                     --  Alias references an entity type
                     Alias := Full_Identifier (Reference (List_Node));

                  elsif Present (Package_Name (List_Node)) then
                     --  Alias references a package
                     Alias := Build_Package_Identifier
                       (Package_Name (List_Node));
                  end if;
                  pragma Assert (Present (Alias));

jhugues's avatar
jhugues committed
164
165
166
167
168
169
                  if Name (Alias) = Name (Build_Package_Identifier
                                            (Package_Name (Package_Node)))
                  then
                     Display_Analyzer_Error
                       (Alias, "alias definition refer to self package",
                        Loc => Loc (Name_Visibility_Node));
170
                     Success := False;
jhugues's avatar
jhugues committed
171
172
173
174
175
176
177
178
179

                  else
                     In_Node := Node_Explicitly_In_Scope
                       (Alias, Current_Scope);

                     if In_Node = No_Node then
                        Success := False;
                        Display_Analyzer_Error (Alias, "is not visible");
                     end if;
180
181
182
183
184
                  end if;
               end;
            when others =>
               null;
         end case;
jhugues's avatar
jhugues committed
185
         exit when not Success;
186
187
188

         List_Node := Next_Node (List_Node);
      end loop;
jhugues's avatar
jhugues committed
189

190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
      Push_Scope (Entity_Scope (Package_Node));
      return Success;
   end Check_Import_Declaration;

   ---------------------------------------------------------
   -- Check_Declaration_Names_In_Component_Implementation --
   ---------------------------------------------------------

   function Check_Declaration_Names_In_Component_Implementation
     (Node : Node_Id)
     return Boolean
   is
      pragma Assert (Kind (Node) = K_Component_Implementation);

      List_Node      : Node_Id;
      Call_List_Node : Node_Id;
      Success        : Boolean := True;
   begin
      if Parent (Node) /= No_Node
        and then (Get_Referenced_Entity (Parent (Node))) /= No_Node
      then
         --  First check the declarations of the parent component
         Success := Check_Declaration_Names_In_Component_Implementation
           (Get_Referenced_Entity (Parent (Node)));
      else
         --  But before all, we include the features of the component
         --  type into the scope

         Success := Check_Declaration_Names_In_Component_Type
           (Corresponding_Entity (Component_Type_Identifier (Node)));
      end if;

      Push_Scope (Entity_Scope (Node));

      --  Type refinements

      if not Is_Empty (Refines_Type (Node)) then
         List_Node := First_Node (Refines_Type (Node));

         while Present (List_Node) loop
            Success := Enter_Name_In_Scope (Identifier (List_Node))
              and then Check_Property_Association_Names (List_Node)
              and then Success;

            List_Node := Next_Node (List_Node);
         end loop;
      end if;

      --  Subcomponents

      if not Is_Empty (Subcomponents (Node)) then
         List_Node := First_Node (Subcomponents (Node));

         while Present (List_Node) loop
            Success := Enter_Name_In_Scope (Identifier (List_Node))
              and then Check_Property_Association_Names (List_Node)
              and then Success;

            List_Node := Next_Node (List_Node);
         end loop;
      end if;

      --  Call sequences
      --  Some call sequences are anonymous

      if not Is_Empty (Calls (Node)) then
         List_Node := First_Node (Calls (Node));

         while Present (List_Node) loop
            if Identifier (List_Node) /= No_Node then
               Success := Enter_Name_In_Scope (Identifier (List_Node))
                 and then Success;
            end if;

            if not Is_Empty (Subprogram_Calls (List_Node)) then
               Call_List_Node := First_Node (Subprogram_Calls (List_Node));

               --  Subprogram call names are put in the same scope as
               --  all the other names. All the call names must be in
               --  the same scope, since connections directly refer to
               --  call names, without specifying sequence names.

               while Present (Call_List_Node) loop
                  Set_In_Modes (Call_List_Node, In_Modes (List_Node));
                  --  We set implicit in modes statement for the
                  --  subprogram call. It is the one the call
                  --  sequence.

                  Success := Enter_Name_In_Scope (Identifier (Call_List_Node))
                    and then Check_Property_Association_Names (Call_List_Node)
                    and then Success;
                  Call_List_Node := Next_Node (Call_List_Node);
               end loop;
            end if;

            List_Node := Next_Node (List_Node);
         end loop;
      end if;

      --  Connections
      --  Some connections are anonymous

      if not Is_Empty (Connections (Node)) then
         List_Node := First_Node (Connections (Node));

         while Present (List_Node) loop
            if Identifier (List_Node) /= No_Node then
               Success := Enter_Name_In_Scope (Identifier (List_Node))
                 and then Check_Property_Association_Names (List_Node)
                 and then Success;
            else
               Success := Check_Property_Association_Names (List_Node)
                 and then Success;
            end if;

            List_Node := Next_Node (List_Node);
         end loop;
      end if;

      --  Flows

      if not Is_Empty (Flows (Node)) then
         List_Node := First_Node (Flows (Node));

         while Present (List_Node) loop
            Success := Enter_Name_In_Scope (Identifier (List_Node))
              and then Check_Property_Association_Names (List_Node)
              and then Success;
            List_Node := Next_Node (List_Node);
         end loop;
      end if;

      --  Modes

      if not Is_Empty (Modes (Node)) then
         List_Node := First_Node (Modes (Node));

         while Present (List_Node) loop
            if Kind (List_Node) = K_Mode then
               Success := Enter_Name_In_Scope (Identifier (List_Node))
                 and then Check_Property_Association_Names (List_Node)
                 and then Success;
            end if;

            List_Node := Next_Node (List_Node);
         end loop;
      end if;

      Pop_Scope;
      return Success;
   end Check_Declaration_Names_In_Component_Implementation;

   -----------------------------------------------
   -- Check_Declaration_Names_In_Component_Type --
   -----------------------------------------------

   function Check_Declaration_Names_In_Component_Type
     (Node : Node_Id)
     return Boolean
   is
      pragma Assert (Kind (Node) = K_Component_Type);

      List_Node : Node_Id;
      Success   : Boolean := True;
   begin
      --  First check the declarations of the parent component

      if Parent (Node) /= No_Node
        and then (Get_Referenced_Entity (Parent (Node))) /= No_Node
      then
         Success := Check_Declaration_Names_In_Component_Type
           (Get_Referenced_Entity (Parent (Node)));
      end if;

      Push_Scope (Entity_Scope (Node));

366
367
368
369
370
371
372
373
374
375
376
377
378
      --  Prototypes

      if not Is_Empty (Prototypes (Node)) then
         List_Node := First_Node (Prototypes (Node));

         while Present (List_Node) loop
            Success := Enter_Name_In_Scope (Identifier (List_Node))
              --  and then Check_Property_Association_Names (List_Node)
              and then Success;
            List_Node := Next_Node (List_Node);
         end loop;
      end if;

379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
      --  Features

      if not Is_Empty (Features (Node)) then
         List_Node := First_Node (Features (Node));

         while Present (List_Node) loop
            Success := Enter_Name_In_Scope (Identifier (List_Node))
              and then Check_Property_Association_Names (List_Node)
              and then Success;
            List_Node := Next_Node (List_Node);
         end loop;
      end if;

      --  Flows

      if not Is_Empty (Flows (Node)) then
         List_Node := First_Node (Flows (Node));

         while Present (List_Node) loop
            Success := Enter_Name_In_Scope (Identifier (List_Node))
              and then Check_Property_Association_Names (List_Node)
              and then Success;
            List_Node := Next_Node (List_Node);
         end loop;
      end if;

      Pop_Scope;
      return Success;
   end Check_Declaration_Names_In_Component_Type;

   ---------------------------------------------------
   -- Check_Declaration_Names_In_Feature_Group_Type --
   ---------------------------------------------------

   function Check_Declaration_Names_In_Feature_Group_Type
     (Node : Node_Id)
     return Boolean
   is
      pragma Assert (Kind (Node) = K_Feature_Group_Type);

      List_Node : Node_Id;
      Success   : Boolean := True;
   begin
      --  First check the declarations of the parent port group

      if Parent (Node) /= No_Node
        and then Get_Referenced_Entity (Parent (Node)) /= No_Node
      then
         Success :=
           Check_Declaration_Names_In_Feature_Group_Type
           (Get_Referenced_Entity (Parent (Node)));
      end if;

      Push_Scope (Entity_Scope (Node));

      if not Is_Empty (Features (Node)) then
         List_Node := First_Node (Features (Node));

         while Present (List_Node) loop
            if not Is_Implicit_Inverse (List_Node) then
               Success := Enter_Name_In_Scope (Identifier (List_Node))
                 and then Check_Property_Association_Names (List_Node)
                 and then Success;
            end if;

            List_Node := Next_Node (List_Node);
         end loop;
      end if;

      Pop_Scope;
      return Success;
   end Check_Declaration_Names_In_Feature_Group_Type;

   --------------------------------------------------
   -- Check_Names_In_Components_And_Feature_Groups --
   --------------------------------------------------

   function Check_Names_In_Components_And_Feature_Groups
     (Root : Node_Id)
     return Boolean
   is
      pragma Assert (Kind (Root) = K_AADL_Specification);

      List_Node         : Node_Id;
      Package_List_Node : Node_Id;
      Success           : Boolean := True;
   begin
      Push_Scope (Entity_Scope (Root));

      if not Is_Empty (Declarations (Root)) then
         List_Node :=  First_Node (Declarations (Root));

         while Present (List_Node) loop
            case Kind (List_Node) is
               when K_Component_Type =>
                  Success := Check_Names_In_Component_Type (List_Node)
                    and then Success;

               when K_Component_Implementation =>
                  Success := Check_Names_In_Component_Implementation
                    (List_Node)
                    and then Success;

               when K_Feature_Group_Type =>
                  Success := Check_Names_In_Feature_Group
                    (List_Node)
                    and then Success;

               when K_Package_Specification =>
                  Push_Scope (Entity_Scope (List_Node));

                  if not Is_Empty (Declarations (List_Node)) then
                     Package_List_Node :=
                       First_Node (Declarations (List_Node));

                     while Present (Package_List_Node) loop
                        case Kind (Package_List_Node) is
                           when K_Component_Type =>
                              Success := Check_Names_In_Component_Type
                                (Package_List_Node)
                                and then Success;

                           when K_Component_Implementation =>
                              Success :=
                                Check_Names_In_Component_Implementation
                                (Package_List_Node)
                                and then Success;

                           when K_Feature_Group_Type =>
                              Success :=
                                Check_Names_In_Feature_Group
                                (Package_List_Node)
                                and then Success;

                           when others =>
                              null;
                        end case;

                        Package_List_Node := Next_Node (Package_List_Node);
                     end loop;
                  end if;

                  Pop_Scope;

               when others =>
                  null;
            end case;

            List_Node := Next_Node (List_Node);
         end loop;
      end if;

      Pop_Scope;
      return Success;
   end Check_Names_In_Components_And_Feature_Groups;

   ---------------------------------------------
   -- Check_Names_In_Component_Implementation --
   ---------------------------------------------

   function Check_Names_In_Component_Implementation
     (Node : Node_Id)
     return Boolean
   is
      pragma Assert (Kind (Node) = K_Component_Implementation);

      Success : Boolean := True;
   begin
      Success := Check_Declaration_Names_In_Component_Implementation (Node);
      Success := Check_Property_Association_Names (Node)
        and then Success;

      return Success;
   end Check_Names_In_Component_Implementation;

   -----------------------------------
   -- Check_Names_In_Component_Type --
   -----------------------------------

   function Check_Names_In_Component_Type (Node : Node_Id) return Boolean is
      pragma Assert (Kind (Node) = K_Component_Type);

      Success : Boolean := True;
   begin
      Success := Check_Declaration_Names_In_Component_Type (Node);
      Success := Check_Property_Association_Names (Node)
        and then Success;

      return Success;
   end Check_Names_In_Component_Type;

   -------------------------------
   -- Check_Names_In_Namespaces --
   -------------------------------

   function Check_Names_In_Namespaces (Node : Node_Id) return Boolean is
      pragma Assert (Kind (Node) = K_AADL_Specification);

      Success               : Boolean := True;
      List_Node             : Node_Id;
      Node_Entered_In_Scope : Node_Id;
   begin
      if not Is_Empty (Declarations (Node)) then
         Push_Scope (Entity_Scope (Node));

         --  First, we check the names of the AADL specification

         List_Node := First_Node (Declarations (Node));

         while Present (List_Node) loop
            Node_Entered_In_Scope := Enter_Name_In_Scope
              (Identifier (List_Node));

            if Node_Entered_In_Scope = No_Node then
               Success := False;

            elsif Kind (List_Node) = K_Package_Specification
              and then Node_Entered_In_Scope /= List_Node
            then
               --  If the package was already declared elsewhere,
               --  Enter_Name_In_Scope merges the two package and
               --  returns the former Node_Id. Hence we have to remove
               --  the node from the list.

               Remove_Node_From_List (List_Node, Declarations (Node));
            end if;

            List_Node := Next_Node (List_Node);
         end loop;

         --  Then, we check the names inside packages.

         --  Note: we could not do it in the same time as for the
         --  names of the AADL specification. Indeed, packages are
         --  declared in two times, we would check the names inside
         --  the first part of the package, and when we find the
         --  second part of the package we would have to clear the
         --  scopes of the resulting merged package and then check the
         --  names again in the whole package (thus checking some
         --  declarations twice).

         List_Node := First_Node (Declarations (Node));

         while Present (List_Node) loop
            if Kind (List_Node) = K_Package_Specification then
               Success := Check_Names_In_Package (List_Node)
                 and then Success;

            elsif Kind (List_Node) = K_Property_Set then
               Success := Check_Names_In_Property_Set (List_Node)
                 and then Success;
            end if;

            List_Node := Next_Node (List_Node);
         end loop;

         Pop_Scope;
      end if;

      return Success;
   end Check_Names_In_Namespaces;

   ----------------------------
   -- Check_Names_In_Package --
   ----------------------------

   function Check_Names_In_Package (Node : Node_Id) return Boolean is
      pragma Assert (Kind (Node) = K_Package_Specification);

      Success   : Boolean := True;
      List_Node : Node_Id;
   begin
      if not Is_Empty (Declarations (Node)) then
         Push_Scope (Entity_Scope (Node));
         List_Node := First_Node (Declarations (Node));

         while Present (List_Node) loop
            if Kind (List_Node) = K_Name_Visibility_Declaration then
               Success := Check_Import_Declaration (List_Node, Node);
            else
               if not Enter_Name_In_Scope (Identifier (List_Node)) then
                  Success := False;
               end if;
jhugues's avatar
jhugues committed
662

663
            end if;
jhugues's avatar
jhugues committed
664
            exit when not Success;
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782

            List_Node := Next_Node (List_Node);
         end loop;

         Pop_Scope;
      end if;

      if not Is_Empty (Properties (Node)) then
         Push_Scope (Property_Scope (Node));
         List_Node := First_Node (Properties (Node));

         while Present (List_Node) loop
            if not Enter_Name_In_Scope (Identifier (List_Node)) then
               Success := False;
            end if;

            List_Node := Next_Node (List_Node);
         end loop;

         Pop_Scope;
      end if;

      return Success;
   end Check_Names_In_Package;

   ----------------------------------
   -- Check_Names_In_Feature_Group --
   ----------------------------------

   function Check_Names_In_Feature_Group
     (Node : Node_Id)
     return Boolean is

      pragma Assert (Kind (Node) = K_Feature_Group_Type);

      Success : Boolean := True;
   begin
      Success :=
        Check_Declaration_Names_In_Feature_Group_Type (Node);

      Success := Check_Property_Association_Names (Node)
        and then Success;

      return Success;
   end Check_Names_In_Feature_Group;

   ---------------------------------
   -- Check_Names_In_Property_Set --
   ---------------------------------

   function Check_Names_In_Property_Set (Node : Node_Id) return Boolean is

      pragma Assert (Kind (Node) = K_Property_Set);

      Success   : Boolean := True;
      List_Node : Node_Id;
   begin
      if not Is_Empty (Declarations (Node)) then
         Push_Scope (Entity_Scope (Node));
         List_Node := First_Node (Declarations (Node));

         while Present (List_Node) loop
            if not Enter_Name_In_Scope (Identifier (List_Node)) then
               Success := False;
            end if;

            List_Node := Next_Node (List_Node);
         end loop;

         Pop_Scope;
      end if;

      return Success;
   end Check_Names_In_Property_Set;

   --------------------------------------
   -- Check_Property_Association_Names --
   --------------------------------------

   function Check_Property_Association_Names (Node : Node_Id) return Boolean is
      pragma Assert (Kind (Node) = K_Component_Implementation       or else
                     Kind (Node) = K_Component_Type                 or else
                     Kind (Node) = K_Port_Spec                      or else
                     Kind (Node) = K_Feature_Group_Spec             or else
                     Kind (Node) = K_Feature_Group_Type             or else
                     Kind (Node) = K_Subprogram_Spec                or else
                     Kind (Node) = K_Parameter                      or else
                     Kind (Node) = K_Subcomponent                   or else
                     Kind (Node) = K_Subcomponent_Access            or else
                     Kind (Node) = K_Flow_Spec                      or else
                     Kind (Node) = K_Mode                           or else
                     Kind (Node) = K_Flow_Implementation            or else
                     Kind (Node) = K_End_To_End_Flow_Spec           or else
                     Kind (Node) = K_Flow_Implementation_Refinement or else
                     Kind (Node) = K_End_To_End_Flow_Refinement     or else
                     Kind (Node) = K_Subprogram_Call                or else
                     Kind (Node) = K_Connection);

      Success   : Boolean := True;
      List_Node : Node_Id;
   begin
      if not Is_Empty (Properties (Node)) then
         Push_Scope (Property_Scope (Node));
         List_Node := First_Node (Properties (Node));

         while Present (List_Node) loop
            Success := Enter_Name_In_Scope (Identifier (List_Node))
              and then Success;
            List_Node := Next_Node (List_Node);
         end loop;

         Pop_Scope;
      end if;

      return Success;
   end Check_Property_Association_Names;

end Ocarina.Analyzer.AADL.Names;