Commit 4cfb1c4b authored by yoogx's avatar yoogx

* Display available root systems in error message

        For issue #40
parent f8721404
...@@ -155,6 +155,23 @@ package body Ocarina.Instances is ...@@ -155,6 +155,23 @@ package body Ocarina.Instances is
Root_System : Node_Id := No_Node; Root_System : Node_Id := No_Node;
List_Node : Node_Id; List_Node : Node_Id;
procedure Report_Root_Systems_To_User;
procedure Report_Root_Systems_To_User is
begin
Error_Loc (1) := No_Location;
DE ("Please select a root system among ");
List_Node := Root_Systems.First;
while Present (List_Node) loop
Error_Loc (1) := ATN.Loc (List_Node);
Error_Name (1) := ATE.Get_Name_Of_Entity
(List_Node, False, True);
DE ("%");
List_Node := ATN.Next_Entity (List_Node);
end loop;
Exit_On_Error (True, "Cannot instantiate AADL model");
end Report_Root_Systems_To_User;
begin begin
Errors.Initialize; Errors.Initialize;
N_Errors := 0; N_Errors := 0;
...@@ -166,7 +183,6 @@ package body Ocarina.Instances is ...@@ -166,7 +183,6 @@ package body Ocarina.Instances is
Root_Systems := Find_All_Root_Systems (Root); Root_Systems := Find_All_Root_Systems (Root);
if Root_Systems.First /= Root_Systems.Last then if Root_Systems.First /= Root_Systems.Last then
-- If the user provided a particular root system to -- If the user provided a particular root system to
-- instantiate, find this system in the root system -- instantiate, find this system in the root system
-- list. Otherwise, display an error message indicating that -- list. Otherwise, display an error message indicating that
...@@ -186,27 +202,24 @@ package body Ocarina.Instances is ...@@ -186,27 +202,24 @@ package body Ocarina.Instances is
end loop; end loop;
if Present (List_Node) then if Present (List_Node) then
-- We found a root system matching user name, use it
Root_System := List_Node; Root_System := List_Node;
else
-- Else report error to user
Report_Root_Systems_To_User;
end if; end if;
else else
Error_Loc (1) := No_Location; -- User provided no root system, there are multiple ones,
DE ("Please select a root system among "); -- report and exit
List_Node := Root_Systems.First; Report_Root_Systems_To_User;
while Present (List_Node) loop
Error_Loc (1) := ATN.Loc (List_Node);
Error_Name (1) := ATE.Get_Name_Of_Entity
(List_Node, False, True);
DE ("%");
List_Node := ATN.Next_Entity (List_Node);
end loop;
Exit_On_Error (True, "Cannot instantiate AADL model");
end if; end if;
else else
-- If there is only one root system, choose it -- If there is only one root system, choose it
Root_System := Root_Systems.First; Root_System := Root_Systems.First;
if No (Root_System) then if No (Root_System) then
Error_Loc (1) := No_Location; Error_Loc (1) := No_Location;
DE ("Cannot find a root system"); DE ("Cannot find a root system");
......
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