prj.ads, [...] (Recursive_Process): Remove duplicated code.

2009-04-22  Emmanuel Briot  <briot@adacore.com>

	* prj.ads, prj.adb, prj-nmsc.adb, prj-proc.adb (Recursive_Process):
	Remove duplicated code.
	(Canonical_Case_File_Name): new subprogram
	(Check_And_Normalize_Unit_Names): new subprogram
	(Write_Attr): new subprogram
	Better sharing of code
	(Check_Naming_Ada_Only, Check_Naming_Multi_Lang): new subprogram, to
	split Check_Naming and help find duplicated code
	(Check_Common): new subprogram, sharing code between ada_only and
	multi_language mode.
	(Naming_Data.Dot_Repl_Loc): field removed

From-SVN: r146567
This commit is contained in:
Emmanuel Briot 2009-04-22 10:57:10 +00:00 committed by Arnaud Charlet
parent 24a40b356f
commit 347ab254f8
5 changed files with 606 additions and 847 deletions

View File

@ -1,3 +1,17 @@
2009-04-22 Emmanuel Briot <briot@adacore.com>
* prj.ads, prj.adb, prj-nmsc.adb, prj-proc.adb (Recursive_Process):
Remove duplicated code.
(Canonical_Case_File_Name): new subprogram
(Check_And_Normalize_Unit_Names): new subprogram
(Write_Attr): new subprogram
Better sharing of code
(Check_Naming_Ada_Only, Check_Naming_Multi_Lang): new subprogram, to
split Check_Naming and help find duplicated code
(Check_Common): new subprogram, sharing code between ada_only and
multi_language mode.
(Naming_Data.Dot_Repl_Loc): field removed
2009-04-22 Emmanuel Briot <briot@adacore.com>
* prj-proc.adb, prj-nmsc.adb (Load_Naming_Exceptions): New subprogram.

File diff suppressed because it is too large Load Diff

View File

