mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-18 22:39:11 +02:00
Converter: refactor and clean.
git-svn-id: trunk@42465 -
This commit is contained in:
parent
f0e3321128
commit
5e88daf9f5
@ -36,7 +36,7 @@ uses
|
|||||||
LazarusIDEStrConsts, IDEMsgIntf, IDEExternToolIntf,
|
LazarusIDEStrConsts, IDEMsgIntf, IDEExternToolIntf,
|
||||||
// codetools
|
// codetools
|
||||||
CodeToolManager, StdCodeTools, CodeTree, CodeCache, CodeToolsStructs, AVL_Tree,
|
CodeToolManager, StdCodeTools, CodeTree, CodeCache, CodeToolsStructs, AVL_Tree,
|
||||||
LinkScanner, KeywordFuncLists, SourceChanger, CodeAtom, CodeToolsStrConsts,
|
LinkScanner, KeywordFuncLists, SourceChanger, CodeAtom, CodeToolsStrConsts, FileProcs,
|
||||||
// Converter
|
// Converter
|
||||||
ConverterTypes, ConvCodeTool, ConvertSettings, ReplaceNamesUnit;
|
ConverterTypes, ConvCodeTool, ConvertSettings, ReplaceNamesUnit;
|
||||||
|
|
||||||
@ -72,6 +72,7 @@ type
|
|||||||
function ParentBlockNode: TCodeTreeNode; virtual; abstract;
|
function ParentBlockNode: TCodeTreeNode; virtual; abstract;
|
||||||
// Uses node in either Main or Implementation section.
|
// Uses node in either Main or Implementation section.
|
||||||
function UsesSectionNode: TCodeTreeNode; virtual; abstract;
|
function UsesSectionNode: TCodeTreeNode; virtual; abstract;
|
||||||
|
procedure ParseToUsesSectionEnd; virtual; abstract;
|
||||||
public
|
public
|
||||||
constructor Create(ACTLink: TCodeToolLink; aOwnerTool: TUsedUnitsTool);
|
constructor Create(ACTLink: TCodeToolLink; aOwnerTool: TUsedUnitsTool);
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
@ -91,6 +92,7 @@ type
|
|||||||
protected
|
protected
|
||||||
function ParentBlockNode: TCodeTreeNode; override;
|
function ParentBlockNode: TCodeTreeNode; override;
|
||||||
function UsesSectionNode: TCodeTreeNode; override;
|
function UsesSectionNode: TCodeTreeNode; override;
|
||||||
|
procedure ParseToUsesSectionEnd; override;
|
||||||
public
|
public
|
||||||
constructor Create(ACTLink: TCodeToolLink; aOwnerTool: TUsedUnitsTool);
|
constructor Create(ACTLink: TCodeToolLink; aOwnerTool: TUsedUnitsTool);
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
@ -103,6 +105,7 @@ type
|
|||||||
protected
|
protected
|
||||||
function ParentBlockNode: TCodeTreeNode; override;
|
function ParentBlockNode: TCodeTreeNode; override;
|
||||||
function UsesSectionNode: TCodeTreeNode; override;
|
function UsesSectionNode: TCodeTreeNode; override;
|
||||||
|
procedure ParseToUsesSectionEnd; override;
|
||||||
public
|
public
|
||||||
constructor Create(ACTLink: TCodeToolLink; aOwnerTool: TUsedUnitsTool);
|
constructor Create(ACTLink: TCodeToolLink; aOwnerTool: TUsedUnitsTool);
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
@ -357,10 +360,7 @@ var
|
|||||||
Result:=True;
|
Result:=True;
|
||||||
with fCTLink do begin
|
with fCTLink do begin
|
||||||
ResetMainScanner;
|
ResetMainScanner;
|
||||||
if fUsesSection=usMain then
|
ParseToUsesSectionEnd;
|
||||||
CodeTool.BuildTree(lsrMainUsesSectionEnd)
|
|
||||||
else
|
|
||||||
CodeTool.BuildTree(lsrImplementationUsesSectionEnd);
|
|
||||||
// Calls either FindMainUsesSection or FindImplementationUsesSection
|
// Calls either FindMainUsesSection or FindImplementationUsesSection
|
||||||
UsesNode:=UsesSectionNode;
|
UsesNode:=UsesSectionNode;
|
||||||
Assert(Assigned(UsesNode),
|
Assert(Assigned(UsesNode),
|
||||||
@ -397,10 +397,7 @@ begin
|
|||||||
// Add LCL and Delphi sections for output.
|
// Add LCL and Delphi sections for output.
|
||||||
if (LclOnlyUnits.Count=0) and (DelphiOnlyUnits.Count=0) then Exit(True);
|
if (LclOnlyUnits.Count=0) and (DelphiOnlyUnits.Count=0) then Exit(True);
|
||||||
fCTLink.ResetMainScanner;
|
fCTLink.ResetMainScanner;
|
||||||
if fUsesSection=usMain then
|
ParseToUsesSectionEnd;
|
||||||
fCTLink.CodeTool.BuildTree(lsrMainUsesSectionEnd)
|
|
||||||
else
|
|
||||||
fCTLink.CodeTool.BuildTree(lsrImplementationUsesSectionEnd);
|
|
||||||
UsesNode:=UsesSectionNode;
|
UsesNode:=UsesSectionNode;
|
||||||
if Assigned(UsesNode) then begin //uses section exists
|
if Assigned(UsesNode) then begin //uses section exists
|
||||||
EndChar:=',';
|
EndChar:=',';
|
||||||
@ -478,11 +475,9 @@ var
|
|||||||
begin
|
begin
|
||||||
Result:=false;
|
Result:=false;
|
||||||
for i:=0 to fUnitsToRemove.Count-1 do begin
|
for i:=0 to fUnitsToRemove.Count-1 do begin
|
||||||
fCTLink.ResetMainScanner;
|
DebugLn('TUsedUnits.RemoveUnits: '+fUnitsToRemove[i]);
|
||||||
if fUsesSection=usMain then
|
//fCTLink.ResetMainScanner;
|
||||||
fCTLink.CodeTool.BuildTree(lsrMainUsesSectionEnd)
|
ParseToUsesSectionEnd;
|
||||||
else
|
|
||||||
fCTLink.CodeTool.BuildTree(lsrImplementationUsesSectionEnd);
|
|
||||||
if not fCTLink.CodeTool.RemoveUnitFromUsesSection(UsesSectionNode,
|
if not fCTLink.CodeTool.RemoveUnitFromUsesSection(UsesSectionNode,
|
||||||
UpperCaseStr(fUnitsToRemove[i]), fCTLink.SrcCache) then
|
UpperCaseStr(fUnitsToRemove[i]), fCTLink.SrcCache) then
|
||||||
exit;
|
exit;
|
||||||
@ -519,6 +514,11 @@ begin
|
|||||||
Result:=fCTLink.CodeTool.FindMainUsesSection(IsPackage);
|
Result:=fCTLink.CodeTool.FindMainUsesSection(IsPackage);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TMainUsedUnits.ParseToUsesSectionEnd;
|
||||||
|
begin
|
||||||
|
fCTLink.CodeTool.BuildTree(lsrMainUsesSectionEnd)
|
||||||
|
end;
|
||||||
|
|
||||||
{ TImplUsedUnits }
|
{ TImplUsedUnits }
|
||||||
|
|
||||||
constructor TImplUsedUnits.Create(ACTLink: TCodeToolLink; aOwnerTool: TUsedUnitsTool);
|
constructor TImplUsedUnits.Create(ACTLink: TCodeToolLink; aOwnerTool: TUsedUnitsTool);
|
||||||
@ -542,6 +542,11 @@ begin
|
|||||||
Result:=fCTLink.CodeTool.FindImplementationUsesSection;
|
Result:=fCTLink.CodeTool.FindImplementationUsesSection;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TImplUsedUnits.ParseToUsesSectionEnd;
|
||||||
|
begin
|
||||||
|
fCTLink.CodeTool.BuildTree(lsrImplementationUsesSectionEnd);
|
||||||
|
end;
|
||||||
|
|
||||||
{ TUsedUnitsTool }
|
{ TUsedUnitsTool }
|
||||||
|
|
||||||
constructor TUsedUnitsTool.Create(ACTLink: TCodeToolLink; AFilename: string);
|
constructor TUsedUnitsTool.Create(ACTLink: TCodeToolLink; AFilename: string);
|
||||||
|
Loading…
Reference in New Issue
Block a user