Converter: Call FixIncludeFiles before parsing the source.

git-svn-id: trunk@37646 -
This commit is contained in:
juha 2012-06-14 17:51:25 +00:00
parent be1c9fa2ae
commit d91c978a4d
3 changed files with 22 additions and 22 deletions

View File

@ -1621,10 +1621,8 @@ end;
procedure TCodeToolManager.FreeListOfPCodeXYPosition(var List: TFPList);
begin
if List<>nil then begin
CodeCache.FreeListOfPCodeXYPosition(List);
List:=nil;
end;
CodeCache.FreeListOfPCodeXYPosition(List);
List:=nil;
end;
procedure TCodeToolManager.FreeTreeOfPCodeXYPosition(var Tree: TAVLTree);

View File

@ -133,6 +133,7 @@ begin
fCodeTool:=CodeToolBoss.CurCodeTool;
fSrcCache:=CodeToolBoss.SourceChangeCache;
ResetMainScanner;
fCodeTool.Scanner.IgnoreMissingIncludeFiles:=True;
except
on e: Exception do
CodeToolBoss.HandleException(e);
@ -175,13 +176,13 @@ begin
fLowerCaseRes:=True;
fIsConsoleApp:=False;
fCTLinkCreated:=True;
if fCTLink.CodeTool=nil then exit;
try
fCTLink.CodeTool.BuildTree(lsrInitializationStart);
except
on e: Exception do
CodeToolBoss.HandleException(e);
end;
if Assigned(fCTLink.CodeTool) then
try
fCTLink.CodeTool.BuildTree(lsrInitializationStart);
except
on e: Exception do
CodeToolBoss.HandleException(e);
end;
end;
constructor TConvDelphiCodeTool.Create(ACTLink: TCodeToolLink);
@ -537,7 +538,7 @@ var
FuncInfo.StartPos:=xStart;
with fCTLink.CodeTool do begin
MoveCursorToCleanPos(xStart);
ReadNextAtom; // Read func name.
ReadNextAtom; // Read proc name.
ReadNextAtom; // Read first atom after proc name.
if AtomIsChar('(') then begin
// read parameter list

View File

@ -101,8 +101,8 @@ type
function FixLfmFilenameAndLoad(ADfmFilename: string): TModalResult;
function ConvertUnitFile: TModalResult;
function ConvertFormFile: TModalResult;
function AskUnitPathFromUser: TModalResult;
function FixIncludeFiles: TModalResult;
function AskUnitPathFromUser: TModalResult;
protected
public
constructor Create(AOwnerConverter: TConvertDelphiPBase; const AFilename: string;
@ -482,6 +482,9 @@ begin
fCTLink:=TCodeToolLink.Create(fPascalBuffer);
fCTLink.Settings:=fSettings;
fCTLink.AskAboutError:=Assigned(fOwnerConverter);
// Fix include file names.
Result:=FixIncludeFiles;
if Result<>mrOk then exit;
// Create a toold for missing units.
fUsedUnitsTool:=TUsedUnitsTool.Create(fCTLink, fOrigUnitFilename);
if Assigned(fOwnerConverter) then begin
@ -574,9 +577,6 @@ begin
DfmFilename:=GetDfmFileName;
Result:=FixLfmFilenameAndLoad(DfmFilename);
if Result<>mrOk then exit;
// Fix include file names.
Result:=FixIncludeFiles;
if Result<>mrOk then exit;
if fSettings.UnitsReplaceMode<>rlDisabled then begin
// Find and prepare the missing units. Don't replace yet.
Result:=fUsedUnitsTool.Prepare;
@ -686,6 +686,7 @@ end;
function TConvertDelphiUnit.FixIncludeFiles: TModalResult;
// fix include filenames
var
FoundIncludeFiles: TStrings;
MissingIncludeFilesCodeXYPos: TFPList;
CodePos: PCodeXYPosition;
Msg: string;
@ -693,11 +694,12 @@ var
OldChange: Boolean;
begin
Result:=mrOk;
MissingIncludeFilesCodeXYPos:=Nil;
OldChange:=LazarusIDE.OpenEditorsOnCodeToolChange;
LazarusIDE.OpenEditorsOnCodeToolChange:=False;
try
if not CodeToolBoss.FixIncludeFilenames(fPascalBuffer,true,MissingIncludeFilesCodeXYPos)
then begin
if not fCodeTool.FixIncludeFilenames(fCode,fSrcCache,FoundIncludeFiles,
MissingIncludeFilesCodeXYPos) then begin
if MissingIncludeFilesCodeXYPos<>nil then begin
for i:=0 to MissingIncludeFilesCodeXYPos.Count-1 do begin
CodePos:=PCodeXYPosition(MissingIncludeFilesCodeXYPos[i]);
@ -710,10 +712,9 @@ begin
[CodeToolBoss.ErrorMessage]), '', -1);
Application.ProcessMessages;
Result:=mrCancel;
exit;
end;
finally
CodeToolBoss.FreeListOfPCodeXYPosition(MissingIncludeFilesCodeXYPos);
CodeCache.FreeListOfPCodeXYPosition(MissingIncludeFilesCodeXYPos);
LazarusIDE.OpenEditorsOnCodeToolChange:=OldChange;
end;
end;
@ -1601,8 +1602,8 @@ begin
ConvUnits.Add(Converter);
Result:=Converter.CopyAndLoadFile;
if Result<>mrOK then exit;
Result:=Converter.CheckFailed(Result);
if Result<>mrOK then Break;
//Result:=Converter.CheckFailed(Result);
//if Result<>mrOK then Break;
Result:=Converter.ConvertUnitFile;
if Result<>mrOK then exit;
Result:=Converter.CheckFailed(Result);