mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-16 07:49:33 +02:00
Converter: find replacement also for units that are omitted from project (they have a valid Lazarus package). Improve messages
git-svn-id: trunk@39689 -
This commit is contained in:
parent
c806da351b
commit
62517a1978
@ -617,6 +617,9 @@ function TDelphiUnit.ConvertUnitFile: TModalResult;
|
||||
// Comment out automatically units that were commented in other files.
|
||||
fUsedUnitsTool.MainUsedUnits.CommentAutomatic(fOwnerConverter.fAllCommentedUnits);
|
||||
fUsedUnitsTool.ImplUsedUnits.CommentAutomatic(fOwnerConverter.fAllCommentedUnits);
|
||||
// Remove omitted units from MissingUnits.
|
||||
fUsedUnitsTool.MainUsedUnits.OmitUnits;
|
||||
fUsedUnitsTool.ImplUsedUnits.OmitUnits;
|
||||
if fUsedUnitsTool.MissingUnitCount=0 then exit;
|
||||
// Interactive dialog for searching unit.
|
||||
Result:=AskUnitPathFromUser;
|
||||
@ -1017,8 +1020,10 @@ var
|
||||
Converter: TDelphiUnit;
|
||||
i: Integer;
|
||||
begin
|
||||
if not fSettings.SameDfmFile then
|
||||
if not fSettings.SameDfmFile then begin
|
||||
IDEMessagesWindow.AddMsg('', '', -1);
|
||||
IDEMessagesWindow.AddMsg(lisConvDelphiRepairingFormFiles, '', -1);
|
||||
end;
|
||||
Application.ProcessMessages;
|
||||
Screen.Cursor:=crHourGlass;
|
||||
try
|
||||
@ -1484,6 +1489,7 @@ begin
|
||||
MisUnits:=nil;
|
||||
NormalUnits:=nil;
|
||||
try
|
||||
IDEMessagesWindow.AddMsg('', '', -1);
|
||||
IDEMessagesWindow.AddMsg(lisConvDelphiFindAllUnitFiles, '', -1);
|
||||
Application.ProcessMessages;
|
||||
if not CodeToolBoss.FindDelphiProjectUnits(fMainUnitConverter.fPascalBuffer,
|
||||
@ -1552,6 +1558,7 @@ begin
|
||||
ConvUnits:=TObjectList.Create;
|
||||
try
|
||||
// convert all units and fix .lfm files
|
||||
IDEMessagesWindow.AddMsg('', '', -1);
|
||||
IDEMessagesWindow.AddMsg(lisConvDelphiConvertingUnitFiles, '', -1);
|
||||
Application.ProcessMessages;
|
||||
for i:=0 to LazProject.UnitCount-1 do begin
|
||||
@ -1732,6 +1739,7 @@ begin
|
||||
ConvUnits:=TObjectList.create;
|
||||
try
|
||||
// convert all units and fix .lfm files
|
||||
IDEMessagesWindow.AddMsg('', '', -1);
|
||||
IDEMessagesWindow.AddMsg(lisConvDelphiConvertingUnitFiles, '', -1);
|
||||
Application.ProcessMessages;
|
||||
for i:=0 to LazPackage.FileCount-1 do begin
|
||||
|
@ -76,6 +76,7 @@ type
|
||||
constructor Create(ACTLink: TCodeToolLink; aOwnerTool: TUsedUnitsTool);
|
||||
destructor Destroy; override;
|
||||
procedure CommentAutomatic(ACommentedUnits: TStringList);
|
||||
procedure OmitUnits;
|
||||
public
|
||||
property UnitsToRemove: TStringList read fUnitsToRemove;
|
||||
property UnitsToRename: TStringToStringTree read fUnitsToRename;
|
||||
@ -211,6 +212,7 @@ var
|
||||
NewUnitName, NewInFilename: String;
|
||||
AFilename, s, LowNU: String;
|
||||
x: Integer;
|
||||
OmitUnit: Boolean;
|
||||
begin
|
||||
UsesNode:=UsesSectionNode;
|
||||
if UsesNode=nil then exit(true);
|
||||
@ -234,16 +236,19 @@ begin
|
||||
if NewInFilename<>'' then
|
||||
s:=s+' in '''+NewInFilename+'''';
|
||||
if AFilename<>'' then begin // unit found
|
||||
if (NewUnitName<>OldUnitName) and not Settings.OmitProjUnits.Find(NewUnitName,x)
|
||||
then begin
|
||||
OmitUnit := Settings.OmitProjUnits.Find(NewUnitName,x);
|
||||
if (NewUnitName<>OldUnitName) and not OmitUnit then begin
|
||||
// Character case differs, fix it.
|
||||
fUnitsToFixCase[OldUnitName]:=NewUnitName;
|
||||
IDEMessagesWindow.AddMsg(Format(lisConvDelphiFixedUnitCase,
|
||||
[OldUnitName, NewUnitName]), '', -1);
|
||||
end;
|
||||
// Report omitted units as missing, pretend they don't exist here,
|
||||
if OmitUnit then // but they can have replacements.
|
||||
fMissingUnits.Add(NewUnitName)
|
||||
// Report Windows specific units as missing if target is MultiPlatform.
|
||||
// Needed if work-platform is Windows (kind of a hack).
|
||||
if Settings.MultiPlatform and IsWinSpecificUnit(LowNU) then
|
||||
else if Settings.MultiPlatform and IsWinSpecificUnit(LowNU) then
|
||||
fMissingUnits.Add(s);
|
||||
// Check if the unit is not part of project and needs conversion, too.
|
||||
if Assigned(fOwnerTool.OnCheckUnitForConversion) then
|
||||
@ -434,6 +439,17 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TUsedUnits.OmitUnits;
|
||||
// Remove globally omitted units from MissingUnits.
|
||||
// Those units were added to MissingUnits to find possible replacements.
|
||||
var
|
||||
i, x: Integer;
|
||||
begin
|
||||
for i:=fMissingUnits.Count-1 downto 0 do
|
||||
if fCTLink.Settings.OmitProjUnits.Find(fMissingUnits[i], x) then
|
||||
fMissingUnits.Delete(i);
|
||||
end;
|
||||
|
||||
function TUsedUnits.RemoveUnits: boolean;
|
||||
// Remove units
|
||||
var
|
||||
|
@ -5331,10 +5331,10 @@ resourcestring
|
||||
lisConvDelphiConvertDelphiUnit = 'Convert Delphi unit';
|
||||
lisConvDelphiConvertDelphiProject = 'Convert Delphi project';
|
||||
lisConvDelphiConvertDelphiPackage = 'Convert Delphi package';
|
||||
lisConvDelphiFindAllUnitFiles = '*** Find all unit files ... ***';
|
||||
lisConvDelphiRepairingFormFiles = '*** Repairing form files ... ***';
|
||||
lisConvDelphiFindAllUnitFiles = '*** Find all unit files ***';
|
||||
lisConvDelphiRepairingFormFiles = '*** Fixing used units and Repairing form files ***';
|
||||
lisConvDelphiConvertingUnitFiles = '*** Converting unit files ***';
|
||||
lisConvDelphiRepairingFormFile = '* Repairing form file %s *';
|
||||
lisConvDelphiConvertingUnitFiles = '*** Converting unit files ... ***';
|
||||
lisConvDelphiConvertingFile = '* Converting file %s *';
|
||||
lisConvDelphiFixingUsedUnits = '* Fixing used units for file %s *';
|
||||
lisConvDelphiChangedEncodingToUTF8 = 'Changed encoding from %s to UTF-8';
|
||||
|
Loading…
Reference in New Issue
Block a user