mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-24 22:19:12 +02:00
Converter: do dummy string replacement for known problematic syntax when CodeTools raised an exception. Issue #23552
git-svn-id: trunk@41967 -
This commit is contained in:
parent
09cfe454ce
commit
1cc1c541af
@ -504,6 +504,8 @@ begin
|
||||
end;
|
||||
|
||||
function TDelphiUnit.CopyAndLoadFile: TModalResult;
|
||||
var
|
||||
CodeOk, CodeFixed: Boolean;
|
||||
begin
|
||||
fOwnerConverter.fSettings.AddLogLine(Format(lisConvDelphiConvertingFile,
|
||||
[fOrigUnitFilename]));
|
||||
@ -536,8 +538,25 @@ begin
|
||||
// Fix include file names.
|
||||
Result:=FixIncludeFiles;
|
||||
if Result<>mrOK then exit;
|
||||
// Create a tool for missing units.
|
||||
fUsedUnitsTool:=TUsedUnitsTool.Create(fCTLink, fOrigUnitFilename);
|
||||
CodeFixed:=False;
|
||||
repeat
|
||||
CodeOk:=True;
|
||||
try
|
||||
// Create a tool for missing units.
|
||||
fUsedUnitsTool:=TUsedUnitsTool.Create(fCTLink, fOrigUnitFilename);
|
||||
except
|
||||
// If CodeTool's BuildTree raised exception, try dummy replacement for
|
||||
// some known problematic syntax, currently only OleVariant.type.
|
||||
if CodeFixed then
|
||||
Raise // There was a second exception -> we are doomed!
|
||||
else begin
|
||||
with fPascalBuffer do
|
||||
Source:=StringReplace(Source,'.type','.&type',[rfReplaceAll]);
|
||||
CodeOk := False;
|
||||
CodeFixed := True; // Try replacements only once
|
||||
end;
|
||||
end;
|
||||
until CodeOk;
|
||||
if fOwnerConverter is TConvertDelphiProjPack then
|
||||
with TConvertDelphiProjPack(fOwnerConverter) do begin
|
||||
fUsedUnitsTool.OnCheckPackageDependency:=@CheckPackageDep;
|
||||
|
Loading…
Reference in New Issue
Block a user