diff --git a/components/codetools/codetoolmanager.pas b/components/codetools/codetoolmanager.pas index b313ee3697..59d9887935 100644 --- a/components/codetools/codetoolmanager.pas +++ b/components/codetools/codetoolmanager.pas @@ -35,6 +35,8 @@ interface {$I codetools.inc} +{ $DEFINE CTDEBUG} + uses {$IFDEF MEM_CHECK} MemCheck, @@ -248,6 +250,8 @@ type const ResourceName: string): boolean; function RenameMainInclude(Code: TCodeBuffer; const NewFilename: string; KeepPath: boolean): boolean; + function RenameIncludeDirective(Code: TCodeBuffer; LinkIndex: integer; + const NewFilename: string; KeepPath: boolean): boolean; // Application.Createform(ClassName,VarName) statements in program source function FindCreateFormStatement(Code: TCodeBuffer; StartPos: integer; @@ -1145,18 +1149,36 @@ var OldIgnoreMissingIncludeFiles: boolean; begin Result:=false; -{$IFDEF CTDEBUG} -writeln('TCodeToolManager.RenameMainInclude A ',Code.Filename,' NewFilename=',NewFilename,' KeepPath=',KeepPath); -{$ENDIF} + {$IFDEF CTDEBUG} + writeln('TCodeToolManager.RenameMainInclude A ',Code.Filename,' NewFilename=',NewFilename,' KeepPath=',KeepPath); + {$ENDIF} if not InitCurCodeTool(Code) then exit; try - OldIgnoreMissingIncludeFiles:=FCurCodeTool.Scanner.IgnoreMissingIncludeFiles; + OldIgnoreMissingIncludeFiles:= + FCurCodeTool.Scanner.IgnoreMissingIncludeFiles; FCurCodeTool.Scanner.IgnoreMissingIncludeFiles:=true; LinkIndex:=-1; if FCurCodeTool.FindNextIncludeInInitialization(LinkIndex)=nil then exit; Result:=FCurCodeTool.RenameInclude(LinkIndex,NewFilename,KeepPath, 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 on e: Exception do Result:=HandleException(e); end; @@ -1170,9 +1192,9 @@ function TCodeToolManager.FindCreateFormStatement(Code: TCodeBuffer; var PosAtom: TAtomPosition; begin Result:=-1; -{$IFDEF CTDEBUG} -writeln('TCodeToolManager.FindCreateFormStatement A ',Code.Filename,' StartPos=',StartPos,' ',AClassName,':',AVarName); -{$ENDIF} + {$IFDEF CTDEBUG} + writeln('TCodeToolManager.FindCreateFormStatement A ',Code.Filename,' StartPos=',StartPos,' ',AClassName,':',AVarName); + {$ENDIF} if not InitCurCodeTool(Code) then exit; try Result:=FCurCodeTool.FindCreateFormStatement(StartPos,UpperCaseStr(AClassName), diff --git a/components/codetools/finddeclarationtool.pas b/components/codetools/finddeclarationtool.pas index 9e3b25ba39..bd092a227b 100644 --- a/components/codetools/finddeclarationtool.pas +++ b/components/codetools/finddeclarationtool.pas @@ -3167,6 +3167,7 @@ var CurContext:=CreateFindContext(Params); end else begin // predefined identifier not redefined + CurExprDesc:=PredefinedIdentToExprTypeDesc(@Src[CurAtom.StartPos]); CurContext:=CreateFindContext(Self,nil); end; @@ -3470,6 +3471,10 @@ function TFindDeclarationTool.ConvertNodeToExpressionType(Node: TCodeTreeNode; Params: TFindDeclarationParams): TExpressionType; var BaseContext: TFindContext; begin + {$IFDEF ShowExprEval} + writeln('[TFindDeclarationTool.ConvertNodeToExpressionType] A', + ' Node=',Node.DescAsString); + {$ENDIF} BaseContext:=FindBaseTypeOfNode(Params,Node); Node:=BaseContext.Node; if BaseContext.Tool<>Self then begin diff --git a/components/codetools/linkscanner.pas b/components/codetools/linkscanner.pas index a55e16c88d..92265563c0 100644 --- a/components/codetools/linkscanner.pas +++ b/components/codetools/linkscanner.pas @@ -1554,7 +1554,8 @@ begin AddLink(CleanedLen+1,SrcPos,Code); end else begin if MissingIncludeFile<>nil then begin - if FMissingIncludeFiles=nil then FMissingIncludeFiles.Create; + if FMissingIncludeFiles=nil then + FMissingIncludeFiles:=TMissingIncludeFiles.Create; FMissingIncludeFiles.Add(MissingIncludeFile); end; if (not IgnoreMissingIncludeFiles) then begin diff --git a/ide/main.pp b/ide/main.pp index 6dd84af6f8..b8cdbe9160 100644 --- a/ide/main.pp +++ b/ide/main.pp @@ -2459,7 +2459,7 @@ begin end; EnvironmentOptions.LastOpenDialogDir:=ExtractFilePath(NewFilename); - + // check unitname NewUnitName:=ExtractFileNameOnly(NewFilename); if NewUnitName='' then exit; @@ -2532,9 +2532,9 @@ begin exit; end; - + // 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 // changing the unitname NewResFilePath:=ExtractFilePath(ResourceCode.Filename); @@ -2556,16 +2556,18 @@ begin NewResFilename:=NewResFilePath +ExtractFileNameOnly(NewFilename)+ResourceFileExt; CodeToolBoss.SaveBufferAs(ResourceCode,NewResFilename,ResourceCode); -{$IFDEF IDE_DEBUG} -writeln('TMainIDE.ShowSaveFileAsDialog D ',ResourceCode<>nil); -writeln(' NewResFilePath="',NewResFilePath,'" NewResFilename="',NewresFilename,'"'); -if ResourceCode<>nil then writeln('*** ResourceFileName ',ResourceCode.Filename); -{$ENDIF} - end else + + {$IFDEF IDE_DEBUG} + writeln('TMainIDE.ShowSaveFileAsDialog D ',ResourceCode<>nil); + writeln(' NewResFilePath="',NewResFilePath,'" NewResFilename="',NewresFilename,'"'); + if ResourceCode<>nil then writeln('*** ResourceFileName ',ResourceCode.Filename); + {$ENDIF} + end else begin NewResFilename:=''; -{$IFDEF IDE_DEBUG} -writeln('TMainIDE.ShowSaveFileAsDialog C ',ResourceCode<>nil); -{$ENDIF} + end; + {$IFDEF IDE_DEBUG} + writeln('TMainIDE.ShowSaveFileAsDialog C ',ResourceCode<>nil); + {$ENDIF} // set new codebuffer in unitinfo and sourceeditor AnUnitInfo.Source:=NewSource; @@ -2641,9 +2643,13 @@ begin until Result<>mrRetry; // create lazarus form resource code if FormSavingOk then begin - if (sfSaveToTestDir in Flags) then begin - ResTestFilename:=ChangeFileExt(GetTestUnitFilename(AnUnitInfo), - ResourceFileExt); + if ResourceCode=nil then begin + if (sfSaveToTestDir in Flags) then + ResTestFilename:=ChangeFileExt(GetTestUnitFilename(AnUnitInfo), + ResourceFileExt) + else + ResTestFilename:=ChangeFileExt(AnUnitInfo.Filename, + ResourceFileExt); ResourceCode:=CodeToolBoss.CreateFile(ResTestFilename); FormSavingOk:=(ResourceCode<>nil); end; @@ -6237,6 +6243,9 @@ end. { ============================================================================= $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 MG: fixed inputhistory load/save