codetools: fixed RemoveUnitFromAllUsesSections

git-svn-id: branches/fixes_1_8@55945 -
This commit is contained in:
mattias 2017-09-30 13:15:10 +00:00
parent 38b9a75726
commit 74f7640ff3

View File

@ -1183,8 +1183,13 @@ end;
function TStandardCodeTool.RemoveUnitFromAllUsesSections( function TStandardCodeTool.RemoveUnitFromAllUsesSections(
const AnUnitName: string; SourceChangeCache: TSourceChangeCache): boolean; const AnUnitName: string; SourceChangeCache: TSourceChangeCache): boolean;
var
SectionNode, Node: TCodeTreeNode; function RemoveFromSection(UsesNode: TCodeTreeNode): boolean;
begin
Result:=(UsesNode=nil)
or (RemoveUnitFromUsesSection(UsesNode,AnUnitName,SourceChangeCache));
end;
begin begin
Result:=false; Result:=false;
if (AnUnitName='') or (SourceChangeCache=nil) then exit; if (AnUnitName='') or (SourceChangeCache=nil) then exit;
@ -1192,21 +1197,8 @@ begin
SourceChangeCache.BeginUpdate; SourceChangeCache.BeginUpdate;
try try
SectionNode:=Tree.Root; if not RemoveFromSection(FindMainUsesNode) then exit;
while (SectionNode<>nil) do begin if not RemoveFromSection(FindImplementationUsesNode) then exit;
Node:=SectionNode.FirstChild;
while (Node<>nil) and (Node.Desc=ctnIdentifier) do
Node:=Node.NextBrother;
if (Node<>nil)
and (Node.Desc=ctnUsesSection) then begin
if not RemoveUnitFromUsesSection(Node,AnUnitName,
SourceChangeCache)
then begin
exit;
end;
end;
SectionNode:=SectionNode.NextBrother;
end;
finally finally
Result:=SourceChangeCache.EndUpdate; Result:=SourceChangeCache.EndUpdate;
end; end;
@ -1214,24 +1206,18 @@ end;
function TStandardCodeTool.FixUsedUnitCase( function TStandardCodeTool.FixUsedUnitCase(
SourceChangeCache: TSourceChangeCache): boolean; SourceChangeCache: TSourceChangeCache): boolean;
var
SectionNode: TCodeTreeNode; function FixUsesSection(UsesNode: TCodeTreeNode): boolean;
begin
Result:=(UsesNode=nil) or FixUsedUnitCaseInUsesSection(UsesNode,SourceChangeCache);
end;
begin begin
//debugln('TStandardCodeTool.FixUsedUnitCase ',MainFilename); //debugln('TStandardCodeTool.FixUsedUnitCase ',MainFilename);
Result:=false; Result:=false;
BuildTree(lsrImplementationUsesSectionEnd); BuildTree(lsrImplementationUsesSectionEnd);
SectionNode:=Tree.Root; if not FixUsesSection(FindMainUsesNode) then exit;
while (SectionNode<>nil) do begin if not FixUsesSection(FindImplementationUsesNode) then exit;
if (SectionNode.FirstChild<>nil)
and (SectionNode.FirstChild.Desc=ctnUsesSection) then begin
if not FixUsedUnitCaseInUsesSection(
SectionNode.FirstChild,SourceChangeCache)
then begin
exit;
end;
end;
SectionNode:=SectionNode.NextBrother;
end;
Result:=true; Result:=true;
end; end;