mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-08 02:38:13 +02:00
codetools: find all with candidates
git-svn-id: trunk@32221 -
This commit is contained in:
parent
b726db4376
commit
df52f97ad3
@ -46,7 +46,7 @@ begin
|
||||
writeln('Usage:');
|
||||
writeln(' ',ParamStr(0));
|
||||
writeln(' ',ParamStr(0),' <filename> <X> <Y>');
|
||||
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);
|
||||
|
@ -36,6 +36,7 @@ begin
|
||||
Son1.Name:=Son2.Name;
|
||||
Son2.Mother:=Son1;
|
||||
Son1.Mother:=Son2.Mother.Mother;
|
||||
Son1.Components[0].Create(nil);
|
||||
end;
|
||||
|
||||
end.
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -96,6 +96,10 @@ type
|
||||
sbcStopOnSemicolon
|
||||
);
|
||||
TSkipBracketChecks = set of TSkipBracketCheck;
|
||||
const
|
||||
sbcStopOnAll = [sbcStopOnRecord,sbcStopOnSemicolon];
|
||||
|
||||
type
|
||||
|
||||
TTreeRange = (trTillRange, trTillCursor, trTillCursorSection);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user