mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-14 14:59:22 +02:00
codetools: findreferences: fixed searching procs 18153
git-svn-id: trunk@28619 -
This commit is contained in:
parent
b55cf19954
commit
fc610a8a98
@ -2442,7 +2442,7 @@ begin
|
|||||||
else
|
else
|
||||||
Result:='y='+IntToStr(CodePos.Y)+',x='+IntToStr(CodePos.X);
|
Result:='y='+IntToStr(CodePos.Y)+',x='+IntToStr(CodePos.X);
|
||||||
end else
|
end else
|
||||||
Result:='y=?,x=?';
|
Result:='y=?,x=?,c='+IntToStr(CleanPos)+'('+dbgstr(copy(Src,CleanPos-5,5)+'|'+copy(Src,CleanPos,5))+')';
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TCustomCodeTool.CleanPosToRelativeStr(CleanPos: integer;
|
function TCustomCodeTool.CleanPosToRelativeStr(CleanPos: integer;
|
||||||
|
@ -4004,7 +4004,7 @@ var
|
|||||||
if PosTree=nil then
|
if PosTree=nil then
|
||||||
PosTree:=TAVLTree.Create;
|
PosTree:=TAVLTree.Create;
|
||||||
p:=@Src[ACleanPos];
|
p:=@Src[ACleanPos];
|
||||||
//debugln('TFindDeclarationTool.FindReferences.AddReference ',CleanPosToStr(ACleanPos),' ',dbgs(PosTree.Find(p)=nil));
|
//debugln('TFindDeclarationTool.FindReferences.AddReference ',CleanPosToStr(ACleanPos),' ',dbgs(PosTree.Find(p)=nil),' Code=',dbgstr(copy(Src,ACleanPos-8,8)+'|'+dbgstr(copy(Src,ACleanPos,5))));
|
||||||
if PosTree.Find(p)=nil then
|
if PosTree.Find(p)=nil then
|
||||||
PosTree.Add(p);
|
PosTree.Add(p);
|
||||||
end;
|
end;
|
||||||
@ -4043,7 +4043,7 @@ var
|
|||||||
IdentEndPos:=StartPos;
|
IdentEndPos:=StartPos;
|
||||||
while (IdentEndPos<=MaxPos) and (IsIdentChar[Src[IdentEndPos]]) do
|
while (IdentEndPos<=MaxPos) and (IsIdentChar[Src[IdentEndPos]]) do
|
||||||
inc(IdentEndPos);
|
inc(IdentEndPos);
|
||||||
//debugln('ReadIdentifier ',copy(Src,StartPos,IdentEndPos-StartPos));
|
//debugln('ReadIdentifier ',CleanPosToStr(StartPos,true),' ',copy(Src,StartPos,IdentEndPos-StartPos));
|
||||||
if (IdentEndPos-StartPos=length(Identifier))
|
if (IdentEndPos-StartPos=length(Identifier))
|
||||||
and (CompareIdentifiers(PChar(Pointer(Identifier)),@Src[StartPos])=0)
|
and (CompareIdentifiers(PChar(Pointer(Identifier)),@Src[StartPos])=0)
|
||||||
and ((not IsComment)
|
and ((not IsComment)
|
||||||
@ -4063,9 +4063,11 @@ var
|
|||||||
|
|
||||||
if (DeclarationTool=Self)
|
if (DeclarationTool=Self)
|
||||||
and ((StartPos=CleanDeclCursorPos) or (CursorNode=AliasDeclarationNode))
|
and ((StartPos=CleanDeclCursorPos) or (CursorNode=AliasDeclarationNode))
|
||||||
then
|
then begin
|
||||||
// declaration itself found
|
// declaration itself found
|
||||||
|
//debugln(['ReadIdentifier declaration itself found, adding ...']);
|
||||||
AddReference(StartPos)
|
AddReference(StartPos)
|
||||||
|
end
|
||||||
else if CleanPosIsDeclarationIdentifier(StartPos,CursorNode) then
|
else if CleanPosIsDeclarationIdentifier(StartPos,CursorNode) then
|
||||||
// this identifier is another declaration with the same name
|
// this identifier is another declaration with the same name
|
||||||
else begin
|
else begin
|
||||||
@ -4102,8 +4104,10 @@ var
|
|||||||
UseProcHead(Params.NewNode);
|
UseProcHead(Params.NewNode);
|
||||||
//debugln('Context=',Params.NewNode.DescAsString,' ',dbgs(Params.NewNode.StartPos),' ',dbgs(DeclarationNode.StartPos));
|
//debugln('Context=',Params.NewNode.DescAsString,' ',dbgs(Params.NewNode.StartPos),' ',dbgs(DeclarationNode.StartPos));
|
||||||
if (Params.NewNode=DeclarationNode)
|
if (Params.NewNode=DeclarationNode)
|
||||||
or (Params.NewNode=AliasDeclarationNode) then
|
or (Params.NewNode=AliasDeclarationNode) then begin
|
||||||
|
//debugln(['ReadIdentifier reference found, adding ...']);
|
||||||
AddReference(StartPos);
|
AddReference(StartPos);
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -4222,6 +4226,8 @@ var
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
function FindDeclarationNode: boolean;
|
function FindDeclarationNode: boolean;
|
||||||
|
const
|
||||||
|
ProcAttr = [phpInUpperCase,phpAddClassName,phpWithVarModifiers];
|
||||||
var
|
var
|
||||||
Node: TCodeTreeNode;
|
Node: TCodeTreeNode;
|
||||||
CommentStart: integer;
|
CommentStart: integer;
|
||||||
@ -4246,27 +4252,32 @@ var
|
|||||||
CleanDeclCursorPos,true);
|
CleanDeclCursorPos,true);
|
||||||
Identifier:=DeclarationTool.ExtractIdentifier(CleanDeclCursorPos);
|
Identifier:=DeclarationTool.ExtractIdentifier(CleanDeclCursorPos);
|
||||||
if Identifier='' then begin
|
if Identifier='' then begin
|
||||||
debugln('FindDeclarationNode Identifier="',Identifier,'"');
|
//debugln('FindDeclarationNode Identifier="',Identifier,'"');
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
UseProcHead(DeclarationNode);
|
UseProcHead(DeclarationNode);
|
||||||
if DeclarationTool=Self then
|
if DeclarationTool=Self then begin
|
||||||
|
//debugln(['FindDeclarationNode adding DeclarationNode ...']);
|
||||||
AddNodeReference(DeclarationNode);
|
AddNodeReference(DeclarationNode);
|
||||||
|
end;
|
||||||
|
|
||||||
// find alias declaration node
|
// find alias declaration node
|
||||||
//debugln('FindDeclarationNode DeclarationNode=',DeclarationNode.DescAsString);
|
//debugln('FindDeclarationNode DeclarationNode=',DeclarationNode.DescAsString);
|
||||||
AliasDeclarationNode:=nil;
|
AliasDeclarationNode:=nil;
|
||||||
case DeclarationNode.Desc of
|
case DeclarationNode.Desc of
|
||||||
|
|
||||||
ctnProcedure:
|
ctnProcedure,ctnProcedureHead:
|
||||||
AliasDeclarationNode:=DeclarationTool.FindCorrespondingProcNode(
|
begin
|
||||||
DeclarationNode);
|
Node:=DeclarationNode;
|
||||||
ctnProcedureHead:
|
if DeclarationNode.Desc=ctnProcedureHead then
|
||||||
AliasDeclarationNode:=DeclarationTool.FindCorrespondingProcNode(
|
Node:=Node.Parent;
|
||||||
DeclarationNode.Parent);
|
AliasDeclarationNode:=DeclarationTool.FindCorrespondingProcNode(
|
||||||
|
Node,ProcAttr);
|
||||||
|
end;
|
||||||
|
|
||||||
ctnVarDefinition:
|
ctnVarDefinition:
|
||||||
if DeclarationNode.HasParentOfType(ctnProcedureHead) then begin
|
if DeclarationNode.HasParentOfType(ctnProcedureHead) then begin
|
||||||
AliasDeclarationNode:=FindCorrespondingProcParamNode(DeclarationNode);
|
AliasDeclarationNode:=FindCorrespondingProcParamNode(DeclarationNode,ProcAttr);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
ctnTypeDefinition:
|
ctnTypeDefinition:
|
||||||
@ -4279,17 +4290,18 @@ var
|
|||||||
if AliasDeclarationNode=DeclarationNode then
|
if AliasDeclarationNode=DeclarationNode then
|
||||||
AliasDeclarationNode:=nil;
|
AliasDeclarationNode:=nil;
|
||||||
|
|
||||||
|
|
||||||
if AliasDeclarationNode<>nil then begin
|
if AliasDeclarationNode<>nil then begin
|
||||||
UseProcHead(AliasDeclarationNode);
|
UseProcHead(AliasDeclarationNode);
|
||||||
if DeclarationTool=Self then
|
if DeclarationTool=Self then begin
|
||||||
|
//debugln(['FindDeclarationNode adding alias node ...']);
|
||||||
AddNodeReference(AliasDeclarationNode);
|
AddNodeReference(AliasDeclarationNode);
|
||||||
|
end;
|
||||||
if AliasDeclarationNode.StartPos>DeclarationNode.StartPos then begin
|
if AliasDeclarationNode.StartPos>DeclarationNode.StartPos then begin
|
||||||
Node:=AliasDeclarationNode;
|
Node:=AliasDeclarationNode;
|
||||||
AliasDeclarationNode:=DeclarationNode;
|
AliasDeclarationNode:=DeclarationNode;
|
||||||
DeclarationNode:=Node;
|
DeclarationNode:=Node;
|
||||||
end;
|
end;
|
||||||
//debugln('FindDeclarationNode AliasDeclarationNode=',AliasDeclarationNode.DescAsString);
|
//debugln('FindDeclarationNode AliasDeclarationNode=',AliasDeclarationNode.DescAsString,' ',DeclarationTool.CleanPosToStr(AliasDeclarationNode.StartPos,DeclarationTool<>Self));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// search comment in front of declaration
|
// search comment in front of declaration
|
||||||
@ -4306,6 +4318,7 @@ var
|
|||||||
while (p<=SrcLen) and IsSpaceChar[Src[p]] do inc(p);
|
while (p<=SrcLen) and IsSpaceChar[Src[p]] do inc(p);
|
||||||
if (p<=SrcLen) and (CompareIdentifiers(@Src[p],PChar(Identifier))=0)
|
if (p<=SrcLen) and (CompareIdentifiers(@Src[p],PChar(Identifier))=0)
|
||||||
then begin
|
then begin
|
||||||
|
//debugln(['FindDeclarationNode comment in front']);
|
||||||
AddReference(p);
|
AddReference(p);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
@ -689,6 +689,7 @@ begin
|
|||||||
StartNode:=FindNextNodeOnSameLvl(Result);
|
StartNode:=FindNextNodeOnSameLvl(Result);
|
||||||
Result:=FindProcNode(StartNode,ProcHead,Attr);
|
Result:=FindProcNode(StartNode,ProcHead,Attr);
|
||||||
end;
|
end;
|
||||||
|
//if Result<>nil then debugln(['TPascalReaderTool.FindCorrespondingProcNode Result=',CleanPosToStr(Result.StartPos),' ',dbgstr(copy(Src,Result.StartPos,50))]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TPascalReaderTool.FindCorrespondingProcParamNode(
|
function TPascalReaderTool.FindCorrespondingProcParamNode(
|
||||||
|
Loading…
Reference in New Issue
Block a user