mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-05 02:37:37 +02:00
codetools: find identifier references: fixed searching local identifiers
git-svn-id: trunk@34832 -
This commit is contained in:
parent
d469685cc6
commit
8f6bddb835
@ -4642,6 +4642,7 @@ var
|
|||||||
procedure LimitScope;
|
procedure LimitScope;
|
||||||
var
|
var
|
||||||
Node: TCodeTreeNode;
|
Node: TCodeTreeNode;
|
||||||
|
StartNode: TCodeTreeNode;
|
||||||
begin
|
begin
|
||||||
MinPos:=Tree.FindFirstPosition;
|
MinPos:=Tree.FindFirstPosition;
|
||||||
MaxPos:=Tree.FindLastPosition;
|
MaxPos:=Tree.FindLastPosition;
|
||||||
@ -4649,11 +4650,10 @@ var
|
|||||||
|
|
||||||
if DeclarationTool<>Self then exit;
|
if DeclarationTool<>Self then exit;
|
||||||
|
|
||||||
Node:=DeclarationNode;
|
StartNode:=DeclarationNode;
|
||||||
if (AliasDeclarationNode<>nil) then
|
if (AliasDeclarationNode<>nil) then
|
||||||
Node:=AliasDeclarationNode;
|
StartNode:=AliasDeclarationNode;
|
||||||
if Node.Desc=ctnProcedureHead then
|
Node:=StartNode;
|
||||||
MinPos:=Node.StartPos;
|
|
||||||
while Node<>nil do begin
|
while Node<>nil do begin
|
||||||
case Node.Desc of
|
case Node.Desc of
|
||||||
ctnImplementation:
|
ctnImplementation:
|
||||||
@ -4671,15 +4671,16 @@ var
|
|||||||
if MinPos<Node.StartPos then MinPos:=Node.StartPos;
|
if MinPos<Node.StartPos then MinPos:=Node.StartPos;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
ctnProcedureHead:
|
||||||
|
MinPos:=Node.StartPos;
|
||||||
|
|
||||||
ctnProcedure:
|
ctnProcedure:
|
||||||
begin
|
begin
|
||||||
if (DeclarationNode<>Node)
|
if (FindProcBody(Node)<>nil) and (StartNode<>Node.FirstChild) then
|
||||||
and (DeclarationNode<>Node.FirstChild)
|
begin
|
||||||
and (AliasDeclarationNode<>Node)
|
|
||||||
and (AliasDeclarationNode<>Node.FirstChild)
|
|
||||||
then begin
|
|
||||||
// DeclarationNode is a local identifier
|
// DeclarationNode is a local identifier
|
||||||
// limit scope to procedure
|
// limit scope to procedure
|
||||||
|
//debugln(['LimitScope ProcNode=',CleanPosToStr(Node.StartPos),'..',CleanPosToStr(Node.EndPos)]);
|
||||||
if MinPos<Node.FirstChild.EndPos then
|
if MinPos<Node.FirstChild.EndPos then
|
||||||
MinPos:=Node.FirstChild.EndPos;
|
MinPos:=Node.FirstChild.EndPos;
|
||||||
if MaxPos>Node.EndPos then
|
if MaxPos>Node.EndPos then
|
||||||
@ -4687,7 +4688,17 @@ var
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
ctnOnBlock:
|
||||||
|
begin
|
||||||
|
// a declaration in an on block is only accessible in the on block
|
||||||
|
if MinPos<Node.StartPos then
|
||||||
|
MinPos:=Node.StartPos;
|
||||||
|
if MaxPos>Node.EndPos then
|
||||||
|
MaxPos:=Node.EndPos;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
end;
|
||||||
|
//debugln(['scope limited to node: ',Node.DescAsString,' ',CleanPosToStr(MinPos),'..',CleanPosToStr(MaxPos),': ',dbgstr(copy(Src,MinPos,20)),'..',dbgstr(copy(Src,MaxPos-20,20))]);
|
||||||
Node:=Node.Parent;
|
Node:=Node.Parent;
|
||||||
end;
|
end;
|
||||||
//debugln(['LimitScope ',CleanPosToStr(MinPos),'..',CleanPosToStr(MaxPos),': ',dbgstr(copy(Src,MinPos,20)),'..',dbgstr(copy(Src,MaxPos-20,20))]);
|
//debugln(['LimitScope ',CleanPosToStr(MinPos),'..',CleanPosToStr(MaxPos),': ',dbgstr(copy(Src,MinPos,20)),'..',dbgstr(copy(Src,MaxPos-20,20))]);
|
||||||
@ -4721,7 +4732,7 @@ begin
|
|||||||
// search identifiers
|
// search identifiers
|
||||||
LimitScope;
|
LimitScope;
|
||||||
|
|
||||||
//debugln('FindReferences MinPos=',dbgs(MinPos),' MaxPos=',dbgs(MaxPos));
|
//debugln('FindReferences MinPos=',CleanPosToStr(MinPos),' MaxPos=',CleanPosToStr(MaxPos));
|
||||||
SearchIdentifiers;
|
SearchIdentifiers;
|
||||||
|
|
||||||
// create the reference list
|
// create the reference list
|
||||||
|
@ -792,11 +792,11 @@ begin
|
|||||||
Result:=ProcNode;
|
Result:=ProcNode;
|
||||||
if Result=nil then exit;
|
if Result=nil then exit;
|
||||||
if Result.Desc<>ctnProcedure then exit;
|
if Result.Desc<>ctnProcedure then exit;
|
||||||
Result:=Result.FirstChild;
|
Result:=Result.LastChild;
|
||||||
while Result<>nil do begin
|
while Result<>nil do begin
|
||||||
if Result.Desc in [ctnBeginBlock,ctnAsmBlock] then
|
if Result.Desc in [ctnBeginBlock,ctnAsmBlock] then
|
||||||
exit;
|
exit;
|
||||||
Result:=Result.NextBrother;
|
Result:=Result.PriorBrother;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user