Converter: Organize and clean method FindMissingUnits. Use original unit name when reporting special cases as missing.

git-svn-id: trunk@39800 -
This commit is contained in:
juha 2013-01-07 19:45:38 +00:00
parent c47b6d72a2
commit a4cebdfafc

View File

@ -210,7 +210,7 @@ var
InAtom, UnitNameAtom: TAtomPosition; InAtom, UnitNameAtom: TAtomPosition;
OldUnitName, OldInFilename: String; OldUnitName, OldInFilename: String;
NewUnitName, NewInFilename: String; NewUnitName, NewInFilename: String;
AFilename, s, LowNU: String; FullFileN, LowFileN: String;
OmitUnit: Boolean; OmitUnit: Boolean;
begin begin
UsesNode:=UsesSectionNode; UsesNode:=UsesSectionNode;
@ -228,37 +228,39 @@ begin
OldInFilename:=''; OldInFilename:='';
// find unit file // find unit file
NewUnitName:=OldUnitName; NewUnitName:=OldUnitName;
LowNU:=LowerCase(NewUnitName); LowFileN:=LowerCase(NewUnitName);
NewInFilename:=OldInFilename; NewInFilename:=OldInFilename;
AFilename:=CodeTool.FindUnitCaseInsensitive(NewUnitName,NewInFilename); FullFileN:=CodeTool.FindUnitCaseInsensitive(NewUnitName,NewInFilename);
s:=NewUnitName; if FullFileN<>'' then begin // * Unit found *
if NewInFilename<>'' then
s:=s+' in '''+NewInFilename+'''';
if AFilename<>'' then begin // unit found
OmitUnit := Settings.OmitProjUnits.Contains(NewUnitName); OmitUnit := Settings.OmitProjUnits.Contains(NewUnitName);
if (NewUnitName<>OldUnitName) and not OmitUnit then begin // Report omitted units as missing, pretend they don't exist here,
if OmitUnit then // but they can have replacements.
fMissingUnits.Add(OldUnitName)
else begin
if NewUnitName<>OldUnitName then begin
// Character case differs, fix it. // Character case differs, fix it.
fUnitsToFixCase[OldUnitName]:=NewUnitName; fUnitsToFixCase[OldUnitName]:=NewUnitName;
IDEMessagesWindow.AddMsg(Format(lisConvDelphiFixedUnitCase, IDEMessagesWindow.AddMsg(Format(lisConvDelphiFixedUnitCase,
[OldUnitName, NewUnitName]), '', -1); [OldUnitName, NewUnitName]), '', -1);
end; 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 CrossPlatform. // Report Windows specific units as missing if target is CrossPlatform.
// Needed if work-platform is Windows. // Needed if work-platform is Windows.
else if Settings.CrossPlatform and IsWinSpecificUnit(LowNU) then if Settings.CrossPlatform and IsWinSpecificUnit(LowFileN) then
fMissingUnits.Add(s); fMissingUnits.Add(OldUnitName);
// Check if the unit is not part of project and needs conversion, too. end;
// Check if the unit is not part of project. It will be added and converted then.
if Assigned(fOwnerTool.OnCheckUnitForConversion) then if Assigned(fOwnerTool.OnCheckUnitForConversion) then
fOwnerTool.OnCheckUnitForConversion(AFilename); fOwnerTool.OnCheckUnitForConversion(FullFileN);
end end
else begin else begin // * Unit not found *
// If the unit is not found, add it to fMissingUnits, but don't add // Add unit to fMissingUnits, but don't add Windows specific units if target
// Windows specific units if target is "Windows only". // is "Windows only". Needed if work-platform is different from Windows.
// Needed if work-platform is different from Windows. if Settings.CrossPlatform or not IsWinSpecificUnit(LowFileN) then begin
if Settings.CrossPlatform or not IsWinSpecificUnit(LowNU) then FullFileN:=NewUnitName;
fMissingUnits.Add(s); if NewInFilename<>'' then
FullFileN:=FullFileN+' in '''+NewInFilename+'''';
fMissingUnits.Add(FullFileN);
end;
end; end;
if CodeTool.CurPos.Flag=cafComma then begin if CodeTool.CurPos.Flag=cafComma then begin
// read next unit name // read next unit name