mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-11-21 11:49:57 +01:00
Converter: refactoring AddUnitIfNeeded procedure
git-svn-id: trunk@39048 -
This commit is contained in:
parent
764a95ecf0
commit
fdf1a89262
@ -623,13 +623,13 @@ begin
|
|||||||
// Add more units meant for only LCL.
|
// Add more units meant for only LCL.
|
||||||
with fMainUsedUnits do begin
|
with fMainUsedUnits do begin
|
||||||
for i:=0 to fUnitsToAddForLCL.Count-1 do
|
for i:=0 to fUnitsToAddForLCL.Count-1 do
|
||||||
if not CodeTool.AddUnitToSpecificUsesSection(
|
if not CodeTool.AddUnitToSpecificUsesSection(fUsesSection,
|
||||||
fUsesSection, fUnitsToAddForLCL[i], '', SrcCache) then exit;
|
fUnitsToAddForLCL[i], '', SrcCache) then exit;
|
||||||
end;
|
end;
|
||||||
with fImplUsedUnits do begin
|
with fImplUsedUnits do begin
|
||||||
for i:=0 to fUnitsToAddForLCL.Count-1 do
|
for i:=0 to fUnitsToAddForLCL.Count-1 do
|
||||||
if not CodeTool.AddUnitToSpecificUsesSection(
|
if not CodeTool.AddUnitToSpecificUsesSection(fUsesSection,
|
||||||
fUsesSection, fUnitsToAddForLCL[i], '', SrcCache) then exit;
|
fUnitsToAddForLCL[i], '', SrcCache) then exit;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -666,27 +666,29 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TUsedUnitsTool.AddUnitIfNeeded(AUnitName: string);
|
procedure TUsedUnitsTool.AddUnitIfNeeded(AUnitName: string);
|
||||||
|
|
||||||
|
// Return True if the rename (target) value contains AUnitName.
|
||||||
|
// The rename value can have many comma separated unit names.
|
||||||
|
function RenameValHasUnit(aUsedUnits: TUsedUnits): Boolean;
|
||||||
|
var
|
||||||
|
i: Integer;
|
||||||
|
begin
|
||||||
|
Result := False;
|
||||||
|
for i := 0 to aUsedUnits.fUnitsToRenameVals.Count-1 do
|
||||||
|
if Pos(AUnitName, aUsedUnits.fUnitsToRenameVals[i]) > 0 then
|
||||||
|
Exit(True);
|
||||||
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
i: Integer;
|
|
||||||
UnitInFileName: String;
|
UnitInFileName: String;
|
||||||
RenameValFound: Boolean;
|
x: Integer;
|
||||||
begin
|
begin
|
||||||
RenameValFound:=false;
|
if not ( fMainUsedUnits.fExistingUnits.Find(AUnitName, x)
|
||||||
for i := 0 to fMainUsedUnits.fUnitsToRenameVals.Count-1 do
|
or fImplUsedUnits.fExistingUnits.Find(AUnitName, x)
|
||||||
if Pos(AUnitName, fMainUsedUnits.fUnitsToRenameVals[i]) > 0 then begin
|
or (fMainUsedUnits.fUnitsToAdd.IndexOf(AUnitName) > -1)
|
||||||
RenameValFound:=true;
|
or RenameValHasUnit(fMainUsedUnits)
|
||||||
Break;
|
or RenameValHasUnit(fImplUsedUnits) ) then
|
||||||
end;
|
begin
|
||||||
if not RenameValFound then
|
|
||||||
for i := 0 to fImplUsedUnits.fUnitsToRenameVals.Count-1 do
|
|
||||||
if Pos(AUnitName, fImplUsedUnits.fUnitsToRenameVals[i]) > 0 then begin
|
|
||||||
RenameValFound:=true;
|
|
||||||
Break;
|
|
||||||
end;
|
|
||||||
if not ( fMainUsedUnits.fExistingUnits.Find(AUnitName, i) or
|
|
||||||
fImplUsedUnits.fExistingUnits.Find(AUnitName, i) or
|
|
||||||
(fMainUsedUnits.fUnitsToAdd.IndexOf(AUnitName) > -1) or RenameValFound)
|
|
||||||
then begin
|
|
||||||
fMainUsedUnits.fUnitsToAdd.Add(AUnitName);
|
fMainUsedUnits.fUnitsToAdd.Add(AUnitName);
|
||||||
IDEMessagesWindow.AddMsg('Added unit '+AUnitName+ ' to uses section', '', -1);
|
IDEMessagesWindow.AddMsg('Added unit '+AUnitName+ ' to uses section', '', -1);
|
||||||
// If the unit is not found, open the package containing it.
|
// If the unit is not found, open the package containing it.
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user