From 6ebaacbba1819ccf44418e0f0567cdf250d6ac3f Mon Sep 17 00:00:00 2001 From: mattias Date: Tue, 28 Sep 2010 10:51:08 +0000 Subject: [PATCH] codetools: clean up and debugging git-svn-id: trunk@27498 - --- components/codetools/basiccodetools.pas | 4 +- components/codetools/codecache.pas | 2 +- components/codetools/codecompletiontool.pas | 4 +- components/codetools/codetemplatestool.pas | 2 +- components/codetools/codetoolmanager.pas | 2 +- components/codetools/codetools.lpk | 2 +- components/codetools/codetoolscfgscript.pas | 198 +++++++++++++++--- components/codetools/directorycacher.pas | 30 +-- components/codetools/finddeclarationtool.pas | 4 +- components/codetools/h2pastool.pas | 3 +- components/codetools/lfmtrees.pas | 3 +- components/codetools/multikeywordlisttool.pas | 3 +- components/codetools/stdcodetools.pas | 4 +- 13 files changed, 204 insertions(+), 57 deletions(-) diff --git a/components/codetools/basiccodetools.pas b/components/codetools/basiccodetools.pas index af9835ff56..7ad2e12826 100644 --- a/components/codetools/basiccodetools.pas +++ b/components/codetools/basiccodetools.pas @@ -93,7 +93,7 @@ function IsValidIdentPair(const NamePair: string; // line/code ends procedure GetLineStartEndAtPosition(const Source:string; Position:integer; - var LineStart,LineEnd:integer); + out LineStart,LineEnd:integer); function GetLineStartPosition(const Source:string; Position:integer): integer; function LineEndCount(const Txt: string): integer; inline; function LineEndCount(const Txt: string; out LengthOfLastLine:integer): integer; inline; @@ -1337,7 +1337,7 @@ begin end; procedure GetLineStartEndAtPosition(const Source:string; Position:integer; - var LineStart,LineEnd:integer); + out LineStart,LineEnd:integer); begin LineStart:=Position; while (LineStart>1) and (not (Source[LineStart-1] in [#10,#13])) do diff --git a/components/codetools/codecache.pas b/components/codetools/codecache.pas index a8f228a90d..e570f5e938 100644 --- a/components/codetools/codecache.pas +++ b/components/codetools/codecache.pas @@ -38,7 +38,7 @@ uses {$IFDEF MEM_CHECK} MemCheck, {$ENDIF} - Math, Classes, SysUtils, SourceLog, LinkScanner, FileProcs, + Classes, SysUtils, SourceLog, LinkScanner, FileProcs, Avl_Tree, Laz_XMLCfg; const diff --git a/components/codetools/codecompletiontool.pas b/components/codetools/codecompletiontool.pas index 7673b60128..2ed8dd98cf 100644 --- a/components/codetools/codecompletiontool.pas +++ b/components/codetools/codecompletiontool.pas @@ -200,7 +200,7 @@ type SourceChangeCache: TSourceChangeCache): boolean; function CompleteEventAssignment(CleanCursorPos, OldTopLine: integer; CursorNode: TCodeTreeNode; - var IsEventAssignment: boolean; + out IsEventAssignment: boolean; var NewPos: TCodeXYPosition; var NewTopLine: integer; SourceChangeCache: TSourceChangeCache): boolean; function CompleteLocalVariableForIn(CleanCursorPos, @@ -1392,7 +1392,7 @@ end; function TCodeCompletionCodeTool.CompleteEventAssignment(CleanCursorPos, OldTopLine: integer; CursorNode: TCodeTreeNode; - var IsEventAssignment: boolean; + out IsEventAssignment: boolean; var NewPos: TCodeXYPosition; var NewTopLine: integer; SourceChangeCache: TSourceChangeCache): boolean; var diff --git a/components/codetools/codetemplatestool.pas b/components/codetools/codetemplatestool.pas index 32e221f88c..0b86192051 100644 --- a/components/codetools/codetemplatestool.pas +++ b/components/codetools/codetemplatestool.pas @@ -37,7 +37,7 @@ uses MemCheck, {$ENDIF} Classes, SysUtils, FileProcs, CodeTree, CodeAtom, KeywordFuncLists, - BasicCodeTools, LinkScanner, AVL_Tree, SourceChanger, + LinkScanner, AVL_Tree, SourceChanger, CustomCodeTool, PascalParserTool, CodeToolsStructs, StdCodeTools; type diff --git a/components/codetools/codetoolmanager.pas b/components/codetools/codetoolmanager.pas index adddafe322..164f52b46f 100644 --- a/components/codetools/codetoolmanager.pas +++ b/components/codetools/codetoolmanager.pas @@ -46,7 +46,7 @@ uses FindDeclarationCache, DirectoryCacher, AVL_Tree, LFMTrees, DirectivesTree, PascalParserTool, CodeToolsConfig, CustomCodeTool, FindDeclarationTool, IdentCompletionTool, StdCodeTools, ResourceCodeTool, CodeToolsStructs, - CodeTemplatesTool, ExtractProcTool, PascalReaderTool; + CodeTemplatesTool, ExtractProcTool; type TCodeToolManager = class; diff --git a/components/codetools/codetools.lpk b/components/codetools/codetools.lpk index d989585f76..85aa242ca3 100644 --- a/components/codetools/codetools.lpk +++ b/components/codetools/codetools.lpk @@ -276,7 +276,7 @@ - + diff --git a/components/codetools/codetoolscfgscript.pas b/components/codetools/codetoolscfgscript.pas index f360358d47..43f05971a8 100644 --- a/components/codetools/codetoolscfgscript.pas +++ b/components/codetools/codetoolscfgscript.pas @@ -41,6 +41,7 @@ unit CodeToolsCfgScript; {$inline on} {off $Define VerboseCTCfgScript} +{off $DEFINE CheckCTCfgVars} interface @@ -179,6 +180,9 @@ type procedure Delete(Index: integer); function TopItem: PCTCfgScriptStackItem; function TopItemOperand: PCTCfgScriptVariable; + {$IFDEF CheckCTCfgVars} + procedure CheckOperands; + {$ENDIF} end; { TCTCfgScriptError } @@ -208,8 +212,8 @@ type procedure PushStringConstant; procedure RunStatement(Skip: boolean); procedure RunBegin(Skip: boolean); - procedure RunIf(Skip: boolean); - procedure RunUndefine(Skip: boolean); + procedure RunIf({%H-}Skip: boolean); + procedure RunUndefine({%H-}Skip: boolean); procedure RunAssignment(Skip: boolean); function RunExpression: boolean; // if true the stack top has an operand function ExecuteStack(MaxLevel: integer): boolean; @@ -266,6 +270,7 @@ function CTCSVariableIsFalse(const V: PCTCfgScriptVariable): boolean; function CTCSStringToNumber(P: PChar; out Number: int64): boolean; function AtomToCTCfgOperator(p: PChar): TCTCfgScriptOperator; +procedure CheckCTCSVariable(const V: PCTCfgScriptVariable); function dbgs(const t: TCTCfgScriptStackItemType): string; overload; function dbgs(const t: TCTCSValueType): string; overload; function dbgs(const t: TCTCfgScriptOperator): string; overload; @@ -291,7 +296,7 @@ begin and (CompareIdentifierPtrs(PChar(OldName),AtomStart)=0) then begin SrcPos:=PtrUInt(AtomStart-PChar(Src))+1; - Src:=copy(Src,1,SrcPos-1)+NewName+copy(Src,SrcPos+length(OldName),length(Src)); + Src:=copy(Src,1,SrcPos-1)+NewName+copy(Src,SrcPos+PtrUInt(length(OldName)),length(Src)); p:=@Src[SrcPos]+length(NewName); end; until false; @@ -303,6 +308,10 @@ var v1: PCTCfgScriptVariable absolute Var1; v2: PCTCfgScriptVariable absolute Var2; begin + {$IFDEF CheckCTCfgVars} + CheckCTCSVariable(v1); + CheckCTCSVariable(v2); + {$ENDIF} Result:=CompareIdentifiers(v1^.Name,v2^.Name); end; @@ -311,11 +320,16 @@ var n: PChar absolute Name; v: PCTCfgScriptVariable absolute aVar; begin + {$IFDEF CheckCTCfgVars}CheckCTCSVariable(v);{$ENDIF} Result:=CompareIdentifiers(n,v^.Name); end; function AreCTCSVariablesEqual(const V1, V2: PCTCfgScriptVariable): Boolean; begin + {$IFDEF CheckCTCfgVars} + CheckCTCSVariable(v1); + CheckCTCSVariable(v2); + {$ENDIF} Result:=false; case V1^.ValueType of ctcsvNone: @@ -325,9 +339,9 @@ begin ctcsvNone: exit; ctcsvString: if (V1^.StrLen<>V2^.StrLen) - or ((V1^.StrStart<>nil) - and (not CompareMem(V1^.StrStart,V2^.StrStart,V1^.StrLen))) - then exit; + or ((V1^.StrStart<>nil) + and (not CompareMem(V1^.StrStart,V2^.StrStart,V1^.StrLen))) + then exit; ctcsvNumber: if not CTCSNumberEqualsString(V2^.Number,V1^.StrStart) then exit; end; @@ -346,6 +360,10 @@ end; function AreCTCSVariablesExactEqual(const V1, V2: PCTCfgScriptVariable ): Boolean; begin + {$IFDEF CheckCTCfgVars} + CheckCTCSVariable(v1); + CheckCTCSVariable(v2); + {$ENDIF} Result:=false; if V1^.ValueType<>V2^.ValueType then exit; case V1^.ValueType of @@ -415,6 +433,10 @@ var V1: PChar; V2: PChar; begin + {$IFDEF CheckCTCfgVars} + CheckCTCSVariable(Left); + CheckCTCSVariable(Right); + {$ENDIF} Result:=false; Equal:=false; LeftIsLowerThanRight:=false; @@ -485,7 +507,10 @@ end; function NewCTCSVariable: PCTCfgScriptVariable; begin New(Result); - FillByte(Result^,SizeOf(Result),0); + FillByte(Result^,SizeOf(TCTCfgScriptVariable),0); + {$IFDEF CheckCTCfgVars} + CheckCTCSVariable(Result); + {$ENDIF} end; function NewCTCSVariable(CloneName: PChar): PCTCfgScriptVariable; @@ -499,21 +524,33 @@ begin System.Move(CloneName^,Result^.Name^,l); Result^.Name[l]:=#0; end; + {$IFDEF CheckCTCfgVars} + CheckCTCSVariable(Result); + {$ENDIF} end; function CloneCTCSVariable(const V: PCTCfgScriptVariable): PCTCfgScriptVariable; var l: LongInt; begin + {$IFDEF CheckCTCfgVars} + CheckCTCSVariable(v); + {$ENDIF} Result:=NewCTCSVariable(V^.Name); + {$IFDEF CheckCTCfgVars} + CheckCTCSVariable(Result); + {$ENDIF} Result^.ValueType:=V^.ValueType; + {$IFDEF CheckCTCfgVars} + CheckCTCSVariable(Result); + {$ENDIF} case V^.ValueType of ctcsvNone: ; ctcsvString: begin l:=V^.StrLen; - Result^.StrLen:=l; if l>0 then begin + Result^.StrLen:=l; Result^.StrStart:=GetMem(l+1); System.Move(V^.StrStart^,Result^.StrStart^,l); Result^.StrStart[l]:=#0; @@ -522,12 +559,19 @@ begin ctcsvNumber: Result^.Number:=V^.Number; end; + {$IFDEF CheckCTCfgVars} + CheckCTCSVariable(Result); + {$ENDIF} end; procedure SetCTCSVariableValue(const Src, Dest: PCTCfgScriptVariable); var l: LongInt; begin + {$IFDEF CheckCTCfgVars} + CheckCTCSVariable(Src); + CheckCTCSVariable(Dest); + {$ENDIF} if Src=Dest then exit; case Src^.ValueType of ctcsvNone: @@ -563,10 +607,17 @@ begin Dest^.Number:=Src^.Number; end; end; + {$IFDEF CheckCTCfgVars} + CheckCTCSVariable(Src); + CheckCTCSVariable(Dest); + {$ENDIF} end; procedure FreeCTCSVariable(var V: PCTCfgScriptVariable); begin + {$IFDEF CheckCTCfgVars} + CheckCTCSVariable(v); + {$ENDIF} ClearCTCSVariable(V); ReAllocMem(V^.Name,0); Dispose(V); @@ -574,15 +625,24 @@ end; procedure ClearCTCSVariable(const V: PCTCfgScriptVariable); begin + {$IFDEF CheckCTCfgVars} + CheckCTCSVariable(v); + {$ENDIF} if V^.ValueType=ctcsvString then ReAllocMem(V^.StrStart,0); V^.ValueType:=ctcsvNone; + {$IFDEF CheckCTCfgVars} + CheckCTCSVariable(v); + {$ENDIF} end; procedure MakeCTCSVariableString(const V: PCTCfgScriptVariable); var s: String; begin + {$IFDEF CheckCTCfgVars} + CheckCTCSVariable(V); + {$ENDIF} case V^.ValueType of ctcsvNone: begin @@ -600,12 +660,18 @@ begin V^.ValueType:=ctcsvString; end; end; + {$IFDEF CheckCTCfgVars} + CheckCTCSVariable(V); + {$ENDIF} end; procedure MakeCTCSVariableInt64(const V: PCTCfgScriptVariable); var i: Int64; begin + {$IFDEF CheckCTCfgVars} + CheckCTCSVariable(V); + {$ENDIF} case V^.ValueType of ctcsvNone: begin @@ -614,18 +680,28 @@ begin end; ctcsvString: begin - i:=StrToInt64Def(V^.StrStart,0); - V^.Number:=i; + if V^.StrStart<>nil then begin + i:=StrToInt64Def(V^.StrStart,0); + FreeMem(V^.StrStart); + V^.Number:=i; + end else + V^.Number:=0; V^.ValueType:=ctcsvNumber; end; ctcsvNumber: ; end; + {$IFDEF CheckCTCfgVars} + CheckCTCSVariable(V); + {$ENDIF} end; procedure MakeCTCSVariableInteger(const V: PCTCfgScriptVariable); var i: integer; begin + {$IFDEF CheckCTCfgVars} + CheckCTCSVariable(V); + {$ENDIF} case V^.ValueType of ctcsvNone: begin @@ -634,12 +710,19 @@ begin end; ctcsvString: begin - i:=StrToIntDef(V^.StrStart,0); - V^.Number:=i; + if V^.StrStart<>nil then begin + i:=StrToIntDef(V^.StrStart,0); + FreeMem(V^.StrStart); + V^.Number:=i; + end else + V^.Number:=0; V^.ValueType:=ctcsvNumber; end; ctcsvNumber: ; end; + {$IFDEF CheckCTCfgVars} + CheckCTCSVariable(V); + {$ENDIF} end; procedure AddCTCSVariables(const AddVar, SumVar: PCTCfgScriptVariable); @@ -651,6 +734,10 @@ var OldLen: LongInt; s: String; begin + {$IFDEF CheckCTCfgVars} + CheckCTCSVariable(AddVar); + CheckCTCSVariable(SumVar); + {$ENDIF} case SumVar^.ValueType of ctcsvNone: SetCTCSVariableValue(AddVar,SumVar); @@ -682,7 +769,7 @@ begin ; ctcsvString: begin - // convert to string and append + // convert SumVar from number to string and append s:=IntToStr(SumVar^.Number); SumVar^.ValueType:=ctcsvString; SumVar^.StrLen:=length(s)+AddVar^.StrLen; @@ -700,6 +787,10 @@ begin end; end; end; + {$IFDEF CheckCTCfgVars} + CheckCTCSVariable(AddVar); + CheckCTCSVariable(SumVar); + {$ENDIF} end; function CTCSNumberEqualsString(const Number: int64; const P: PChar): boolean; @@ -849,6 +940,30 @@ begin end; end; +procedure CheckCTCSVariable(const V: PCTCfgScriptVariable); +begin + if V=nil then + RaiseCatchableException(''); + if (V^.Name<>nil) and (strlen(V^.Name)>255) then + RaiseCatchableException(''); + case V^.ValueType of + ctcsvNone: ; + ctcsvString: + begin + if V^.StrLen=0 then begin + if V^.StrStart<>nil then + RaiseCatchableException(''); + end else begin + if V^.StrStart=nil then + RaiseCatchableException(''); + if strlen(V^.StrStart)<>V^.StrLen then + RaiseCatchableException(''); + end; + end; + ctcsvNumber: ; + end; +end; + function dbgs(const t: TCTCfgScriptStackItemType): string; begin Result:=GetEnumName(typeinfo(t),ord(t)); @@ -876,9 +991,10 @@ begin begin Result:=Result+'string='; l:=length(Result); - SetLength(Result,l+V^.StrLen); - if V^.StrLen>0 then + if V^.StrLen>0 then begin + SetLength(Result,l+V^.StrLen); System.Move(V^.StrStart^,Result[l+1],V^.StrLen); + end; end; ctcsvNumber: Result:=Result+'int64='+IntToStr(V^.Number); @@ -887,6 +1003,9 @@ end; function GetCTCSVariableAsString(const V: PCTCfgScriptVariable): string; begin + {$IFDEF CheckCTCfgVars} + CheckCTCSVariable(V); + {$ENDIF} case V^.ValueType of ctcsvNone: Result:=''; ctcsvString: @@ -905,6 +1024,9 @@ procedure SetCTCSVariableAsString(const V: PCTCfgScriptVariable; const s: string var l: Integer; begin + {$IFDEF CheckCTCfgVars} + CheckCTCSVariable(v); + {$ENDIF} if V^.ValueType<>ctcsvString then begin V^.ValueType:=ctcsvString; V^.StrLen:=0; @@ -917,15 +1039,24 @@ begin System.Move(s[1],V^.StrStart^,l+1); // +1 for the #0 end else ReAllocMem(V^.StrStart,0); + {$IFDEF CheckCTCfgVars} + CheckCTCSVariable(v); + {$ENDIF} end; procedure SetCTCSVariableAsNumber(const V: PCTCfgScriptVariable; const i: int64 ); begin + {$IFDEF CheckCTCfgVars} + CheckCTCSVariable(v); + {$ENDIF} if (V^.ValueType=ctcsvString) and (V^.StrStart<>nil) then Freemem(V^.StrStart); V^.ValueType:=ctcsvNumber; V^.Number:=i; + {$IFDEF CheckCTCfgVars} + CheckCTCSVariable(v); + {$ENDIF} end; { TCTCfgScriptVariables } @@ -1016,6 +1147,7 @@ var Item: PCTCfgScriptVariable; NewItem: PCTCfgScriptVariable; begin + if Self=Source then exit; Clear; Node:=Source.FItems.FindLowest; while Node<>nil do begin @@ -1104,14 +1236,10 @@ begin V:=GetVariable(Name,true); if Value='' then ClearCTCSVariable(V) - else begin - try - i:=StrToInt64(Value); - SetCTCSVariableAsNumber(V,i); - except - SetCTCSVariableAsString(V,Value); - end; - end; + else if TryStrToInt64(Value,i) then + SetCTCSVariableAsNumber(V,i) + else + SetCTCSVariableAsString(V,Value); end; function TCTCfgScriptVariables.IsDefined(Name: PChar): boolean; @@ -1422,7 +1550,7 @@ begin ReadRawNextPascalAtom(Src,AtomStart); FStack.Push(ctcssRoundBracketOpen,AtomStart); - FillByte(Value,SizeOf(Value),0); + FillByte(Value{%H-},SizeOf(Value),0); if RunExpression then SetCTCSVariableValue(FStack.TopItemOperand,@Value); if AtomStart^<>')' then begin @@ -1582,8 +1710,9 @@ begin Item^.Operand.ValueType:=ctcsvString; l:=Src-AtomStart; Item^.Operand.StrLen:=l; - Item^.Operand.StrStart:=GetMem(l); + Item^.Operand.StrStart:=GetMem(l+1); System.Move(AtomStart^,Item^.Operand.StrStart^,l); + Item^.Operand.StrStart[l]:=#0; end; ExecuteStack(1); end; @@ -2308,6 +2437,9 @@ begin Item^.Typ:=Typ; Item^.StartPos:=StartPos; TopTyp:=Typ; + {$IFDEF CheckCTCfgVars} + CheckOperands; + {$ENDIF} end; procedure TCTCfgScriptStack.Pop(Count: integer); @@ -2334,6 +2466,9 @@ begin TopTyp:=ctcssNone; dec(Count); end; + {$IFDEF CheckCTCfgVars} + CheckOperands; + {$ENDIF} end; procedure TCTCfgScriptStack.Delete(Index: integer); @@ -2352,6 +2487,9 @@ begin FillByte(Item^.Operand,SizeOf(Item^.Operand),0); end; dec(Top); + {$IFDEF CheckCTCfgVars} + CheckOperands; + {$ENDIF} end; function TCTCfgScriptStack.TopItem: PCTCfgScriptStackItem; @@ -2370,6 +2508,16 @@ begin Result:=@Items[Top].Operand; end; +{$IFDEF CheckCTCfgVars} +procedure TCTCfgScriptStack.CheckOperands; +var + i: Integer; +begin + for i:=0 to Top do + CheckCTCSVariable(@Items[Top].Operand); +end; +{$ENDIF} + { TCTCfgScriptError } constructor TCTCfgScriptError.Create(const aMsg: string; anErrorPos: PChar); diff --git a/components/codetools/directorycacher.pas b/components/codetools/directorycacher.pas index b5b4559293..216b71f492 100644 --- a/components/codetools/directorycacher.pas +++ b/components/codetools/directorycacher.pas @@ -84,9 +84,9 @@ const type - { TUnitNameLink } + { TUnitFileNameLink } - TUnitNameLink = class + TUnitFileNameLink = class public Unit_Name: string; Filename: string; @@ -125,7 +125,7 @@ type FPool: TCTDirectoryCachePool; FRefCount: integer; FStrings: array[TCTDirCacheString] of TCTDirCacheStringRecord; - FUnitLinksTree: TAVLTree; // tree of TUnitNameLink + FUnitLinksTree: TAVLTree; // tree of TUnitFileNameLink FUnitLinksTreeTimeStamp: cardinal; FListing: TCTDirectoryListing; FUnitSources: array[TCTDirectoryUnitSources] of TCTDirCacheUnitSrcRecord; @@ -233,7 +233,7 @@ function ComparePCharCaseSensitive(Data1, Data2: Pointer): integer; // unit links function SearchUnitInUnitLinks(const UnitLinks, TheUnitName: string; var UnitLinkStart, UnitLinkEnd: integer; out Filename: string): boolean; -function CreateUnitLinksTree(const UnitLinks: string): TAVLTree; // tree of TUnitNameLink +function CreateUnitLinksTree(const UnitLinks: string): TAVLTree; // tree of TUnitFileNameLink function CompareUnitLinkNodes(NodeData1, NodeData2: Pointer): integer; function CompareUnitNameWithUnitLinkNode(AUnitName: Pointer; NodeData: pointer): integer; @@ -396,7 +396,7 @@ var UnitLinkEnd: Integer; TheUnitName: String; Filename: String; - NewNode: TUnitNameLink; + NewNode: TUnitFileNameLink; begin UnitLinksTree:=TAVLTree.Create(@CompareUnitLinkNodes); UnitLinkStart:=1; @@ -419,7 +419,7 @@ begin inc(UnitLinkEnd); if UnitLinkEnd>UnitLinkStart then begin Filename:=copy(UnitLinks,UnitLinkStart,UnitLinkEnd-UnitLinkStart); - NewNode:=TUnitNameLink.Create; + NewNode:=TUnitFileNameLink.Create; NewNode.Unit_Name:=TheUnitName; NewNode.Filename:=Filename; UnitLinksTree.Add(NewNode); @@ -438,17 +438,17 @@ begin end; function CompareUnitLinkNodes(NodeData1, NodeData2: pointer): integer; -var Link1, Link2: TUnitNameLink; +var Link1, Link2: TUnitFileNameLink; begin - Link1:=TUnitNameLink(NodeData1); - Link2:=TUnitNameLink(NodeData2); + Link1:=TUnitFileNameLink(NodeData1); + Link2:=TUnitFileNameLink(NodeData2); Result:=CompareText(Link1.Unit_Name,Link2.Unit_Name); end; function CompareUnitNameWithUnitLinkNode(AUnitName: Pointer; NodeData: pointer): integer; begin - Result:=CompareText(String(AUnitName),TUnitNameLink(NodeData).Unit_Name); + Result:=CompareText(String(AUnitName),TUnitFileNameLink(NodeData).Unit_Name); end; { TCTDirectoryCache } @@ -664,7 +664,7 @@ begin +SizeOf(TAVLTreeNode)*PtrUInt(FUnitLinksTree.Count); Node:=FUnitLinksTree.FindLowest; while Node<>nil do begin - inc(m,TUnitNameLink(Node.Data).CalcMemSize); + inc(m,TUnitFileNameLink(Node.Data).CalcMemSize); Node:=FUnitLinksTree.FindSuccessor(Node); end; Stats.Add('TCTDirectoryCache.FUnitLinksTree',m); @@ -690,7 +690,7 @@ end; function TCTDirectoryCache.FindUnitLink(const AUnitName: string): string; var Node: TAVLTreeNode; - Link: TUnitNameLink; + Link: TUnitFileNameLink; AliasFilename: String; pe: TCTPascalExtType; begin @@ -703,7 +703,7 @@ begin Node:=FUnitLinksTree.FindKey(Pointer(AUnitName), @CompareUnitNameWithUnitLinkNode); if Node<>nil then begin - Link:=TUnitNameLink(Node.Data); + Link:=TUnitFileNameLink(Node.Data); Result:=Link.Filename; if FileExistsCached(Result) then begin exit; @@ -1383,9 +1383,9 @@ begin +PtrUInt(NamesLength); end; -{ TUnitNameLink } +{ TUnitFileNameLink } -function TUnitNameLink.CalcMemSize: PtrUInt; +function TUnitFileNameLink.CalcMemSize: PtrUInt; begin Result:=PtrUInt(InstanceSize) +MemSizeString(Unit_Name) diff --git a/components/codetools/finddeclarationtool.pas b/components/codetools/finddeclarationtool.pas index a95de63956..586af501dc 100644 --- a/components/codetools/finddeclarationtool.pas +++ b/components/codetools/finddeclarationtool.pas @@ -759,7 +759,7 @@ type out NewPos: TCodeXYPosition; out NewTopLine: integer): boolean; function FindDeclaration(const CursorPos: TCodeXYPosition; SearchSmartFlags: TFindSmartFlags; - var NewTool: TFindDeclarationTool; var NewNode: TCodeTreeNode; + out NewTool: TFindDeclarationTool; out NewNode: TCodeTreeNode; out NewPos: TCodeXYPosition; out NewTopLine: integer): boolean; function FindDeclarationInInterface(const Identifier: string; out NewPos: TCodeXYPosition; out NewTopLine: integer): boolean; @@ -1246,7 +1246,7 @@ end; function TFindDeclarationTool.FindDeclaration(const CursorPos: TCodeXYPosition; SearchSmartFlags: TFindSmartFlags; - var NewTool: TFindDeclarationTool; var NewNode: TCodeTreeNode; + out NewTool: TFindDeclarationTool; out NewNode: TCodeTreeNode; out NewPos: TCodeXYPosition; out NewTopLine: integer): boolean; var CleanCursorPos: integer; CursorNode, ClassNode: TCodeTreeNode; diff --git a/components/codetools/h2pastool.pas b/components/codetools/h2pastool.pas index d107246284..08efd1e555 100644 --- a/components/codetools/h2pastool.pas +++ b/components/codetools/h2pastool.pas @@ -55,7 +55,7 @@ interface uses Classes, SysUtils, CodeToolsStructs, AVL_Tree, - FileProcs, DirectivesTree, BasicCodeTools, CCodeParserTool, + FileProcs, BasicCodeTools, CCodeParserTool, NonPascalCodeTools, KeywordFuncLists, CodeCache, CodeTree, CodeAtom; @@ -1840,6 +1840,7 @@ begin end; AVLNode:=Macros.FindSuccessor(AVLNode); end; + if Changed then ; end; procedure TH2PasTool.DeleteDirectiveNode(Node: TH2PDirectiveNode; diff --git a/components/codetools/lfmtrees.pas b/components/codetools/lfmtrees.pas index d39c83cb41..84fb3b1f8f 100644 --- a/components/codetools/lfmtrees.pas +++ b/components/codetools/lfmtrees.pas @@ -30,8 +30,7 @@ unit LFMTrees; interface uses - Classes, SysUtils, AVL_Tree, FileProcs, BasicCodeTools, CodeCache, CodeAtom, - TypInfo; + Classes, SysUtils, AVL_Tree, FileProcs, BasicCodeTools, CodeCache, TypInfo; type { TLFMTreeNode } diff --git a/components/codetools/multikeywordlisttool.pas b/components/codetools/multikeywordlisttool.pas index ad5f95cded..e539227e3b 100644 --- a/components/codetools/multikeywordlisttool.pas +++ b/components/codetools/multikeywordlisttool.pas @@ -36,8 +36,7 @@ uses {$IFDEF MEM_CHECK} MemCheck, {$ENDIF} - Classes, SysUtils, FileProcs, CodeAtom, CustomCodeTool, KeywordFuncLists, - BasicCodeTools; + Classes, SysUtils, FileProcs, CustomCodeTool, KeywordFuncLists; type diff --git a/components/codetools/stdcodetools.pas b/components/codetools/stdcodetools.pas index 19bd6a80d1..7898fa8a37 100644 --- a/components/codetools/stdcodetools.pas +++ b/components/codetools/stdcodetools.pas @@ -205,7 +205,7 @@ type function FindBlockCounterPart(const CursorPos: TCodeXYPosition; out NewPos: TCodeXYPosition; out NewTopLine: integer): boolean; function FindBlockStart(const CursorPos: TCodeXYPosition; - out NewPos: TCodeXYPosition; var NewTopLine: integer): boolean; + out NewPos: TCodeXYPosition; out NewTopLine: integer): boolean; function GuessUnclosedBlock(const CursorPos: TCodeXYPosition; out NewPos: TCodeXYPosition; out NewTopLine: integer): boolean; function FindBlockCleanBounds(const CursorPos: TCodeXYPosition; @@ -4868,7 +4868,7 @@ begin end; function TStandardCodeTool.FindBlockStart(const CursorPos: TCodeXYPosition; - out NewPos: TCodeXYPosition; var NewTopLine: integer): boolean; + out NewPos: TCodeXYPosition; out NewTopLine: integer): boolean; // jump to beginning of current block // e.g. bracket open, 'begin', 'repeat', ... var CleanCursorPos: integer;