codetools: identifier completion: do not eat unit not found error when searching ancestors

git-svn-id: trunk@25035 -
This commit is contained in:
mattias 2010-04-28 17:15:24 +00:00
parent 756b181ef3
commit 0b64f42042
3 changed files with 38 additions and 26 deletions

View File

@ -5018,7 +5018,7 @@ begin
Ancestors:=nil;
ListOfPFindContext:=nil;
try
if not FindClassAndAncestors(ClassNode,Ancestors) then exit;
if not FindClassAndAncestors(ClassNode,Ancestors,false) then exit;
if Ancestors=nil then exit(true);
for i:=0 to Ancestors.Count-1 do begin
Context:=PFindContext(Ancestors[i]);

View File

@ -806,7 +806,8 @@ type
out ListOfPCodeXYPosition: TFPList;
Flags: TFindDeclarationListFlags): boolean;
function FindClassAndAncestors(ClassNode: TCodeTreeNode;
out ListOfPFindContext: TFPList): boolean; // without interfaces
out ListOfPFindContext: TFPList; ExceptionOnNotFound: boolean
): boolean; // without interfaces
function FindContextClassAndAncestors(const CursorPos: TCodeXYPosition;
var ListOfPFindContext: TFPList): boolean; // without interfaces
function FindAncestorOfClass(ClassNode: TCodeTreeNode;
@ -3790,11 +3791,32 @@ begin
end;
function TFindDeclarationTool.FindClassAndAncestors(ClassNode: TCodeTreeNode;
out ListOfPFindContext: TFPList): boolean;
out ListOfPFindContext: TFPList; ExceptionOnNotFound: boolean): boolean;
var
FoundContext: TFindContext;
CurTool: TFindDeclarationTool;
Params: TFindDeclarationParams;
function Search: boolean;
var
CurTool: TFindDeclarationTool;
FoundContext: TFindContext;
begin
CurTool:=Self;
while CurTool.FindAncestorOfClass(ClassNode,Params,true) do begin
if (Params.NewCodeTool=nil) then break;
FoundContext.Tool:=Params.NewCodeTool;
FoundContext.Node:=Params.NewNode;
if IndexOfFindContext(ListOfPFindContext,@FoundContext)>=0 then break;
AddFindContext(ListOfPFindContext,FoundContext);
//debugln('TFindDeclarationTool.FindClassAndAncestors FoundContext=',DbgsFC(FoundContext));
CurTool:=Params.NewCodeTool;
ClassNode:=Params.NewNode;
if (ClassNode=nil)
or (not (ClassNode.Desc in AllClasses)) then
break;
end;
Result:=true;
end;
begin
{$IFDEF CheckNodeTool}CheckNodeTool(ClassNode);{$ENDIF}
Result:=false;
@ -3809,26 +3831,16 @@ begin
Params:=TFindDeclarationParams.Create;
ActivateGlobalWriteLock;
try
try
CurTool:=Self;
while CurTool.FindAncestorOfClass(ClassNode,Params,true) do begin
if (Params.NewCodeTool=nil) then break;
FoundContext.Tool:=Params.NewCodeTool;
FoundContext.Node:=Params.NewNode;
if IndexOfFindContext(ListOfPFindContext,@FoundContext)>=0 then break;
AddFindContext(ListOfPFindContext,FoundContext);
//debugln('TFindDeclarationTool.FindClassAndAncestors FoundContext=',DbgsFC(FoundContext));
CurTool:=Params.NewCodeTool;
ClassNode:=Params.NewNode;
if (ClassNode=nil)
or (not (ClassNode.Desc in AllClasses)) then
break;
if ExceptionOnNotFound then
Result:=Search
else begin
try
Result:=Search;
except
// catch syntax errors
on E: ECodeToolError do ;
on E: ELinkScannerError do ;
end;
Result:=true;
except
// catch syntax errors
on E: ECodeToolError do ;
on E: ELinkScannerError do ;
end;
finally
DeactivateGlobalWriteLock;
@ -3864,7 +3876,7 @@ begin
//debugln('TFindDeclarationTool.FindContextClassAndAncestors A ClassName=',ExtractClassName(ClassNode,false));
// add class and ancestors type definition to ListOfPCodeXYPosition
if not FindClassAndAncestors(ClassNode,ListOfPFindContext)
if not FindClassAndAncestors(ClassNode,ListOfPFindContext,true)
then exit;
//debugln('TFindDeclarationTool.FindContextClassAndAncestors List: ',ListOfPFindContextToStr(ListOfPFindContext));

View File

@ -4889,7 +4889,7 @@ begin
AncestorList:=nil;
try
if WithAncestors then begin
if not FindClassAndAncestors(ClassNode,AncestorList) then exit;
if not FindClassAndAncestors(ClassNode,AncestorList,true) then exit;
end else begin
AddFindContext(AncestorList,CreateFindContext(Self,ClassNode));
end;