mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-28 21:00:43 +02:00
Converter: Call FixIncludeFiles before parsing the source.
git-svn-id: trunk@37646 -
This commit is contained in:
parent
be1c9fa2ae
commit
d91c978a4d
@ -1621,10 +1621,8 @@ end;
|
|||||||
|
|
||||||
procedure TCodeToolManager.FreeListOfPCodeXYPosition(var List: TFPList);
|
procedure TCodeToolManager.FreeListOfPCodeXYPosition(var List: TFPList);
|
||||||
begin
|
begin
|
||||||
if List<>nil then begin
|
|
||||||
CodeCache.FreeListOfPCodeXYPosition(List);
|
CodeCache.FreeListOfPCodeXYPosition(List);
|
||||||
List:=nil;
|
List:=nil;
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCodeToolManager.FreeTreeOfPCodeXYPosition(var Tree: TAVLTree);
|
procedure TCodeToolManager.FreeTreeOfPCodeXYPosition(var Tree: TAVLTree);
|
||||||
|
@ -133,6 +133,7 @@ begin
|
|||||||
fCodeTool:=CodeToolBoss.CurCodeTool;
|
fCodeTool:=CodeToolBoss.CurCodeTool;
|
||||||
fSrcCache:=CodeToolBoss.SourceChangeCache;
|
fSrcCache:=CodeToolBoss.SourceChangeCache;
|
||||||
ResetMainScanner;
|
ResetMainScanner;
|
||||||
|
fCodeTool.Scanner.IgnoreMissingIncludeFiles:=True;
|
||||||
except
|
except
|
||||||
on e: Exception do
|
on e: Exception do
|
||||||
CodeToolBoss.HandleException(e);
|
CodeToolBoss.HandleException(e);
|
||||||
@ -175,7 +176,7 @@ begin
|
|||||||
fLowerCaseRes:=True;
|
fLowerCaseRes:=True;
|
||||||
fIsConsoleApp:=False;
|
fIsConsoleApp:=False;
|
||||||
fCTLinkCreated:=True;
|
fCTLinkCreated:=True;
|
||||||
if fCTLink.CodeTool=nil then exit;
|
if Assigned(fCTLink.CodeTool) then
|
||||||
try
|
try
|
||||||
fCTLink.CodeTool.BuildTree(lsrInitializationStart);
|
fCTLink.CodeTool.BuildTree(lsrInitializationStart);
|
||||||
except
|
except
|
||||||
@ -537,7 +538,7 @@ var
|
|||||||
FuncInfo.StartPos:=xStart;
|
FuncInfo.StartPos:=xStart;
|
||||||
with fCTLink.CodeTool do begin
|
with fCTLink.CodeTool do begin
|
||||||
MoveCursorToCleanPos(xStart);
|
MoveCursorToCleanPos(xStart);
|
||||||
ReadNextAtom; // Read func name.
|
ReadNextAtom; // Read proc name.
|
||||||
ReadNextAtom; // Read first atom after proc name.
|
ReadNextAtom; // Read first atom after proc name.
|
||||||
if AtomIsChar('(') then begin
|
if AtomIsChar('(') then begin
|
||||||
// read parameter list
|
// read parameter list
|
||||||
|
@ -101,8 +101,8 @@ type
|
|||||||
function FixLfmFilenameAndLoad(ADfmFilename: string): TModalResult;
|
function FixLfmFilenameAndLoad(ADfmFilename: string): TModalResult;
|
||||||
function ConvertUnitFile: TModalResult;
|
function ConvertUnitFile: TModalResult;
|
||||||
function ConvertFormFile: TModalResult;
|
function ConvertFormFile: TModalResult;
|
||||||
function AskUnitPathFromUser: TModalResult;
|
|
||||||
function FixIncludeFiles: TModalResult;
|
function FixIncludeFiles: TModalResult;
|
||||||
|
function AskUnitPathFromUser: TModalResult;
|
||||||
protected
|
protected
|
||||||
public
|
public
|
||||||
constructor Create(AOwnerConverter: TConvertDelphiPBase; const AFilename: string;
|
constructor Create(AOwnerConverter: TConvertDelphiPBase; const AFilename: string;
|
||||||
@ -482,6 +482,9 @@ begin
|
|||||||
fCTLink:=TCodeToolLink.Create(fPascalBuffer);
|
fCTLink:=TCodeToolLink.Create(fPascalBuffer);
|
||||||
fCTLink.Settings:=fSettings;
|
fCTLink.Settings:=fSettings;
|
||||||
fCTLink.AskAboutError:=Assigned(fOwnerConverter);
|
fCTLink.AskAboutError:=Assigned(fOwnerConverter);
|
||||||
|
// Fix include file names.
|
||||||
|
Result:=FixIncludeFiles;
|
||||||
|
if Result<>mrOk then exit;
|
||||||
// Create a toold for missing units.
|
// Create a toold for missing units.
|
||||||
fUsedUnitsTool:=TUsedUnitsTool.Create(fCTLink, fOrigUnitFilename);
|
fUsedUnitsTool:=TUsedUnitsTool.Create(fCTLink, fOrigUnitFilename);
|
||||||
if Assigned(fOwnerConverter) then begin
|
if Assigned(fOwnerConverter) then begin
|
||||||
@ -574,9 +577,6 @@ begin
|
|||||||
DfmFilename:=GetDfmFileName;
|
DfmFilename:=GetDfmFileName;
|
||||||
Result:=FixLfmFilenameAndLoad(DfmFilename);
|
Result:=FixLfmFilenameAndLoad(DfmFilename);
|
||||||
if Result<>mrOk then exit;
|
if Result<>mrOk then exit;
|
||||||
// Fix include file names.
|
|
||||||
Result:=FixIncludeFiles;
|
|
||||||
if Result<>mrOk then exit;
|
|
||||||
if fSettings.UnitsReplaceMode<>rlDisabled then begin
|
if fSettings.UnitsReplaceMode<>rlDisabled then begin
|
||||||
// Find and prepare the missing units. Don't replace yet.
|
// Find and prepare the missing units. Don't replace yet.
|
||||||
Result:=fUsedUnitsTool.Prepare;
|
Result:=fUsedUnitsTool.Prepare;
|
||||||
@ -686,6 +686,7 @@ end;
|
|||||||
function TConvertDelphiUnit.FixIncludeFiles: TModalResult;
|
function TConvertDelphiUnit.FixIncludeFiles: TModalResult;
|
||||||
// fix include filenames
|
// fix include filenames
|
||||||
var
|
var
|
||||||
|
FoundIncludeFiles: TStrings;
|
||||||
MissingIncludeFilesCodeXYPos: TFPList;
|
MissingIncludeFilesCodeXYPos: TFPList;
|
||||||
CodePos: PCodeXYPosition;
|
CodePos: PCodeXYPosition;
|
||||||
Msg: string;
|
Msg: string;
|
||||||
@ -693,11 +694,12 @@ var
|
|||||||
OldChange: Boolean;
|
OldChange: Boolean;
|
||||||
begin
|
begin
|
||||||
Result:=mrOk;
|
Result:=mrOk;
|
||||||
|
MissingIncludeFilesCodeXYPos:=Nil;
|
||||||
OldChange:=LazarusIDE.OpenEditorsOnCodeToolChange;
|
OldChange:=LazarusIDE.OpenEditorsOnCodeToolChange;
|
||||||
LazarusIDE.OpenEditorsOnCodeToolChange:=False;
|
LazarusIDE.OpenEditorsOnCodeToolChange:=False;
|
||||||
try
|
try
|
||||||
if not CodeToolBoss.FixIncludeFilenames(fPascalBuffer,true,MissingIncludeFilesCodeXYPos)
|
if not fCodeTool.FixIncludeFilenames(fCode,fSrcCache,FoundIncludeFiles,
|
||||||
then begin
|
MissingIncludeFilesCodeXYPos) then begin
|
||||||
if MissingIncludeFilesCodeXYPos<>nil then begin
|
if MissingIncludeFilesCodeXYPos<>nil then begin
|
||||||
for i:=0 to MissingIncludeFilesCodeXYPos.Count-1 do begin
|
for i:=0 to MissingIncludeFilesCodeXYPos.Count-1 do begin
|
||||||
CodePos:=PCodeXYPosition(MissingIncludeFilesCodeXYPos[i]);
|
CodePos:=PCodeXYPosition(MissingIncludeFilesCodeXYPos[i]);
|
||||||
@ -710,10 +712,9 @@ begin
|
|||||||
[CodeToolBoss.ErrorMessage]), '', -1);
|
[CodeToolBoss.ErrorMessage]), '', -1);
|
||||||
Application.ProcessMessages;
|
Application.ProcessMessages;
|
||||||
Result:=mrCancel;
|
Result:=mrCancel;
|
||||||
exit;
|
|
||||||
end;
|
end;
|
||||||
finally
|
finally
|
||||||
CodeToolBoss.FreeListOfPCodeXYPosition(MissingIncludeFilesCodeXYPos);
|
CodeCache.FreeListOfPCodeXYPosition(MissingIncludeFilesCodeXYPos);
|
||||||
LazarusIDE.OpenEditorsOnCodeToolChange:=OldChange;
|
LazarusIDE.OpenEditorsOnCodeToolChange:=OldChange;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -1601,8 +1602,8 @@ begin
|
|||||||
ConvUnits.Add(Converter);
|
ConvUnits.Add(Converter);
|
||||||
Result:=Converter.CopyAndLoadFile;
|
Result:=Converter.CopyAndLoadFile;
|
||||||
if Result<>mrOK then exit;
|
if Result<>mrOK then exit;
|
||||||
Result:=Converter.CheckFailed(Result);
|
//Result:=Converter.CheckFailed(Result);
|
||||||
if Result<>mrOK then Break;
|
//if Result<>mrOK then Break;
|
||||||
Result:=Converter.ConvertUnitFile;
|
Result:=Converter.ConvertUnitFile;
|
||||||
if Result<>mrOK then exit;
|
if Result<>mrOK then exit;
|
||||||
Result:=Converter.CheckFailed(Result);
|
Result:=Converter.CheckFailed(Result);
|
||||||
|
Loading…
Reference in New Issue
Block a user