mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-12 22:40:15 +02:00
Converter: refactoring, extract identical code into a function.
git-svn-id: trunk@26102 -
This commit is contained in:
parent
e08543719c
commit
be5ea84897
@ -1377,10 +1377,24 @@ end;
|
|||||||
|
|
||||||
function TConvertDelphiProject.ConvertAllUnits: TModalResult;
|
function TConvertDelphiProject.ConvertAllUnits: TModalResult;
|
||||||
var
|
var
|
||||||
i: Integer;
|
|
||||||
CurUnitInfo: TUnitInfo;
|
|
||||||
Converter: TConvertDelphiUnit;
|
|
||||||
ConvUnits: TObjectList; // List of ConvertDelphiUnits.
|
ConvUnits: TObjectList; // List of ConvertDelphiUnits.
|
||||||
|
|
||||||
|
function ConvertOne(AUnitInfo: TUnitInfo): TModalResult;
|
||||||
|
var
|
||||||
|
Converter: TConvertDelphiUnit;
|
||||||
|
begin
|
||||||
|
Converter:=TConvertDelphiUnit.Create(Self, AUnitInfo.Filename,[]);
|
||||||
|
Converter.fUnitInfo:=AUnitInfo;
|
||||||
|
ConvUnits.Add(Converter);
|
||||||
|
Result:=Converter.CopyAndLoadFile;
|
||||||
|
Result:=Converter.CheckFailed(Result);
|
||||||
|
if Result<>mrOK then exit;
|
||||||
|
Result:=Converter.ConvertUnitFile;
|
||||||
|
end;
|
||||||
|
|
||||||
|
var
|
||||||
|
CurUnitInfo: TUnitInfo;
|
||||||
|
i: Integer;
|
||||||
begin
|
begin
|
||||||
Result:=mrOk;
|
Result:=mrOk;
|
||||||
ConvUnits:=TObjectList.create;
|
ConvUnits:=TObjectList.create;
|
||||||
@ -1391,31 +1405,17 @@ begin
|
|||||||
for i:=0 to LazProject.UnitCount-1 do begin
|
for i:=0 to LazProject.UnitCount-1 do begin
|
||||||
CurUnitInfo:=LazProject.Units[i];
|
CurUnitInfo:=LazProject.Units[i];
|
||||||
// Main LPR file was converted earlier.
|
// Main LPR file was converted earlier.
|
||||||
if CurUnitInfo.IsPartOfProject and (CurUnitInfo<>LazProject.MainUnitInfo) then
|
if CurUnitInfo.IsPartOfProject and (CurUnitInfo<>LazProject.MainUnitInfo) then begin
|
||||||
begin
|
Result:=ConvertOne(CurUnitInfo);
|
||||||
Converter:=TConvertDelphiUnit.Create(Self, CurUnitInfo.Filename,[]);
|
|
||||||
Converter.fUnitInfo:=CurUnitInfo;
|
|
||||||
ConvUnits.Add(Converter);
|
|
||||||
Result:=Converter.CopyAndLoadFile;
|
|
||||||
Result:=Converter.CheckFailed(Result);
|
|
||||||
if Result<>mrOK then Break;
|
|
||||||
Result:=Converter.ConvertUnitFile;
|
|
||||||
if Result<>mrOK then Break;
|
if Result<>mrOK then Break;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
// During conversion there were more units added to be converted.
|
// During conversion there were more units added to be converted.
|
||||||
for i:=0 to fUnitsToAddToProject.Count-1 do begin
|
for i:=0 to fUnitsToAddToProject.Count-1 do begin
|
||||||
Result:=AddUnit(fUnitsToAddToProject[i], CurUnitInfo);
|
Result:=AddUnit(fUnitsToAddToProject[i], CurUnitInfo);
|
||||||
if Result=mrAbort then Break;
|
|
||||||
if Result=mrNo then continue;
|
if Result=mrNo then continue;
|
||||||
/// From above:
|
if Result=mrAbort then Break;
|
||||||
Converter:=TConvertDelphiUnit.Create(Self, CurUnitInfo.Filename,[]);
|
Result:=ConvertOne(CurUnitInfo);
|
||||||
Converter.fUnitInfo:=CurUnitInfo;
|
|
||||||
ConvUnits.Add(Converter);
|
|
||||||
Result:=Converter.CopyAndLoadFile;
|
|
||||||
Result:=Converter.CheckFailed(Result);
|
|
||||||
if Result<>mrOK then Break;
|
|
||||||
Result:=Converter.ConvertUnitFile;
|
|
||||||
if Result<>mrOK then Break;
|
if Result<>mrOK then Break;
|
||||||
end;
|
end;
|
||||||
if Result=mrOK then
|
if Result=mrOK then
|
||||||
|
Loading…
Reference in New Issue
Block a user