codetools: clean up

git-svn-id: trunk@48657 -
This commit is contained in:
mattias 2015-04-06 17:22:43 +00:00
parent 303a563f98
commit 7e7b1e40c4

View File

@ -118,11 +118,9 @@ type
SourceChangeCache: TSourceChangeCache; SourceChangeCache: TSourceChangeCache;
AsLast: boolean = false; CheckSpecialUnits: boolean = true): boolean; AsLast: boolean = false; CheckSpecialUnits: boolean = true): boolean;
function UnitExistsInUsesSection(UsesSection: TUsesSection; function UnitExistsInUsesSection(UsesSection: TUsesSection;
const AnUnitName: string; const AnUnitName: string): boolean;
SourceChangeCache: TSourceChangeCache): boolean;
function UnitExistsInUsesSection(UsesNode: TCodeTreeNode; function UnitExistsInUsesSection(UsesNode: TCodeTreeNode;
const AnUnitName: string; const AnUnitName: string): boolean;
SourceChangeCache: TSourceChangeCache): boolean;
function RemoveUnitFromUsesSection(UsesNode: TCodeTreeNode; function RemoveUnitFromUsesSection(UsesNode: TCodeTreeNode;
const AnUnitName: string; const AnUnitName: string;
SourceChangeCache: TSourceChangeCache): boolean; SourceChangeCache: TSourceChangeCache): boolean;
@ -1052,7 +1050,7 @@ begin
end; end;
function TStandardCodeTool.UnitExistsInUsesSection(UsesSection: TUsesSection; function TStandardCodeTool.UnitExistsInUsesSection(UsesSection: TUsesSection;
const AnUnitName: string; SourceChangeCache: TSourceChangeCache): boolean; const AnUnitName: string): boolean;
var var
UsesNode: TCodeTreeNode; UsesNode: TCodeTreeNode;
begin begin
@ -1063,16 +1061,15 @@ begin
BuildTree(lsrMainUsesSectionEnd) BuildTree(lsrMainUsesSectionEnd)
else else
BuildTree(lsrImplementationUsesSectionEnd); BuildTree(lsrImplementationUsesSectionEnd);
SourceChangeCache.MainScanner:=Scanner;
case UsesSection Of case UsesSection Of
usMain: UsesNode:=FindMainUsesSection; usMain: UsesNode:=FindMainUsesSection;
usImplementation: UsesNode:=FindImplementationUsesSection; usImplementation: UsesNode:=FindImplementationUsesSection;
end; end;
Result:=UnitExistsInUsesSection(UsesNode,AnUnitName,SourceChangeCache); Result:=UnitExistsInUsesSection(UsesNode,AnUnitName);
end; end;
function TStandardCodeTool.UnitExistsInUsesSection(UsesNode: TCodeTreeNode; function TStandardCodeTool.UnitExistsInUsesSection(UsesNode: TCodeTreeNode;
const AnUnitName: string; SourceChangeCache: TSourceChangeCache): boolean; const AnUnitName: string): boolean;
begin begin
Result:=false; Result:=false;
if (UsesNode=nil) or (not IsDottedIdentifier(AnUnitName)) then if (UsesNode=nil) or (not IsDottedIdentifier(AnUnitName)) then
@ -2204,6 +2201,7 @@ var
{$IFDEF VerboseCheckLFM} {$IFDEF VerboseCheckLFM}
debugln('FindNonPublishedDefineProperty Path=',LFMNode.GetPath,' NO DEFINE PROPERTIES'); debugln('FindNonPublishedDefineProperty Path=',LFMNode.GetPath,' NO DEFINE PROPERTIES');
{$ENDIF} {$ENDIF}
if DefaultErrorPosition=0 then ;
end; end;
end; end;
Result:=IsDefined; Result:=IsDefined;
@ -2832,10 +2830,14 @@ begin
then exit; then exit;
BuildTree(lsrEnd); BuildTree(lsrEnd);
Beauty:=SourceChangeCache.BeautifyCodeOptions; Beauty:=SourceChangeCache.BeautifyCodeOptions;
MainBeginNode:=FindMainBeginEndNode; if StartPos<1 then begin
if MainBeginNode=nil then exit; MainBeginNode:=FindMainBeginEndNode;
if MainBeginNode=nil then exit;
StartPos:=MainBeginNode.StartPos;
if StartPos<1 then exit;
end;
FromPos:=-1; FromPos:=-1;
if FindCreateFormStatement(MainBeginNode.StartPos,OldClassName, if FindCreateFormStatement(StartPos,OldClassName,
OldVarName,OldPosition)=-1 then begin OldVarName,OldPosition)=-1 then begin
// does not exist // does not exist
if OnlyIfExists then begin if OnlyIfExists then begin