mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-07 06:38:06 +02:00
Converter: Update uses sections already before checking LFM file. Unknown units screwed up parsing. Especially "Windows" unit on Linux.
git-svn-id: trunk@53842 -
This commit is contained in:
parent
7328ad5783
commit
19cecf179f
@ -666,9 +666,12 @@ begin
|
||||
ConvTool.HasFormFile:=DfmFilename<>'';
|
||||
ConvTool.AddUnitEvent:=@fUsedUnitsTool.AddUnitIfNeeded;
|
||||
Result:=ConvTool.Convert;
|
||||
if Result<>mrOK then exit;
|
||||
finally
|
||||
ConvTool.Free;
|
||||
end;
|
||||
// First pass to add, remove, fix and comment out units in uses sections.
|
||||
Result:=fUsedUnitsTool.ConvertUsed;
|
||||
end;
|
||||
|
||||
function TDelphiUnit.ConvertFormFile: TModalResult;
|
||||
@ -697,7 +700,8 @@ begin
|
||||
Result:=SaveCodeBufferToFile(fLFMBuffer,fLFMBuffer.Filename);
|
||||
if Result<>mrOK then exit;
|
||||
end;
|
||||
// After other changes: add, remove, fix and comment out units in uses sections.
|
||||
// Second pass to add, remove, fix and comment out units in uses sections.
|
||||
// More changes to uses section can happen during form file conversion.
|
||||
Result:=fUsedUnitsTool.ConvertUsed;
|
||||
if Result<>mrOK then exit;
|
||||
Result:=mrOK;
|
||||
|
@ -391,16 +391,20 @@ begin
|
||||
// Don't remove the unit names but add to Delphi block instead.
|
||||
for i:=0 to fUnitsToRemove.Count-1 do
|
||||
if not MoveToDelphi(fUnitsToRemove[i]) then Exit;
|
||||
fUnitsToRemove.Clear;
|
||||
// ... and don't comment the unit names either.
|
||||
for i:=0 to fUnitsToComment.Count-1 do
|
||||
if not MoveToDelphi(fUnitsToComment[i]) then Exit;
|
||||
fUnitsToComment.Clear;
|
||||
// Add replacement units to LCL block.
|
||||
for i:=0 to fUnitsToRenameKeys.Count-1 do begin
|
||||
if not MoveToDelphi(fUnitsToRenameKeys[i]) then Exit;
|
||||
LCLOnlyUnits.Add(fUnitsToRename[fUnitsToRenameKeys[i]]);
|
||||
end;
|
||||
fUnitsToRenameKeys.Clear;
|
||||
// Additional units for LCL (like Interfaces).
|
||||
LCLOnlyUnits.AddStrings(fUnitsToAddForLCL);
|
||||
fUnitsToAddForLCL.Clear;
|
||||
// Add LCL and Delphi sections for output.
|
||||
if (LclOnlyUnits.Count=0) and (DelphiOnlyUnits.Count=0) then Exit(True);
|
||||
fCTLink.ResetMainScanner;
|
||||
@ -481,9 +485,8 @@ var
|
||||
i: Integer;
|
||||
begin
|
||||
Result:=false;
|
||||
for i:=0 to fUnitsToRemove.Count-1 do begin
|
||||
DebugLn('TUsedUnits.RemoveUnits: '+fUnitsToRemove[i]);
|
||||
//fCTLink.ResetMainScanner;
|
||||
for i:=0 to fUnitsToRemove.Count-1 do
|
||||
begin
|
||||
ParseToUsesSectionEnd;
|
||||
if not fCTLink.CodeTool.RemoveUnitFromUsesSection(UsesSectionNode,
|
||||
UpperCaseStr(fUnitsToRemove[i]), fCTLink.SrcCache) then
|
||||
@ -667,17 +670,21 @@ begin
|
||||
with fCTLink do begin
|
||||
// Fix case
|
||||
if not CodeTool.ReplaceUsedUnits(fMainUsedUnits.fUnitsToFixCase, SrcCache) then exit;
|
||||
fMainUsedUnits.fUnitsToFixCase.Clear;
|
||||
if not CodeTool.ReplaceUsedUnits(fImplUsedUnits.fUnitsToFixCase, SrcCache) then exit;
|
||||
fImplUsedUnits.fUnitsToFixCase.Clear;
|
||||
// Add more units.
|
||||
with fMainUsedUnits do begin
|
||||
for i:=0 to fUnitsToAdd.Count-1 do
|
||||
if not CodeTool.AddUnitToSpecificUsesSection(
|
||||
fUsesSection, fUnitsToAdd[i], '', SrcCache) then exit;
|
||||
fUnitsToAdd.Clear;
|
||||
end;
|
||||
with fImplUsedUnits do begin
|
||||
for i:=0 to fUnitsToAdd.Count-1 do
|
||||
if not CodeTool.AddUnitToSpecificUsesSection(
|
||||
fUsesSection, fUnitsToAdd[i], '', SrcCache) then exit;
|
||||
fUnitsToAdd.Clear;
|
||||
end;
|
||||
if fIsMainFile or not Settings.SupportDelphi then begin
|
||||
// One way conversion (or main file) -> remove and rename units.
|
||||
@ -685,7 +692,9 @@ begin
|
||||
if not fImplUsedUnits.RemoveUnits then exit;
|
||||
// Rename
|
||||
if not CodeTool.ReplaceUsedUnits(fMainUsedUnits.fUnitsToRename, SrcCache) then exit;
|
||||
fMainUsedUnits.fUnitsToRename.Clear;
|
||||
if not CodeTool.ReplaceUsedUnits(fImplUsedUnits.fUnitsToRename, SrcCache) then exit;
|
||||
fImplUsedUnits.fUnitsToRename.Clear;
|
||||
end;
|
||||
if Settings.SupportDelphi then begin
|
||||
// Support Delphi. Add IFDEF blocks for units.
|
||||
@ -703,17 +712,21 @@ begin
|
||||
if not CodeTool.CommentUnitsInUsesSection(fImplUsedUnits.fUnitsToComment,
|
||||
SrcCache, CodeTool.FindImplementationUsesNode) then exit;
|
||||
if not SrcCache.Apply then exit;
|
||||
fMainUsedUnits.fUnitsToComment.Clear;
|
||||
fImplUsedUnits.fUnitsToComment.Clear;
|
||||
end;
|
||||
// Add more units meant for only LCL.
|
||||
with fMainUsedUnits do begin
|
||||
for i:=0 to fUnitsToAddForLCL.Count-1 do
|
||||
if not CodeTool.AddUnitToSpecificUsesSection(fUsesSection,
|
||||
fUnitsToAddForLCL[i], '', SrcCache) then exit;
|
||||
fUnitsToAddForLCL.Clear;
|
||||
end;
|
||||
with fImplUsedUnits do begin
|
||||
for i:=0 to fUnitsToAddForLCL.Count-1 do
|
||||
if not CodeTool.AddUnitToSpecificUsesSection(fUsesSection,
|
||||
fUnitsToAddForLCL[i], '', SrcCache) then exit;
|
||||
fUnitsToAddForLCL.Clear;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
Loading…
Reference in New Issue
Block a user