Commit 2c7a9526 authored by yoogx's avatar yoogx
Browse files

* Correct implementation of naming rules for rename declarations

parent 9836f4d9
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
with Ocarina.Analyzer.Messages; with Ocarina.Analyzer.Messages;
with Ocarina.Analyzer.AADL.Finder;
with Ocarina.Analyzer.AADL.Naming_Rules; with Ocarina.Analyzer.AADL.Naming_Rules;
with Ocarina.ME_AADL.AADL_Tree.Nodes; with Ocarina.ME_AADL.AADL_Tree.Nodes;
...@@ -40,6 +41,7 @@ with Ocarina.ME_AADL.AADL_Tree.Entities; ...@@ -40,6 +41,7 @@ with Ocarina.ME_AADL.AADL_Tree.Entities;
package body Ocarina.Analyzer.AADL.Names is package body Ocarina.Analyzer.AADL.Names is
use Ocarina.Analyzer.AADL.Finder;
use Ocarina.Analyzer.Messages; use Ocarina.Analyzer.Messages;
use Ocarina.Analyzer.AADL.Naming_Rules; use Ocarina.Analyzer.AADL.Naming_Rules;
...@@ -89,8 +91,7 @@ package body Ocarina.Analyzer.AADL.Names is ...@@ -89,8 +91,7 @@ package body Ocarina.Analyzer.AADL.Names is
(Name_Visibility_Node : Node_Id; (Name_Visibility_Node : Node_Id;
Package_Node : Node_Id) Package_Node : Node_Id)
return Boolean; return Boolean;
-- Check if package or property in with sublcause -- Check if package or property in with sublcause exists in global scope
-- exists in global scope
------------------------------ ------------------------------
-- Check_Import_Declaration -- -- Check_Import_Declaration --
...@@ -127,12 +128,12 @@ package body Ocarina.Analyzer.AADL.Names is ...@@ -127,12 +128,12 @@ package body Ocarina.Analyzer.AADL.Names is
if Kind (Import_Node) = K_Package_Name then if Kind (Import_Node) = K_Package_Name then
Identifier := Build_Package_Identifier (Import_Node); Identifier := Build_Package_Identifier (Import_Node);
In_Node := Node_Explicitly_In_Scope (Identifier, In_Node :=
Current_Scope); Node_Explicitly_In_Scope (Identifier, Current_Scope);
else
In_Node := Node_Explicitly_In_Scope (Import_Node,
Current_Scope);
else
In_Node :=
Node_Explicitly_In_Scope (Import_Node, Current_Scope);
end if; end if;
if In_Node = No_Node then if In_Node = No_Node then
...@@ -185,10 +186,21 @@ package body Ocarina.Analyzer.AADL.Names is ...@@ -185,10 +186,21 @@ package body Ocarina.Analyzer.AADL.Names is
Loc => Loc (List_Node)); Loc => Loc (List_Node));
else else
In_Node := Node_Explicitly_In_Scope In_Node := Node_In_Scope (Alias, Current_Scope);
(Alias, Current_Scope);
if No (In_Node)
and then Present (Corresponding_Entity (Alias))
then
In_Node := Find_Component_Classifier
(Root => 1,
Package_Identifier => Namespace_Identifier
(Corresponding_Entity (Alias)),
Component_Identifier =>
Ocarina.ME_AADL.AADL_Tree.Nodes.Identifier
(Corresponding_Entity (Alias)));
end if;
if In_Node = No_Node then if No (In_Node) then
Success := False; Success := False;
Display_Analyzer_Error (Alias, "is not visible"); Display_Analyzer_Error (Alias, "is not visible");
end if; end if;
......
...@@ -440,43 +440,55 @@ package body Ocarina.Analyzer.AADL.Naming_Rules is ...@@ -440,43 +440,55 @@ package body Ocarina.Analyzer.AADL.Naming_Rules is
(Declarations (Entity)); (Declarations (Entity));
while Present (List_Node) loop while Present (List_Node) loop
if Kind (List_Node) case Kind (List_Node) is
= K_Name_Visibility_Declaration when K_Component_Type
then | K_Component_Implementation =>
List_Node_2 :=
Ocarina.ME_AADL.AADL_Tree.Nodes.First_Node if Name (Identifier (List_Node))
(List_Items (List_Node)); = Name_Of_Identifier
while Present (List_Node_2) loop then
if Kind (List_Node_2) = K_Alias_Declaration then First_Node := List_Node;
if Is_All (List_Node_2) then end if;
List_Node_3 :=
Ocarina.ME_AADL.AADL_Tree.Nodes. when K_Name_Visibility_Declaration =>
First_Node List_Node_2 :=
(Declarations Ocarina.ME_AADL.AADL_Tree.Nodes.First_Node
(Parent (Parent (List_Node_2)))); (List_Items (List_Node));
while Present (List_Node_3) loop
if Name (Identifier (List_Node_3)) while Present (List_Node_2) loop
= Name (Build_Package_Identifier if Kind (List_Node_2) =
(Package_Name K_Alias_Declaration then
(List_Node_2))) if Is_All (List_Node_2) then
then List_Node_3 :=
Test_Node := Node_In_Scope Ocarina.ME_AADL.AADL_Tree.Nodes.
(Name_Of_Identifier, First_Node
Entity_Scope (Declarations
(List_Node_3)); (Parent (Parent (List_Node_2))));
while Present (List_Node_3) loop
if Present (Test_Node) then if Name (Identifier (List_Node_3))
First_Node := Test_Node; = Name (Build_Package_Identifier
(Package_Name
(List_Node_2)))
then
Test_Node := Node_In_Scope
(Name_Of_Identifier,
Entity_Scope
(List_Node_3));
if Present (Test_Node) then
First_Node := Test_Node;
end if;
end if; end if;
end if; List_Node_3
List_Node_3 := Next_Node (List_Node_3);
:= Next_Node (List_Node_3); end loop;
end loop; end if;
end if; end if;
end if; List_Node_2 := Next_Node (List_Node_2);
List_Node_2 := Next_Node (List_Node_2); end loop;
end loop;
end if; when others => null;
end case;
List_Node := Next_Node (List_Node); List_Node := Next_Node (List_Node);
end loop; end loop;
end; end;
...@@ -826,8 +838,7 @@ package body Ocarina.Analyzer.AADL.Naming_Rules is ...@@ -826,8 +838,7 @@ package body Ocarina.Analyzer.AADL.Naming_Rules is
-- Internal_Node_In_Scope -- -- Internal_Node_In_Scope --
---------------------------- ----------------------------
function Internal_Node_In_Scope (N : Name_Id; S : Node_Id) return Node_Id function Internal_Node_In_Scope (N : Name_Id; S : Node_Id) return Node_Id is
is
I_Name : constant Name_Id := Internal_Scope_Name (N, S); I_Name : constant Name_Id := Internal_Scope_Name (N, S);
begin begin
return Node_Id (Get_Name_Table_Info (I_Name)); return Node_Id (Get_Name_Table_Info (I_Name));
...@@ -857,8 +868,7 @@ package body Ocarina.Analyzer.AADL.Naming_Rules is ...@@ -857,8 +868,7 @@ package body Ocarina.Analyzer.AADL.Naming_Rules is
-- Internal_Scope_Name -- -- Internal_Scope_Name --
------------------------- -------------------------
function Internal_Scope_Name (N : Name_Id; S : Node_Id) return Name_Id function Internal_Scope_Name (N : Name_Id; S : Node_Id) return Name_Id is
is
begin begin
Get_Name_String (N); Get_Name_String (N);
Add_Str_To_Name_Buffer ("%in_scope%"); Add_Str_To_Name_Buffer ("%in_scope%");
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment