From 7e7b1e40c41bb989d71e7753fc9849731e426f04 Mon Sep 17 00:00:00 2001 From: mattias Date: Mon, 6 Apr 2015 17:22:43 +0000 Subject: [PATCH] codetools: clean up git-svn-id: trunk@48657 - --- components/codetools/stdcodetools.pas | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/components/codetools/stdcodetools.pas b/components/codetools/stdcodetools.pas index 563bea530e..f16c3aca0f 100644 --- a/components/codetools/stdcodetools.pas +++ b/components/codetools/stdcodetools.pas @@ -118,11 +118,9 @@ type SourceChangeCache: TSourceChangeCache; AsLast: boolean = false; CheckSpecialUnits: boolean = true): boolean; function UnitExistsInUsesSection(UsesSection: TUsesSection; - const AnUnitName: string; - SourceChangeCache: TSourceChangeCache): boolean; + const AnUnitName: string): boolean; function UnitExistsInUsesSection(UsesNode: TCodeTreeNode; - const AnUnitName: string; - SourceChangeCache: TSourceChangeCache): boolean; + const AnUnitName: string): boolean; function RemoveUnitFromUsesSection(UsesNode: TCodeTreeNode; const AnUnitName: string; SourceChangeCache: TSourceChangeCache): boolean; @@ -1052,7 +1050,7 @@ begin end; function TStandardCodeTool.UnitExistsInUsesSection(UsesSection: TUsesSection; - const AnUnitName: string; SourceChangeCache: TSourceChangeCache): boolean; + const AnUnitName: string): boolean; var UsesNode: TCodeTreeNode; begin @@ -1063,16 +1061,15 @@ begin BuildTree(lsrMainUsesSectionEnd) else BuildTree(lsrImplementationUsesSectionEnd); - SourceChangeCache.MainScanner:=Scanner; case UsesSection Of usMain: UsesNode:=FindMainUsesSection; usImplementation: UsesNode:=FindImplementationUsesSection; end; - Result:=UnitExistsInUsesSection(UsesNode,AnUnitName,SourceChangeCache); + Result:=UnitExistsInUsesSection(UsesNode,AnUnitName); end; function TStandardCodeTool.UnitExistsInUsesSection(UsesNode: TCodeTreeNode; - const AnUnitName: string; SourceChangeCache: TSourceChangeCache): boolean; + const AnUnitName: string): boolean; begin Result:=false; if (UsesNode=nil) or (not IsDottedIdentifier(AnUnitName)) then @@ -2204,6 +2201,7 @@ var {$IFDEF VerboseCheckLFM} debugln('FindNonPublishedDefineProperty Path=',LFMNode.GetPath,' NO DEFINE PROPERTIES'); {$ENDIF} + if DefaultErrorPosition=0 then ; end; end; Result:=IsDefined; @@ -2832,10 +2830,14 @@ begin then exit; BuildTree(lsrEnd); Beauty:=SourceChangeCache.BeautifyCodeOptions; - MainBeginNode:=FindMainBeginEndNode; - if MainBeginNode=nil then exit; + if StartPos<1 then begin + MainBeginNode:=FindMainBeginEndNode; + if MainBeginNode=nil then exit; + StartPos:=MainBeginNode.StartPos; + if StartPos<1 then exit; + end; FromPos:=-1; - if FindCreateFormStatement(MainBeginNode.StartPos,OldClassName, + if FindCreateFormStatement(StartPos,OldClassName, OldVarName,OldPosition)=-1 then begin // does not exist if OnlyIfExists then begin