diff --git a/components/codetools/examples/addwith.lpr b/components/codetools/examples/addwith.lpr index ed908cd004..276b53edb2 100644 --- a/components/codetools/examples/addwith.lpr +++ b/components/codetools/examples/addwith.lpr @@ -46,7 +46,7 @@ begin writeln('Usage:'); writeln(' ',ParamStr(0)); writeln(' ',ParamStr(0),' '); - writeln(' ',ParamStr(0),' scanexamples/addwith1.pas 1 35 1 39'); + writeln(' ',ParamStr(0),' scanexamples/addwith1.pas 1 35 1 40'); end; CodeToolBoss.SimpleInit(ConfigFilename); @@ -56,7 +56,7 @@ begin X1:=1; Y1:=35; X2:=1; - Y2:=36; + Y2:=40; if Paramcount=5 then begin Filename:=ParamStrUTF8(1); X1:=StrToIntDef(ParamStrUTF8(2),1); diff --git a/components/codetools/examples/scanexamples/addwith1.pas b/components/codetools/examples/scanexamples/addwith1.pas index 0e7780b74f..6e545a3552 100644 --- a/components/codetools/examples/scanexamples/addwith1.pas +++ b/components/codetools/examples/scanexamples/addwith1.pas @@ -36,6 +36,7 @@ begin Son1.Name:=Son2.Name; Son2.Mother:=Son1; Son1.Mother:=Son2.Mother.Mother; + Son1.Components[0].Create(nil); end; end. diff --git a/components/codetools/extractproctool.pas b/components/codetools/extractproctool.pas index 03e39df352..2b0833ac68 100644 --- a/components/codetools/extractproctool.pas +++ b/components/codetools/extractproctool.pas @@ -1392,11 +1392,97 @@ var CleanStartPos: integer; CleanEndPos: integer; StartNode: TCodeTreeNode; + + procedure Add(const Identifier: string); + var + i: Integer; + begin + if Candidates=nil then + Candidates:=TStringList.Create; + i:=Candidates.IndexOf(Identifier); + if i<0 then + Candidates.AddObject(Identifier,TObject(Pointer(1))) + else + Candidates.Objects[i]:=TObject(PtrUInt(Candidates.Objects[i])+1); + //debugln(['TExtractProcTool.CheckAddWithBlock.Add ',Identifier]); + end; + + function ReadBlock(Code: PAnsiString): boolean; + var + LastPos: TAtomPosition; + Identifier: String; + StartFlag: TCommonAtomFlag; + begin + Result:=false; + StartFlag:=CurPos.Flag; + while true do begin + if Code<>nil then + Code^:=Code^+GetAtom; + //debugln(['TExtractProcTool.CheckAddWithBlock Atom=',GetAtom]); + if (CurPos.EndPos>CleanEndPos) or (CurPos.StartPos>SrcLen) + or (CurPos.StartPos>StartNode.EndPos) then + break; + if (CurPos.Flag in [cafRoundBracketClose,cafEdgedBracketClose]) then begin + if (StartFlag=cafRoundBracketOpen) then begin + if (CurPos.Flag=cafRoundBracketClose) then + break + else + RaiseCharExpectedButAtomFound(')'); + end; + if (StartFlag=cafEdgedBracketOpen) then begin + if (CurPos.Flag=cafEdgedBracketClose) then + break + else + RaiseCharExpectedButAtomFound(']'); + end; + end; + if AtomIsIdentifier(false) then begin + LastPos:=LastAtoms.GetValueAt(0); + if not ((LastPos.Flag in [cafPoint]) or LastAtomIs(0,'^') + or LastUpAtomIs(0,'INHERITED')) + then begin + // start of identifier + //debugln(['TExtractProcTool.CheckAddWithBlock identifier start ',GetAtom]); + Identifier:=GetAtom; + repeat + ReadNextAtom; + //debugln(['TExtractProcTool.CheckAddWithBlock identifier next ',GetAtom]); + if CurPos.Flag in [cafRoundBracketOpen,cafEdgedBracketOpen] then + begin + if not ReadBlock(@Identifier) then exit; + end else if (CurPos.Flag=cafPoint) then begin + Add(Identifier); + Identifier:=Identifier+GetAtom; + end else if AtomIsChar('^') then begin + Identifier:=Identifier+GetAtom; + end else if AtomIsIdentifier(false) and (LastAtomIs(0,'.')) then + begin + Identifier:=Identifier+GetAtom; + end else begin + if (not IsValidIdent(Identifier)) + and (Identifier[length(Identifier)]<>'.') then + Add(Identifier); + if Code<>nil then + Code^:=Code^+Identifier; + break; + end; + until false; + end; + end; + ReadNextAtom; + end; + Result:=true; + end; + begin Result:=false; if not CheckIfRangeOnSameLevel(StartPos,EndPos,CleanStartPos,CleanEndPos, - StartNode) then exit; - debugln(['TExtractProcTool.CheckAddWithBlock ']); + StartNode) then exit; + MoveCursorToNodeStart(StartNode); + ReadNextAtom; + if not ReadBlock(nil) then exit; + // ToDo: check if identifiers are variables + Result:=true; end; procedure TExtractProcTool.CalcMemSize(Stats: TCTMemStats); diff --git a/components/codetools/finddeclarationtool.pas b/components/codetools/finddeclarationtool.pas index b337c4f63b..4a0b3346e6 100644 --- a/components/codetools/finddeclarationtool.pas +++ b/components/codetools/finddeclarationtool.pas @@ -1649,7 +1649,7 @@ var begin Result:=false; NewContext:=CleanFindContext; - DebugLn('TFindDeclarationTool.FindDeclarationOfPropertyPath PropertyPath="',PropertyPath,'"'); + DebugLn('TFindDeclarationTool.FindDeclarationOfPropertyPath ',MainFilename,' PropertyPath="',PropertyPath,'"'); if PropertyPath='' then exit; ActivateGlobalWriteLock; Params:=TFindDeclarationParams.Create; diff --git a/components/codetools/pascalparsertool.pas b/components/codetools/pascalparsertool.pas index 5f41f81e86..cfe5b9af51 100644 --- a/components/codetools/pascalparsertool.pas +++ b/components/codetools/pascalparsertool.pas @@ -96,6 +96,10 @@ type sbcStopOnSemicolon ); TSkipBracketChecks = set of TSkipBracketCheck; +const + sbcStopOnAll = [sbcStopOnRecord,sbcStopOnSemicolon]; + +type TTreeRange = (trTillRange, trTillCursor, trTillCursorSection);