MG: fixed missing include directives

git-svn-id: trunk@1625 -
This commit is contained in:
lazarus 2002-04-22 07:16:36 +00:00
parent 526e8668fe
commit e3f266184c
4 changed files with 61 additions and 24 deletions

View File

@ -35,6 +35,8 @@ interface
{$I codetools.inc} {$I codetools.inc}
{ $DEFINE CTDEBUG}
uses uses
{$IFDEF MEM_CHECK} {$IFDEF MEM_CHECK}
MemCheck, MemCheck,
@ -248,6 +250,8 @@ type
const ResourceName: string): boolean; const ResourceName: string): boolean;
function RenameMainInclude(Code: TCodeBuffer; const NewFilename: string; function RenameMainInclude(Code: TCodeBuffer; const NewFilename: string;
KeepPath: boolean): boolean; KeepPath: boolean): boolean;
function RenameIncludeDirective(Code: TCodeBuffer; LinkIndex: integer;
const NewFilename: string; KeepPath: boolean): boolean;
// Application.Createform(ClassName,VarName) statements in program source // Application.Createform(ClassName,VarName) statements in program source
function FindCreateFormStatement(Code: TCodeBuffer; StartPos: integer; function FindCreateFormStatement(Code: TCodeBuffer; StartPos: integer;
@ -1150,13 +1154,31 @@ writeln('TCodeToolManager.RenameMainInclude A ',Code.Filename,' NewFilename=',Ne
{$ENDIF} {$ENDIF}
if not InitCurCodeTool(Code) then exit; if not InitCurCodeTool(Code) then exit;
try try
OldIgnoreMissingIncludeFiles:=FCurCodeTool.Scanner.IgnoreMissingIncludeFiles; OldIgnoreMissingIncludeFiles:=
FCurCodeTool.Scanner.IgnoreMissingIncludeFiles;
FCurCodeTool.Scanner.IgnoreMissingIncludeFiles:=true; FCurCodeTool.Scanner.IgnoreMissingIncludeFiles:=true;
LinkIndex:=-1; LinkIndex:=-1;
if FCurCodeTool.FindNextIncludeInInitialization(LinkIndex)=nil then exit; if FCurCodeTool.FindNextIncludeInInitialization(LinkIndex)=nil then exit;
Result:=FCurCodeTool.RenameInclude(LinkIndex,NewFilename,KeepPath, Result:=FCurCodeTool.RenameInclude(LinkIndex,NewFilename,KeepPath,
SourceChangeCache); SourceChangeCache);
FCurCodeTool.Scanner.IgnoreMissingIncludeFiles:=OldIgnoreMissingIncludeFiles; FCurCodeTool.Scanner.IgnoreMissingIncludeFiles:=
OldIgnoreMissingIncludeFiles;
except
on e: Exception do Result:=HandleException(e);
end;
end;
function TCodeToolManager.RenameIncludeDirective(Code: TCodeBuffer;
LinkIndex: integer; const NewFilename: string; KeepPath: boolean): boolean;
begin
Result:=false;
{$IFDEF CTDEBUG}
writeln('TCodeToolManager.RenameIncludeDirective A ',Code.Filename,' NewFilename=',NewFilename,' KeepPath=',KeepPath);
{$ENDIF}
if not InitCurCodeTool(Code) then exit;
try
Result:=FCurCodeTool.RenameInclude(LinkIndex,NewFilename,KeepPath,
SourceChangeCache);
except except
on e: Exception do Result:=HandleException(e); on e: Exception do Result:=HandleException(e);
end; end;

View File

@ -3167,6 +3167,7 @@ var
CurContext:=CreateFindContext(Params); CurContext:=CreateFindContext(Params);
end else begin end else begin
// predefined identifier not redefined // predefined identifier not redefined
CurExprDesc:=PredefinedIdentToExprTypeDesc(@Src[CurAtom.StartPos]);
CurContext:=CreateFindContext(Self,nil); CurContext:=CreateFindContext(Self,nil);
end; end;
@ -3470,6 +3471,10 @@ function TFindDeclarationTool.ConvertNodeToExpressionType(Node: TCodeTreeNode;
Params: TFindDeclarationParams): TExpressionType; Params: TFindDeclarationParams): TExpressionType;
var BaseContext: TFindContext; var BaseContext: TFindContext;
begin begin
{$IFDEF ShowExprEval}
writeln('[TFindDeclarationTool.ConvertNodeToExpressionType] A',
' Node=',Node.DescAsString);
{$ENDIF}
BaseContext:=FindBaseTypeOfNode(Params,Node); BaseContext:=FindBaseTypeOfNode(Params,Node);
Node:=BaseContext.Node; Node:=BaseContext.Node;
if BaseContext.Tool<>Self then begin if BaseContext.Tool<>Self then begin

View File

@ -1554,7 +1554,8 @@ begin
AddLink(CleanedLen+1,SrcPos,Code); AddLink(CleanedLen+1,SrcPos,Code);
end else begin end else begin
if MissingIncludeFile<>nil then begin if MissingIncludeFile<>nil then begin
if FMissingIncludeFiles=nil then FMissingIncludeFiles.Create; if FMissingIncludeFiles=nil then
FMissingIncludeFiles:=TMissingIncludeFiles.Create;
FMissingIncludeFiles.Add(MissingIncludeFile); FMissingIncludeFiles.Add(MissingIncludeFile);
end; end;
if (not IgnoreMissingIncludeFiles) then begin if (not IgnoreMissingIncludeFiles) then begin

View File

@ -2534,7 +2534,7 @@ begin
// rename Resource file // rename Resource file
if ResourceCode<>nil then begin if (ResourceCode<>nil) then begin
// the resource include line in the code will be changed later after // the resource include line in the code will be changed later after
// changing the unitname // changing the unitname
NewResFilePath:=ExtractFilePath(ResourceCode.Filename); NewResFilePath:=ExtractFilePath(ResourceCode.Filename);
@ -2556,13 +2556,15 @@ begin
NewResFilename:=NewResFilePath NewResFilename:=NewResFilePath
+ExtractFileNameOnly(NewFilename)+ResourceFileExt; +ExtractFileNameOnly(NewFilename)+ResourceFileExt;
CodeToolBoss.SaveBufferAs(ResourceCode,NewResFilename,ResourceCode); CodeToolBoss.SaveBufferAs(ResourceCode,NewResFilename,ResourceCode);
{$IFDEF IDE_DEBUG} {$IFDEF IDE_DEBUG}
writeln('TMainIDE.ShowSaveFileAsDialog D ',ResourceCode<>nil); writeln('TMainIDE.ShowSaveFileAsDialog D ',ResourceCode<>nil);
writeln(' NewResFilePath="',NewResFilePath,'" NewResFilename="',NewresFilename,'"'); writeln(' NewResFilePath="',NewResFilePath,'" NewResFilename="',NewresFilename,'"');
if ResourceCode<>nil then writeln('*** ResourceFileName ',ResourceCode.Filename); if ResourceCode<>nil then writeln('*** ResourceFileName ',ResourceCode.Filename);
{$ENDIF} {$ENDIF}
end else end else begin
NewResFilename:=''; NewResFilename:='';
end;
{$IFDEF IDE_DEBUG} {$IFDEF IDE_DEBUG}
writeln('TMainIDE.ShowSaveFileAsDialog C ',ResourceCode<>nil); writeln('TMainIDE.ShowSaveFileAsDialog C ',ResourceCode<>nil);
{$ENDIF} {$ENDIF}
@ -2641,8 +2643,12 @@ begin
until Result<>mrRetry; until Result<>mrRetry;
// create lazarus form resource code // create lazarus form resource code
if FormSavingOk then begin if FormSavingOk then begin
if (sfSaveToTestDir in Flags) then begin if ResourceCode=nil then begin
if (sfSaveToTestDir in Flags) then
ResTestFilename:=ChangeFileExt(GetTestUnitFilename(AnUnitInfo), ResTestFilename:=ChangeFileExt(GetTestUnitFilename(AnUnitInfo),
ResourceFileExt)
else
ResTestFilename:=ChangeFileExt(AnUnitInfo.Filename,
ResourceFileExt); ResourceFileExt);
ResourceCode:=CodeToolBoss.CreateFile(ResTestFilename); ResourceCode:=CodeToolBoss.CreateFile(ResTestFilename);
FormSavingOk:=(ResourceCode<>nil); FormSavingOk:=(ResourceCode<>nil);
@ -6237,6 +6243,9 @@ end.
{ ============================================================================= { =============================================================================
$Log$ $Log$
Revision 1.283 2002/04/22 07:16:34 lazarus
MG: fixed missing include directives
Revision 1.282 2002/04/21 14:30:36 lazarus Revision 1.282 2002/04/21 14:30:36 lazarus
MG: fixed inputhistory load/save MG: fixed inputhistory load/save