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
......@@ -25,7 +25,8 @@
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 Prj.Attr; use Prj.Attr;
......@@ -36,8 +37,12 @@ with Prj.Tree; use Prj.Tree;
with Snames;
with Uintp; use Uintp;
with System.Strings;
package body Prj.Dect is
use System;
type Zone is (In_Project, In_Package, In_Case_Construction);
-- Used to indicate if we are parsing a package (In_Package),
-- a case construction (In_Case_Construction) or none of those two
......@@ -983,11 +988,44 @@ package body Prj.Dect is
if Current_Package = Empty_Package then
if not Quiet_Output then
Error_Msg ("?""" &
Get_Name_String
(Name_Of (Package_Declaration, In_Tree)) &
""" is not a known package name",
Token_Ptr);
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 ("?""" &
Get_Name_String
(Name_Of (Package_Declaration, In_Tree)) &
""" is not a known package name",
Token_Ptr);
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
......
......@@ -6,7 +6,7 @@
-- --
-- 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 --
-- terms of the GNU General Public License as published by the Free Soft- --
......@@ -1047,18 +1047,18 @@ package body Prj.Tree is
With_Clause := Next_With_Clause_Of (With_Clause, In_Tree);
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
Result :=
Extended_Project_Of
(Project_Declaration_Of (Project, In_Tree), In_Tree);
if Result /= Empty_Node
and then Name_Of (Result, In_Tree) /= With_Name
then
Result := Empty_Node;
end if;
Result := Project;
loop
Result :=
Extended_Project_Of
(Project_Declaration_Of (Result, In_Tree), In_Tree);
exit when Result = Empty_Node
or else Name_Of (Result, In_Tree) = With_Name;
end loop;
end if;
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