mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-18 17:19:23 +02:00
fixed jumping to renamed procs
git-svn-id: trunk@4188 -
This commit is contained in:
parent
0fdca7f45b
commit
e220b423c5
@ -78,6 +78,8 @@ type
|
|||||||
IgnoreJumpCentered: boolean): boolean;
|
IgnoreJumpCentered: boolean): boolean;
|
||||||
function FindNodeInTree(ATree: TAVLTree;
|
function FindNodeInTree(ATree: TAVLTree;
|
||||||
const UpperCode: string): TCodeTreeNodeExtension;
|
const UpperCode: string): TCodeTreeNodeExtension;
|
||||||
|
procedure WriteCodeTreeNodeExtTree(ExtTree: TAVLTree);
|
||||||
|
public
|
||||||
property AdjustTopLineDueToComment: boolean
|
property AdjustTopLineDueToComment: boolean
|
||||||
read FAdjustTopLineDueToComment write FAdjustTopLineDueToComment;
|
read FAdjustTopLineDueToComment write FAdjustTopLineDueToComment;
|
||||||
end;
|
end;
|
||||||
@ -442,6 +444,7 @@ begin
|
|||||||
ProcNode,[phpInUpperCase,phpIgnoreForwards],
|
ProcNode,[phpInUpperCase,phpIgnoreForwards],
|
||||||
false);
|
false);
|
||||||
if Result then exit;
|
if Result then exit;
|
||||||
|
|
||||||
// there is no proc with same name and param list
|
// there is no proc with same name and param list
|
||||||
// gather forward procs
|
// gather forward procs
|
||||||
if (ProcNode.Parent.Desc=ctnImplementation)
|
if (ProcNode.Parent.Desc=ctnImplementation)
|
||||||
@ -451,12 +454,17 @@ begin
|
|||||||
StartNode:=ProcNode.Parent.FirstChild;
|
StartNode:=ProcNode.Parent.FirstChild;
|
||||||
SearchForNodes:=GatherProcNodes(StartNode,
|
SearchForNodes:=GatherProcNodes(StartNode,
|
||||||
[phpInUpperCase,phpIgnoreProcsWithBody,phpIgnoreMethods],'');
|
[phpInUpperCase,phpIgnoreProcsWithBody,phpIgnoreMethods],'');
|
||||||
|
|
||||||
// gather proc bodies
|
// gather proc bodies
|
||||||
SearchInNodes:=GatherProcNodes(StartNode,
|
SearchInNodes:=GatherProcNodes(StartNode,
|
||||||
[phpInUpperCase,phpIgnoreForwards,phpIgnoreMethods],'');
|
[phpInUpperCase,phpIgnoreForwards,phpIgnoreMethods],'');
|
||||||
|
|
||||||
try
|
try
|
||||||
// remove corresponding procs
|
// remove corresponding procs
|
||||||
RemoveCorrespondingProcNodes(SearchInNodes,SearchForNodes,true);
|
RemoveCorrespondingProcNodes(SearchForNodes,SearchInNodes,true);
|
||||||
|
|
||||||
|
//writeln('TMethodJumpingCodeTool.FindJumpPoint 2E Unforwarded Body Procs:');
|
||||||
|
//WriteCodeTreeNodeExtTree(SearchInNodes);
|
||||||
|
|
||||||
// search for a proc body with same name
|
// search for a proc body with same name
|
||||||
// and no corresponding forward proc
|
// and no corresponding forward proc
|
||||||
@ -573,69 +581,80 @@ begin
|
|||||||
exit;
|
exit;
|
||||||
end else begin
|
end else begin
|
||||||
// search forward procedure
|
// search forward procedure
|
||||||
|
{$IFDEF CTDEBUG}
|
||||||
|
writeln('TMethodJumpingCodeTool.FindJumpPoint 5A searching exact forward proc ...');
|
||||||
|
{$ENDIF}
|
||||||
Result:=FindBestProcNode(ProcNode,[phpInUpperCase],
|
Result:=FindBestProcNode(ProcNode,[phpInUpperCase],
|
||||||
StartNode,[phpInUpperCase,phpIgnoreProcsWithBody],
|
StartNode,[phpInUpperCase,phpIgnoreProcsWithBody],
|
||||||
false);
|
false);
|
||||||
if not Result then begin
|
if Result then exit;
|
||||||
// there is no proc with same name and param list
|
|
||||||
// gather forward procs
|
{$IFDEF CTDEBUG}
|
||||||
if (ProcNode.Parent.Desc=ctnImplementation)
|
writeln('TMethodJumpingCodeTool.FindJumpPoint 5B searching similar forward proc');
|
||||||
and (ProcNode.Parent.PriorBrother.FirstChild<>nil) then
|
{$ENDIF}
|
||||||
StartNode:=ProcNode.Parent.PriorBrother.FirstChild
|
// there is no proc with same name and param list
|
||||||
else
|
// gather forward procs
|
||||||
StartNode:=ProcNode.Parent.FirstChild;
|
if (ProcNode.Parent.Desc=ctnImplementation)
|
||||||
SearchInNodes:=GatherProcNodes(StartNode,
|
and (ProcNode.Parent.PriorBrother.FirstChild<>nil) then
|
||||||
[phpInUpperCase,phpIgnoreProcsWithBody,phpIgnoreMethods],'');
|
StartNode:=ProcNode.Parent.PriorBrother.FirstChild
|
||||||
// gather proc bodies
|
else
|
||||||
SearchForNodes:=GatherProcNodes(StartNode,
|
StartNode:=ProcNode.Parent.FirstChild;
|
||||||
[phpInUpperCase,phpIgnoreForwards,phpIgnoreMethods],'');
|
SearchInNodes:=GatherProcNodes(StartNode,
|
||||||
try
|
[phpInUpperCase,phpIgnoreProcsWithBody,phpIgnoreMethods],'');
|
||||||
// remove corresponding procs
|
|
||||||
RemoveCorrespondingProcNodes(SearchInNodes,SearchForNodes,true);
|
// gather proc bodies
|
||||||
|
SearchForNodes:=GatherProcNodes(StartNode,
|
||||||
|
[phpInUpperCase,phpIgnoreForwards,phpIgnoreMethods],'');
|
||||||
|
|
||||||
// search for a forward proc with same name
|
try
|
||||||
// and no corresponding proc body
|
// remove corresponding procs
|
||||||
SearchedProcname:=ExtractProcName(ProcNode,[phpInUpperCase]);
|
RemoveCorrespondingProcNodes(SearchForNodes,SearchInNodes,true);
|
||||||
DefAVLNode:=SearchInNodes.FindLowest;
|
|
||||||
while DefAVLNode<>nil do begin
|
//writeln('TMethodJumpingCodeTool.FindJumpPoint 5E Forward Procs without body');
|
||||||
ANode:=TCodeTreeNodeExtension(DefAVLNode.Data).Node;
|
//WriteCodeTreeNodeExtTree(SearchInNodes);
|
||||||
if (ANode.StartPos<ProcNode.StartPos)
|
|
||||||
and (CompareNodeIdentChars(ANode.FirstChild,SearchedProcname)=0)
|
// search for a forward proc with same name
|
||||||
then begin
|
// and no corresponding proc body
|
||||||
// proc body found
|
SearchedProcname:=ExtractProcName(ProcNode,[phpInUpperCase]);
|
||||||
Result:=JumpToProc(ProcNode,JumpToProcAttr,
|
DefAVLNode:=SearchInNodes.FindLowest;
|
||||||
ANode,JumpToProcAttr);
|
while DefAVLNode<>nil do begin
|
||||||
exit;
|
ANode:=TCodeTreeNodeExtension(DefAVLNode.Data).Node;
|
||||||
end;
|
if (ANode.StartPos<ProcNode.StartPos)
|
||||||
DefAVLNode:=SearchInNodes.FindSuccessor(DefAVLNode);
|
and (CompareNodeIdentChars(ANode.FirstChild,SearchedProcname)=0)
|
||||||
|
then begin
|
||||||
|
// proc body found
|
||||||
|
Result:=JumpToProc(ProcNode,JumpToProcAttr,
|
||||||
|
ANode,JumpToProcAttr);
|
||||||
|
exit;
|
||||||
end;
|
end;
|
||||||
|
DefAVLNode:=SearchInNodes.FindSuccessor(DefAVLNode);
|
||||||
// search for a forward proc with same param list
|
|
||||||
// and no corresponding proc body
|
|
||||||
SearchedParamList:=ExtractProcHead(ProcNode,[phpInUpperCase,
|
|
||||||
phpWithStart,phpWithoutClassKeyword,phpWithoutClassName,
|
|
||||||
phpWithoutName]);
|
|
||||||
DefAVLNode:=SearchInNodes.FindLowest;
|
|
||||||
while DefAVLNode<>nil do begin
|
|
||||||
ANode:=TCodeTreeNodeExtension(DefAVLNode.Data).Node;
|
|
||||||
if (ANode.StartPos<ProcNode.StartPos)
|
|
||||||
and (CompareTextIgnoringSpace(SearchedParamList,
|
|
||||||
ExtractProcHead(ANode,[phpInUpperCase,phpWithStart,
|
|
||||||
phpWithoutClassKeyword,phpWithoutClassName,phpWithoutName]),
|
|
||||||
false)=0) then
|
|
||||||
begin
|
|
||||||
// proc body found
|
|
||||||
Result:=JumpToProc(ProcNode,JumpToProcAttr,
|
|
||||||
ANode,JumpToProcAttr);
|
|
||||||
exit;
|
|
||||||
end;
|
|
||||||
DefAVLNode:=SearchInNodes.FindSuccessor(DefAVLNode);
|
|
||||||
end;
|
|
||||||
|
|
||||||
finally
|
|
||||||
NodeExtMemManager.DisposeAVLTree(SearchForNodes);
|
|
||||||
NodeExtMemManager.DisposeAVLTree(SearchInNodes);
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
// search for a forward proc with same param list
|
||||||
|
// and no corresponding proc body
|
||||||
|
SearchedParamList:=ExtractProcHead(ProcNode,[phpInUpperCase,
|
||||||
|
phpWithStart,phpWithoutClassKeyword,phpWithoutClassName,
|
||||||
|
phpWithoutName]);
|
||||||
|
DefAVLNode:=SearchInNodes.FindLowest;
|
||||||
|
while DefAVLNode<>nil do begin
|
||||||
|
ANode:=TCodeTreeNodeExtension(DefAVLNode.Data).Node;
|
||||||
|
if (ANode.StartPos<ProcNode.StartPos)
|
||||||
|
and (CompareTextIgnoringSpace(SearchedParamList,
|
||||||
|
ExtractProcHead(ANode,[phpInUpperCase,phpWithStart,
|
||||||
|
phpWithoutClassKeyword,phpWithoutClassName,phpWithoutName]),
|
||||||
|
false)=0) then
|
||||||
|
begin
|
||||||
|
// proc body found
|
||||||
|
Result:=JumpToProc(ProcNode,JumpToProcAttr,
|
||||||
|
ANode,JumpToProcAttr);
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
DefAVLNode:=SearchInNodes.FindSuccessor(DefAVLNode);
|
||||||
|
end;
|
||||||
|
|
||||||
|
finally
|
||||||
|
NodeExtMemManager.DisposeAVLTree(SearchForNodes);
|
||||||
|
NodeExtMemManager.DisposeAVLTree(SearchInNodes);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -643,8 +662,8 @@ begin
|
|||||||
exit;
|
exit;
|
||||||
end else begin
|
end else begin
|
||||||
// no proc found
|
// no proc found
|
||||||
|
// -> try parent proc ...
|
||||||
ProcNode:=ProcNode.Parent;
|
ProcNode:=ProcNode.Parent;
|
||||||
// try parent proc ...
|
|
||||||
end;
|
end;
|
||||||
end; //while (ProcNode<>nil) and (ProcNode.Desc=ctnProcedure) do begin
|
end; //while (ProcNode<>nil) and (ProcNode.Desc=ctnProcedure) do begin
|
||||||
end;
|
end;
|
||||||
@ -879,6 +898,30 @@ begin
|
|||||||
Result:=nil;
|
Result:=nil;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TMethodJumpingCodeTool.WriteCodeTreeNodeExtTree(ExtTree: TAVLTree);
|
||||||
|
var
|
||||||
|
AVLNode: TAVLTreeNode;
|
||||||
|
ANodeExt: TCodeTreeNodeExtension;
|
||||||
|
begin
|
||||||
|
writeln('TMethodJumpingCodeTool.WriteCodeTreeNodeExtTree ExtTree.Count=',ExtTree.Count);
|
||||||
|
AVLNode:=ExtTree.FindLowest;
|
||||||
|
while AVLNode<>nil do begin
|
||||||
|
ANodeExt:=TCodeTreeNodeExtension(AVLNode.Data);
|
||||||
|
write(' ');
|
||||||
|
if ANodeExt.Node<>nil then begin
|
||||||
|
write('Node=',ANodeExt.Node.DescAsString,' Node.Start=',ANodeExt.Node.StartPos);
|
||||||
|
write(' "',StringToPascalConst(copy(Src,ANodeExt.Node.StartPos,30)),'"');
|
||||||
|
end else
|
||||||
|
write('Node=nil');
|
||||||
|
write(' Position=',ANodeExt.Position);
|
||||||
|
write(' Txt="',ANodeExt.Txt,'"');
|
||||||
|
write(' ExtTxt1="',ANodeExt.ExtTxt1,'"');
|
||||||
|
write(' ExtTxt2="',ANodeExt.ExtTxt2,'"');
|
||||||
|
writeln();
|
||||||
|
AVLNode:=ExtTree.FindSuccessor(AVLNode);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
function TMethodJumpingCodeTool.JumpToCleanPos(NewCleanPos,
|
function TMethodJumpingCodeTool.JumpToCleanPos(NewCleanPos,
|
||||||
NewTopLineCleanPos: integer; var NewPos: TCodeXYPosition;
|
NewTopLineCleanPos: integer; var NewPos: TCodeXYPosition;
|
||||||
var NewTopLine: integer; IgnoreJumpCentered: boolean): boolean;
|
var NewTopLine: integer; IgnoreJumpCentered: boolean): boolean;
|
||||||
|
Loading…
Reference in New Issue
Block a user