@ -2519,7 +2519,67 @@ package body Prj.Proc is
From_Project_Node_Tree : Project_Node_Tree_Ref;
Extended_By : Project_Id)
is
With_Clause : Project_Node_Id;
procedure Process_Imported_Projects
(Imported : in out Project_List;
Limited_With : Boolean);
-- Process imported projects. If Limited_With is True, then only
-- projects processed through a "limited with" are processed, otherwise
-- only projects imported through a standard "with" are processed.
-- Imported is the id of the last imported project.
procedure Process_Imported_Projects
(Imported : in out Project_List;
Limited_With : Boolean)
is
With_Clause : Project_Node_Id := First_With_Clause_Of
(From_Project_Node, From_Project_Node_Tree);
New_Project : Project_Id;
Proj_Node : Project_Node_Id;
begin
while Present (With_Clause) loop
Proj_Node :=
Non_Limited_Project_Node_Of
(With_Clause, From_Project_Node_Tree);
New_Project := No_Project;
if (Limited_With and No (Proj_Node))
or (not Limited_With and Present (Proj_Node))
then
Recursive_Process
(In_Tree => In_Tree,
Project => New_Project,
From_Project_Node =>
Project_Node_Of
(With_Clause, From_Project_Node_Tree),
From_Project_Node_Tree => From_Project_Node_Tree,
Extended_By => No_Project);
-- Add this project to our list of imported projects
Project_List_Table.Increment_Last (In_Tree.Project_Lists);
In_Tree.Project_Lists.Table
(Project_List_Table.Last (In_Tree.Project_Lists)) :=
(Project => New_Project, Next => Empty_Project_List);
-- Imported is the id of the last imported project. If
-- it is nil, then this imported project is our first.
if Imported = Empty_Project_List then
In_Tree.Projects.Table (Project).Imported_Projects :=
Project_List_Table.Last (In_Tree.Project_Lists);
else
In_Tree.Project_Lists.Table (Imported).Next :=
Project_List_Table.Last (In_Tree.Project_Lists);
end if;
Imported := Project_List_Table.Last (In_Tree.Project_Lists);
end if;
With_Clause :=
Next_With_Clause_Of (With_Clause, From_Project_Node_Tree);
end loop;
end Process_Imported_Projects;
begin
if No (From_Project_Node) then
@ -2624,68 +2684,9 @@ package body Prj.Proc is
Prj.Attr.Attribute_First,
Project_Level => True);
-- Process non limited withed projects
In_Tree.Projects.Table (Project) := Processed_Data;
With_Clause :=
First_With_Clause_Of (From_Project_Node, From_Project_Node_Tree);
while Present (With_Clause) loop
declare
New_Project : Project_Id;
New_Data : Project_Data;
pragma Unreferenced (New_Data);
Proj_Node : Project_Node_Id;
begin
Proj_Node :=
Non_Limited_Project_Node_Of
(With_Clause, From_Project_Node_Tree);
if Present (Proj_Node) then
Recursive_Process
(In_Tree => In_Tree,
Project => New_Project,
From_Project_Node =>
Project_Node_Of
(With_Clause, From_Project_Node_Tree),
From_Project_Node_Tree => From_Project_Node_Tree,
Extended_By => No_Project);
New_Data :=
In_Tree.Projects.Table (New_Project);
-- Add this project to our list of imported projects
Project_List_Table.Increment_Last
(In_Tree.Project_Lists);
In_Tree.Project_Lists.Table
(Project_List_Table.Last
(In_Tree.Project_Lists)) :=
(Project => New_Project, Next => Empty_Project_List);
-- Imported is the id of the last imported project. If it
-- is nil, then this imported project is our first.
if Imported = Empty_Project_List then
Processed_Data.Imported_Projects :=
Project_List_Table.Last
(In_Tree.Project_Lists);
else
In_Tree.Project_Lists.Table
(Imported).Next := Project_List_Table.Last
(In_Tree.Project_Lists);
end if;
Imported := Project_List_Table.Last
(In_Tree.Project_Lists);
end if;
With_Clause :=
Next_With_Clause_Of
(With_Clause, From_Project_Node_Tree);
end;
end loop;
Process_Imported_Projects (Imported, Limited_With => False);
Declaration_Node :=
Project_Declaration_Of
@ -2693,15 +2694,13 @@ package body Prj.Proc is
Recursive_Process
(In_Tree => In_Tree,
Project => Processed_Data.Extends,
Project => In_Tree.Projects.Table (Project).Extends,
From_Project_Node => Extended_Project_Of
(Declaration_Node,
From_Project_Node_Tree),
From_Project_Node_Tree => From_Project_Node_Tree,
Extended_By => Project);
In_Tree.Projects.Table (Project) := Processed_Data;
Process_Declarative_Items
(Project => Project,
In_Tree => In_Tree,
@ -2826,68 +2825,7 @@ package body Prj.Proc is
In_Tree.Projects.Table (Project) := Processed_Data;
end if;
-- Process limited withed projects
With_Clause :=
First_With_Clause_Of
(From_Project_Node, From_Project_Node_Tree);
while Present (With_Clause) loop
declare
New_Project : Project_Id;
New_Data : Project_Data;
pragma Unreferenced (New_Data);
Proj_Node : Project_Node_Id;
begin
Proj_Node :=
Non_Limited_Project_Node_Of
(With_Clause, From_Project_Node_Tree);
if No (Proj_Node) then
Recursive_Process
(In_Tree => In_Tree,
Project => New_Project,
From_Project_Node =>
Project_Node_Of
(With_Clause, From_Project_Node_Tree),
From_Project_Node_Tree => From_Project_Node_Tree,
Extended_By => No_Project);
New_Data :=
In_Tree.Projects.Table (New_Project);
-- Add this project to our list of imported projects
Project_List_Table.Increment_Last
(In_Tree.Project_Lists);
In_Tree.Project_Lists.Table
(Project_List_Table.Last
(In_Tree.Project_Lists)) :=
(Project => New_Project, Next => Empty_Project_List);
-- Imported is the id of the last imported project. If
-- it is nil, then this imported project is our first.
if Imported = Empty_Project_List then
In_Tree.Projects.Table (Project).Imported_Projects :=
Project_List_Table.Last
(In_Tree.Project_Lists);
else
In_Tree.Project_Lists.Table
(Imported).Next := Project_List_Table.Last
(In_Tree.Project_Lists);
end if;
Imported := Project_List_Table.Last
(In_Tree.Project_Lists);
end if;
With_Clause :=
Next_With_Clause_Of
(With_Clause, From_Project_Node_Tree);
end;
end loop;
Process_Imported_Projects (Imported, Limited_With => True);
end;
end if;
end Recursive_Process;

View File

@ -73,7 +73,6 @@ package body Prj is
Std_Naming_Data : constant Naming_Data :=
(Dot_Replacement => Standard_Dot_Replacement,
Dot_Repl_Loc => No_Location,
Casing => All_Lower_Case,
Spec_Suffix => No_Array_Element,
Ada_Spec_Suffix_Loc => No_Location,
@ -655,10 +654,9 @@ package body Prj is
Extended : Project_Id;
In_Tree : Project_Tree_Ref) return Boolean
is
Proj : Project_Id;
Proj : Project_Id := Extending;
begin
Proj := Extending;
while Proj /= No_Project loop
if Proj = Extended then
return True;

View File

@ -870,8 +870,6 @@ package Prj is
Dot_Replacement : File_Name_Type := No_File;
-- The string to replace '.' in the source file name (for Ada)
Dot_Repl_Loc : Source_Ptr := No_Location;
Casing : Casing_Type := All_Lower_Case;
-- The casing of the source file name (for Ada)