Commit 1a5d715a by Vincent Celier Committed by Arnaud Charlet

prj-dect.adb (Parse_Package_Declaration): When a package name is not known...

2008-03-26  Vincent Celier  <celier@adacore.com>

	* prj-dect.adb (Parse_Package_Declaration): When a package name is not
	known, check if it may be a missspelling of a known package name. In
	not verbose, not mode, issue warnings only if the package name is a
	possible misspelling.
	In verbose mode, always issue a warning for a not known package name,
	plus a warning if the name is a misspelling of a known package name.

	* prj-part.adb (Post_Parse_Context_Clause): Modify so that only non
	limited withs or limited withs are parse during one call.
	(Parse_Single_Project): Post parse context clause in two passes: non
	limited withs before current project and limited withs after current
	project.

	* prj-proc.adb (Imported_Or_Extended_Project_From): Returns an extended
	project with the name With_Name, even if it is only extended indirectly.
	(Recursive_Process): Process projects in order: first single withs, then
	current project, then limited withs.

	* prj-tree.adb (Imported_Or_Extended_Project_Of): Returns an extended
	project with the name With_Name, even if it is only extended indirectly.

From-SVN: r133573
parent 2b2b6798
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
with Err_Vars; use Err_Vars; with Err_Vars; use Err_Vars;
with GNAT.Case_Util; use GNAT.Case_Util; with GNAT.Case_Util; use GNAT.Case_Util;
with GNAT.Spelling_Checker; use GNAT.Spelling_Checker;
with Opt; use Opt; with Opt; use Opt;
with Prj.Attr; use Prj.Attr; with Prj.Attr; use Prj.Attr;
...@@ -36,8 +37,12 @@ with Prj.Tree; use Prj.Tree; ...@@ -36,8 +37,12 @@ with Prj.Tree; use Prj.Tree;
with Snames; with Snames;
with Uintp; use Uintp; with Uintp; use Uintp;
with System.Strings;
package body Prj.Dect is package body Prj.Dect is
use System;
type Zone is (In_Project, In_Package, In_Case_Construction); type Zone is (In_Project, In_Package, In_Case_Construction);
-- Used to indicate if we are parsing a package (In_Package), -- Used to indicate if we are parsing a package (In_Package),
-- a case construction (In_Case_Construction) or none of those two -- a case construction (In_Case_Construction) or none of those two
...@@ -983,6 +988,31 @@ package body Prj.Dect is ...@@ -983,6 +988,31 @@ package body Prj.Dect is
if Current_Package = Empty_Package then if Current_Package = Empty_Package then
if not Quiet_Output then if not Quiet_Output then
declare
List : constant Strings.String_List := Package_Name_List;
Index : Natural;
Name : constant String := Get_Name_String (Token_Name);
begin
-- Check for possible misspelling of a known package name
Index := 0;
loop
if Index >= List'Last then
Index := 0;
exit;
end if;
Index := Index + 1;
exit when
GNAT.Spelling_Checker.Is_Bad_Spelling_Of
(Name, List (Index).all);
end loop;
-- Issue warning(s) in verbose mode or when a possible
-- misspelling has been found.
if Verbose_Mode or else Index /= 0 then
Error_Msg ("?""" & Error_Msg ("?""" &
Get_Name_String Get_Name_String
(Name_Of (Package_Declaration, In_Tree)) & (Name_Of (Package_Declaration, In_Tree)) &
...@@ -990,6 +1020,14 @@ package body Prj.Dect is ...@@ -990,6 +1020,14 @@ package body Prj.Dect is
Token_Ptr); Token_Ptr);
end if; end if;
if Index /= 0 then
Error_Msg ("\?possible misspelling of """ &
List (Index).all & """",
Token_Ptr);
end if;
end;
end if;
-- Set the package declaration to "ignored" so that it is not -- Set the package declaration to "ignored" so that it is not
-- processed by Prj.Proc.Process. -- processed by Prj.Proc.Process.
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- B o d y -- -- B o d y --
-- -- -- --
-- Copyright (C) 2001-2007, Free Software Foundation, Inc. -- -- Copyright (C) 2001-2008, Free Software Foundation, Inc. --
-- -- -- --
-- GNAT is free software; you can redistribute it and/or modify it under -- -- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -1047,18 +1047,18 @@ package body Prj.Tree is ...@@ -1047,18 +1047,18 @@ package body Prj.Tree is
With_Clause := Next_With_Clause_Of (With_Clause, In_Tree); With_Clause := Next_With_Clause_Of (With_Clause, In_Tree);
end loop; end loop;
-- If it is not an imported project, it might be the imported project -- If it is not an imported project, it might be an extended project
if With_Clause = Empty_Node then if With_Clause = Empty_Node then
Result := Project;
loop
Result := Result :=
Extended_Project_Of Extended_Project_Of
(Project_Declaration_Of (Project, In_Tree), In_Tree); (Project_Declaration_Of (Result, In_Tree), In_Tree);
if Result /= Empty_Node exit when Result = Empty_Node
and then Name_Of (Result, In_Tree) /= With_Name or else Name_Of (Result, In_Tree) = With_Name;
then end loop;
Result := Empty_Node;
end if;
end if; end if;
return Result; return Result;
......
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