IDE: ignore missing related files when renaming a unit

git-svn-id: trunk@27564 -
This commit is contained in:
mattias 2010-10-04 09:41:45 +00:00
parent d589d25f96
commit a1310c5ca4
2 changed files with 17 additions and 6 deletions

View File

@ -38,7 +38,7 @@ uses
{$ELSE}
Laz_DOM,
{$ENDIF}
AVL_Tree, CodeTree, CodeAtom, CodeCache, CodeToolManager,
FileProcs, AVL_Tree, CodeTree, CodeAtom, CodeCache, CodeToolManager,
// IDE
LazarusIDEStrConsts, IDEProcs, IDEWindowIntf, MiscOptions, DialogProcs,
LazIDEIntf, InputHistory, SearchResultView, CodeHelp, ButtonPanel;
@ -98,7 +98,7 @@ function GatherIdentifierReferences(Files: TStringList;
SearchInComments: boolean;
var TreeOfPCodeXYPosition: TAVLTree): TModalResult;
function GatherUnitReferences(Files: TStringList;
UnitCode: TCodeBuffer; SearchInComments, IgnoreErrors: boolean;
UnitCode: TCodeBuffer; SearchInComments, IgnoreErrors, IgnoreMissingFiles: boolean;
var TreeOfPCodeXYPosition: TAVLTree): TModalResult;
function ShowIdentifierReferences(
DeclarationCode: TCodeBuffer; const DeclarationCaretXY: TPoint;
@ -215,7 +215,7 @@ begin
end;
function GatherUnitReferences(Files: TStringList; UnitCode: TCodeBuffer;
SearchInComments, IgnoreErrors: boolean;
SearchInComments, IgnoreErrors, IgnoreMissingFiles: boolean;
var TreeOfPCodeXYPosition: TAVLTree): TModalResult;
var
ListOfPCodeXYPosition: TFPList;
@ -233,6 +233,16 @@ begin
// search in every file
for i:=0 to Files.Count-1 do begin
if CompareFilenames(Files[i],UnitCode.Filename)=0 then continue;
if IgnoreMissingFiles then
begin
if FilenameIsAbsolute(Files[i]) then
begin
if not FileExistsCached(Files[i]) then continue;
end else begin
Code:=CodeToolBoss.LoadFile(Files[i],false,false);
if (Code=nil) then continue;
end;
end;
LoadResult:=
LoadCodeBuffer(Code,Files[i],[lbfCheckIfText,lbfUpdateFromDisk],true);
if LoadResult=mrAbort then begin

View File

@ -5582,7 +5582,7 @@ begin
TSourceEditor(AnUnitInfo.EditorInfo[i].EditorComponent).CodeBuffer := NewSource;
// the code is not changed, therefore the marks are kept
// change unitname in project and in source
// change unitname in lpi and in main source file
AnUnitInfo.Unit_Name:=NewUnitName;
if ResourceCode<>nil then begin
// change resource filename in the source include directive
@ -5613,7 +5613,7 @@ begin
AnUnitInfo.Modified:=false;
end;
// change packages containing the file
// change lpks containing the file
Result:=PkgBoss.OnRenameFile(OldFilename,AnUnitInfo.Filename,
AnUnitInfo.IsPartOfProject);
if Result=mrAbort then exit;
@ -17163,7 +17163,8 @@ begin
end;
// search pascal source references
Result:=GatherUnitReferences(Files,OldCode,false,IgnoreErrors,PascalReferences);
Result:=GatherUnitReferences(Files,OldCode,false,IgnoreErrors,true,
PascalReferences);
if (not IgnoreErrors) and (not Quiet) and (CodeToolBoss.ErrorMessage<>'')
then
DoJumpToCodeToolBossError;