mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-07 04:40:36 +02:00
h2pas: codetools: fixed removing whole sections when removing redefinitions
git-svn-id: trunk@14154 -
This commit is contained in:
parent
e3f5d4cae9
commit
0611fdb50b
@ -1661,9 +1661,6 @@ var
|
|||||||
NodeExt: TCodeTreeNodeExtension;
|
NodeExt: TCodeTreeNodeExtension;
|
||||||
begin
|
begin
|
||||||
DebugLn(['AddRedefinition ',NodeText,' Redefined=',CleanPosToStr(Redefinition.StartPos),' Definition=',CleanPosToStr(Definition.StartPos)]);
|
DebugLn(['AddRedefinition ',NodeText,' Redefined=',CleanPosToStr(Redefinition.StartPos),' Definition=',CleanPosToStr(Definition.StartPos)]);
|
||||||
if (TreeOfCodeTreeNodeExt<>nil)
|
|
||||||
and (FindCodeTreeNodeExt(TreeOfCodeTreeNodeExt,NodeText)<>nil) then
|
|
||||||
exit;
|
|
||||||
NodeExt:=NodeExtMemManager.NewNode;
|
NodeExt:=NodeExtMemManager.NewNode;
|
||||||
NodeExt.Node:=Redefinition;
|
NodeExt.Node:=Redefinition;
|
||||||
NodeExt.Data:=Definition;
|
NodeExt.Data:=Definition;
|
||||||
@ -1708,15 +1705,16 @@ begin
|
|||||||
AVLNode:=FindCodeTreeNodeExtAVLNode(AllNodes,NodeText);
|
AVLNode:=FindCodeTreeNodeExtAVLNode(AllNodes,NodeText);
|
||||||
if AVLNode<>nil then begin
|
if AVLNode<>nil then begin
|
||||||
AddRedefinition(Node,TCodeTreeNodeExtension(AVLNode.Data).Node,NodeText);
|
AddRedefinition(Node,TCodeTreeNodeExtension(AVLNode.Data).Node,NodeText);
|
||||||
|
Node:=Node.NextSkipChilds;
|
||||||
end else begin
|
end else begin
|
||||||
AddDefinition(Node,NodeText);
|
AddDefinition(Node,NodeText);
|
||||||
|
if WithEnums
|
||||||
|
and (Node.FirstChild<>nil)
|
||||||
|
and (Node.FirstChild.Desc=ctnEnumerationType) then
|
||||||
|
Node:=Node.FirstChild
|
||||||
|
else
|
||||||
|
Node:=Node.NextSkipChilds;
|
||||||
end;
|
end;
|
||||||
if WithEnums
|
|
||||||
and (Node.FirstChild<>nil)
|
|
||||||
and (Node.FirstChild.Desc=ctnEnumerationType) then
|
|
||||||
Node:=Node.FirstChild
|
|
||||||
else
|
|
||||||
Node:=Node.NextSkipChilds;
|
|
||||||
end;
|
end;
|
||||||
else
|
else
|
||||||
Node:=Node.Next;
|
Node:=Node.Next;
|
||||||
@ -1733,7 +1731,7 @@ function TCodeCompletionCodeTool.RemoveRedefinitions(
|
|||||||
SourceChangeCache: TSourceChangeCache): boolean;
|
SourceChangeCache: TSourceChangeCache): boolean;
|
||||||
var
|
var
|
||||||
AVLNode: TAVLTreeNode;
|
AVLNode: TAVLTreeNode;
|
||||||
NodesToDo: TAVLTree;
|
NodesToDo: TAVLTree;// tree of TCodeTreeNode
|
||||||
Node: TCodeTreeNode;
|
Node: TCodeTreeNode;
|
||||||
StartNode: TCodeTreeNode;
|
StartNode: TCodeTreeNode;
|
||||||
EndNode: TCodeTreeNode;
|
EndNode: TCodeTreeNode;
|
||||||
@ -1753,7 +1751,8 @@ begin
|
|||||||
// put the nodes to remove into the NodesToDo
|
// put the nodes to remove into the NodesToDo
|
||||||
AVLNode:=TreeOfCodeTreeNodeExt.FindLowest;
|
AVLNode:=TreeOfCodeTreeNodeExt.FindLowest;
|
||||||
while AVLNode<>nil do begin
|
while AVLNode<>nil do begin
|
||||||
NodesToDo.Add(TCodeTreeNodeExtension(AVLNode.Data).Node);
|
Node:=TCodeTreeNodeExtension(AVLNode.Data).Node;
|
||||||
|
NodesToDo.Add(Node);
|
||||||
AVLNode:=TreeOfCodeTreeNodeExt.FindSuccessor(AVLNode);
|
AVLNode:=TreeOfCodeTreeNodeExt.FindSuccessor(AVLNode);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1761,6 +1760,7 @@ begin
|
|||||||
while NodesToDo.Count>0 do begin
|
while NodesToDo.Count>0 do begin
|
||||||
// find a block of redefinitions
|
// find a block of redefinitions
|
||||||
StartNode:=TCodeTreeNode(NodesToDo.Root.Data);
|
StartNode:=TCodeTreeNode(NodesToDo.Root.Data);
|
||||||
|
//DebugLn(['TCodeCompletionCodeTool.RemoveRedefinitions ',StartNode.StartPos,' ',GetRedefinitionNodeText(StartNode)]);
|
||||||
EndNode:=StartNode;
|
EndNode:=StartNode;
|
||||||
while (StartNode.PriorBrother<>nil)
|
while (StartNode.PriorBrother<>nil)
|
||||||
and (NodesToDo.Find(StartNode.PriorBrother)<>nil) do
|
and (NodesToDo.Find(StartNode.PriorBrother)<>nil) do
|
||||||
@ -1768,7 +1768,8 @@ begin
|
|||||||
while (EndNode.NextBrother<>nil)
|
while (EndNode.NextBrother<>nil)
|
||||||
and (NodesToDo.Find(EndNode.NextBrother)<>nil) do
|
and (NodesToDo.Find(EndNode.NextBrother)<>nil) do
|
||||||
EndNode:=EndNode.NextBrother;
|
EndNode:=EndNode.NextBrother;
|
||||||
|
//DebugLn(['TCodeCompletionCodeTool.RemoveRedefinitions Start=',StartNode.StartPos,' ',GetRedefinitionNodeText(StartNode),' End=',EndNode.StartPos,' ',GetRedefinitionNodeText(EndNode)]);
|
||||||
|
|
||||||
// check if a whole section is deleted
|
// check if a whole section is deleted
|
||||||
if (StartNode.PriorBrother=nil) and (EndNode.PriorBrother=nil)
|
if (StartNode.PriorBrother=nil) and (EndNode.PriorBrother=nil)
|
||||||
and (StartNode.Parent<>nil)
|
and (StartNode.Parent<>nil)
|
||||||
@ -1828,9 +1829,10 @@ begin
|
|||||||
Node:=StartNode;
|
Node:=StartNode;
|
||||||
repeat
|
repeat
|
||||||
NodesToDo.Remove(Node);
|
NodesToDo.Remove(Node);
|
||||||
if Node=EndNode then break;
|
//DebugLn(['TCodeCompletionCodeTool.RemoveRedefinitions removed ',Node.StartPos,' ',GetRedefinitionNodeText(Node),' ',NodesToDo.Find(Node)<>nil]);
|
||||||
Node:=Node.Next;
|
Node:=Node.Next;
|
||||||
until false;
|
until (Node=nil) or
|
||||||
|
((Node.StartPos>EndNode.StartPos) and (not Node.HasAsParent(EndNode)));
|
||||||
end;
|
end;
|
||||||
finally
|
finally
|
||||||
NodesToDo.Free;
|
NodesToDo.Free;
|
||||||
|
Loading…
Reference in New Issue
Block a user