codetools: find references: fixed error handling

git-svn-id: trunk@26434 -
This commit is contained in:
mattias 2010-07-02 23:11:47 +00:00
parent 769c96eb77
commit 946f34ba8f
3 changed files with 17 additions and 5 deletions

View File

@ -2210,10 +2210,11 @@ begin
except
on e: Exception do HandleException(e);
end;
if not Result then begin
if (not Result) or (NewNode=nil) then begin
DebugLn('TCodeToolManager.FindReferences unable to FindDeclaration ',IdentifierCode.Filename,' x=',dbgs(x),' y=',dbgs(y));
exit;
end;
Result:=true;
// check if scope can be limited
PrivateDeclaration:=(NewTool.GetSourceType in [ctnLibrary,ctnProgram]);
if not PrivateDeclaration then begin
@ -2222,6 +2223,10 @@ begin
then
PrivateDeclaration:=true;
end;
if not PrivateDeclaration then begin
if (NewNode.Parent<>nil) and (NewNode.Parent.Desc=ctnParameterList) then
PrivateDeclaration:=true;
end;
if NewTopLine=0 then ;
if not InitCurCodeTool(TargetCode) then exit;
if PrivateDeclaration and (FCurCodeTool<>NewTool) then exit(true);

View File

@ -3974,7 +3974,7 @@ var
else
Params.Clear;
Params.Flags:=[fdfSearchInParentNodes,fdfSearchInAncestors,
fdfExceptionOnNotFound,fdfIgnoreCurContextNode];
fdfIgnoreCurContextNode];
if NodeIsForwardDeclaration(CursorNode) then begin
//debugln('Node is forward declaration');
Params.Flags:=Params.Flags+[fdfSearchForward];
@ -3991,8 +3991,14 @@ var
else
Found:=FindDeclarationOfIdentAtParam(Params);
except
on E: ECodeToolError do
if not IsComment then raise;
on E: ECodeToolError do begin
if E.Sender<>Self then begin
// there is an error in another unit, which prevetns searching
// stop further searching in this unit
raise;
end;
// continue
end;
on E: Exception do
raise;
end;

View File

@ -41,7 +41,7 @@ uses
AVL_Tree, CodeTree, CodeAtom, CodeCache, CodeToolManager,
// IDE
LazarusIDEStrConsts, IDEProcs, IDEWindowIntf, MiscOptions, DialogProcs,
InputHistory, SearchResultView, CodeHelp, ButtonPanel;
LazIDEIntf, InputHistory, SearchResultView, CodeHelp, ButtonPanel;
type
@ -176,6 +176,7 @@ begin
// search in every file
for i:=0 to Files.Count-1 do begin
//debugln(['GatherIdentifierReferences ',Files[i]]);
LoadResult:=
LoadCodeBuffer(Code,Files[i],[lbfCheckIfText,lbfUpdateFromDisk],true);
if LoadResult=mrAbort then begin