mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-12-26 00:50:28 +01:00
codetools: extract proc: fixed removing whole var sections
git-svn-id: trunk@10289 -
This commit is contained in:
parent
af58c185f9
commit
84eb5a5a3f
@ -515,7 +515,8 @@ var
|
||||
AVLNode: TAVLTreeNode;
|
||||
begin
|
||||
CurProcVar:=nil;
|
||||
AVLNode:=VarTree.FindKey(VarNode, TListSortCompare(@CompareNodeWithExtractedProcVariable));
|
||||
AVLNode:=VarTree.FindKey(VarNode,
|
||||
TListSortCompare(@CompareNodeWithExtractedProcVariable));
|
||||
if AVLNode=nil then begin
|
||||
Result:=false;
|
||||
end else begin
|
||||
@ -524,6 +525,27 @@ var
|
||||
and CurProcVar.UsedInSelection;
|
||||
end;
|
||||
end;
|
||||
|
||||
function VarSectionIsEmpty: boolean;
|
||||
var
|
||||
VarNode: TCodeTreeNode;
|
||||
SectionNode: TCodeTreeNode;
|
||||
CurProcVar: TExtractedProcVariable;
|
||||
begin
|
||||
Result:=false;
|
||||
SectionNode:=ProcVar.Node;
|
||||
if SectionNode.Desc=ctnVarDefinition then
|
||||
SectionNode:=SectionNode.Parent;
|
||||
if SectionNode.Desc<>ctnVarSection then exit;
|
||||
VarNode:=SectionNode.FirstChild;
|
||||
while VarNode<>nil do begin
|
||||
CurProcVar:=nil;
|
||||
if not VariableNodeShouldBeDeleted(VarNode,CurProcVar) then exit;
|
||||
if not CurProcVar.RemovedFromOldProc then exit;
|
||||
VarNode:=VarNode.NextBrother;
|
||||
end;
|
||||
Result:=true;
|
||||
end;
|
||||
|
||||
var
|
||||
VarNode: TCodeTreeNode;
|
||||
@ -611,8 +633,7 @@ var
|
||||
// all variables of the definition should be deleted
|
||||
// -> delete type declaration
|
||||
DeleteEndPos:=FindLineEndOrCodeAfterPosition(LastVarNode.EndPos);
|
||||
if (FirstVarNode.PriorBrother=nil)
|
||||
and (LastVarNode.NextBrother=nil) then begin
|
||||
if VarSectionIsEmpty then begin
|
||||
// all variables of the 'var' section are deleted
|
||||
// -> delete var section
|
||||
DeleteStartPos:=FirstVarNode.Parent.StartPos;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user