codetools: changed some uppercase parameters to mixed case

git-svn-id: trunk@29982 -
This commit is contained in:
mattias 2011-03-22 13:41:30 +00:00
parent 4f26caa11d
commit c2a58808d3
5 changed files with 139 additions and 147 deletions

View File

@ -290,7 +290,7 @@ type
out ListOfPFindContext: TFPList): boolean;
// custom class completion
function InitClassCompletion(const UpperClassName: string;
function InitClassCompletion(const AClassName: string;
SourceChangeCache: TSourceChangeCache): boolean;
function ApplyClassCompletion(AddMissingProcBodies: boolean): boolean;
function ProcExistsInCodeCompleteClass(
@ -5010,7 +5010,7 @@ begin
end;
function TCodeCompletionCodeTool.InitClassCompletion(
const UpperClassName: string;
const AClassName: string;
SourceChangeCache: TSourceChangeCache): boolean;
var
ClassNode: TCodeTreeNode;
@ -5019,7 +5019,7 @@ begin
BuildTree(lsrEnd);
if ScannedRange<>lsrEnd then exit;
if (SourceChangeCache=nil) or (Scanner=nil) then exit;
ClassNode:=FindClassNodeInUnit(UpperClassName,true,false,false,true);
ClassNode:=FindClassNodeInUnit(AClassName,true,false,false,true);
if (ClassNode=nil) then exit;
CodeCompleteClassNode:=ClassNode;
CodeCompleteSrcChgCache:=SourceChangeCache;

View File

@ -535,7 +535,7 @@ type
// custom class completion
function InitClassCompletion(Code: TCodeBuffer;
const UpperClassName: string; out CodeTool: TCodeTool): boolean;
const AClassName: string; out CodeTool: TCodeTool): boolean;
// extract proc (creates a new procedure from code in selection)
function CheckExtractProc(Code: TCodeBuffer;
@ -3245,8 +3245,7 @@ begin
Result:=false;
if not InitCurCodeTool(Code) then exit;
try
Result:=FCurCodeTool.GetCompatiblePublishedMethods(UpperCaseStr(AClassName),
TypeData,Proc);
Result:=FCurCodeTool.GetCompatiblePublishedMethods(AClassName,TypeData,Proc);
except
on e: Exception do Result:=HandleException(e);
end;
@ -3300,8 +3299,8 @@ begin
Result:=InitCurCodeTool(Code);
if not Result then exit;
try
Result:=FCurCodeTool.JumpToPublishedMethodBody(UpperCaseStr(AClassName),
UpperCaseStr(AMethodName),NewPos,NewTopLine);
Result:=FCurCodeTool.JumpToPublishedMethodBody(AClassName,
AMethodName,NewPos,NewTopLine);
if Result then begin
NewCode:=NewPos.Code;
NewX:=NewPos.X;
@ -3322,9 +3321,8 @@ begin
if not Result then exit;
try
SourceChangeCache.Clear;
Result:=FCurCodeTool.RenamePublishedMethod(UpperCaseStr(AClassName),
UpperCaseStr(OldMethodName),NewMethodName,
SourceChangeCache);
Result:=FCurCodeTool.RenamePublishedMethod(AClassName,
OldMethodName,NewMethodName,SourceChangeCache);
except
on e: Exception do Result:=HandleException(e);
end;
@ -3343,7 +3341,7 @@ begin
if not Result then exit;
try
SourceChangeCache.Clear;
Result:=FCurCodeTool.CreateMethod(UpperCaseStr(AClassName),
Result:=FCurCodeTool.CreateMethod(AClassName,
NewMethodName,ATypeInfo,APropertyUnitName,APropertyPath,
SourceChangeCache,UseTypeInfoForParameters,pcsPublished,
CallAncestorMethod);
@ -3364,7 +3362,7 @@ begin
if not Result then exit;
try
SourceChangeCache.Clear;
Result:=FCurCodeTool.CreateMethod(UpperCaseStr(AClassName),
Result:=FCurCodeTool.CreateMethod(AClassName,
NewMethodName,ATypeInfo,APropertyUnitName,APropertyPath,
SourceChangeCache,UseTypeInfoForParameters,pcsPrivate);
except
@ -3821,7 +3819,7 @@ begin
end;
function TCodeToolManager.InitClassCompletion(Code: TCodeBuffer;
const UpperClassName: string; out CodeTool: TCodeTool): boolean;
const AClassName: string; out CodeTool: TCodeTool): boolean;
begin
{$IFDEF CTDEBUG}
DebugLn('TCodeToolManager.InitClassCompletion A ',Code.Filename);
@ -3830,7 +3828,7 @@ begin
CodeTool:=nil;
if not InitCurCodeTool(Code) then exit;
try
Result:=FCurCodeTool.InitClassCompletion(UpperClassName,SourceChangeCache);
Result:=FCurCodeTool.InitClassCompletion(AClassName,SourceChangeCache);
CodeTool:=FCurCodeTool;
except
on e: Exception do Result:=HandleException(e);
@ -4054,7 +4052,7 @@ begin
OldIgnoreMissingIncludeFiles := FCurCodeTool.Scanner.IgnoreMissingIncludeFiles;
try
FCurCodeTool.Scanner.IgnoreMissingIncludeFiles := IgnoreMissingIncludeFiles;
Result:=FCurCodeTool.FindUnitInAllUsesSections(UpperCaseStr(AnUnitName),
Result:=FCurCodeTool.FindUnitInAllUsesSections(AnUnitName,
NameAtomPos, InAtomPos);
if Result then begin
NamePos:=NameAtomPos.StartPos;
@ -4075,7 +4073,7 @@ begin
{$ENDIF}
if not InitCurCodeTool(Code) then exit;
try
Result:=FCurCodeTool.RenameUsedUnit(UpperCaseStr(OldUnitName),NewUnitName,
Result:=FCurCodeTool.RenameUsedUnit(OldUnitName,NewUnitName,
NewUnitInFile,SourceChangeCache);
except
on e: Exception do Result:=HandleException(e);
@ -4141,7 +4139,7 @@ begin
{$ENDIF}
if not InitCurCodeTool(Code) then exit;
try
Result:=FCurCodeTool.RemoveUnitFromAllUsesSections(UpperCaseStr(AnUnitName),
Result:=FCurCodeTool.RemoveUnitFromAllUsesSections(AnUnitName,
SourceChangeCache);
except
on e: Exception do Result:=HandleException(e);
@ -4489,8 +4487,8 @@ begin
{$ENDIF}
if not InitCurCodeTool(Code) then exit;
try
Result:=FCurCodeTool.FindCreateFormStatement(StartPos,UpperCaseStr(AClassName),
UpperCaseStr(AVarName),PosAtom);
Result:=FCurCodeTool.FindCreateFormStatement(StartPos,AClassName,
AVarName,PosAtom);
if Result<>-1 then
Position:=PosAtom.StartPos;
except
@ -4523,8 +4521,7 @@ begin
{$ENDIF}
if not InitCurCodeTool(Code) then exit;
try
Result:=FCurCodeTool.RemoveCreateFormStatement(UpperCaseStr(AVarName),
SourceChangeCache);
Result:=FCurCodeTool.RemoveCreateFormStatement(AVarName,SourceChangeCache);
except
on e: Exception do Result:=HandleException(e);
end;
@ -4662,8 +4659,7 @@ begin
AncestorClassName:='';
if not InitCurCodeTool(Code) then exit;
try
Result:=FCurCodeTool.FindFormAncestor(UpperCaseStr(FormClassName),
AncestorClassName);
Result:=FCurCodeTool.FindFormAncestor(FormClassName,AncestorClassName);
except
on e: Exception do Result:=HandleException(e);
end;
@ -4698,8 +4694,8 @@ begin
{$ENDIF}
if not InitCurCodeTool(Code) then exit;
try
Result:=FCurCodeTool.FindPublishedVariable(UpperCaseStr(AClassName),
UpperCaseStr(AVarName),ErrorOnClassNotFound)<>nil;
Result:=FCurCodeTool.FindPublishedVariable(AClassName,
AVarName,ErrorOnClassNotFound)<>nil;
except
on e: Exception do Result:=HandleException(e);
end;
@ -4714,7 +4710,7 @@ begin
{$ENDIF}
if not InitCurCodeTool(Code) then exit;
try
Result:=FCurCodeTool.AddPublishedVariable(UpperCaseStr(AClassName),
Result:=FCurCodeTool.AddPublishedVariable(AClassName,
VarName,VarType,SourceChangeCache);
except
on e: Exception do Result:=HandleException(e);
@ -4730,8 +4726,8 @@ begin
{$ENDIF}
if not InitCurCodeTool(Code) then exit;
try
Result:=FCurCodeTool.RemovePublishedVariable(UpperCaseStr(AClassName),
UpperCaseStr(AVarName),ErrorOnClassNotFound,SourceChangeCache);
Result:=FCurCodeTool.RemovePublishedVariable(AClassName,
AVarName,ErrorOnClassNotFound,SourceChangeCache);
except
on e: Exception do Result:=HandleException(e);
end;
@ -4747,8 +4743,8 @@ begin
{$ENDIF}
if not InitCurCodeTool(Code) then exit;
try
Result:=FCurCodeTool.RenamePublishedVariable(UpperCaseStr(AClassName),
UpperCaseStr(OldVariableName),NewVarName,VarType,
Result:=FCurCodeTool.RenamePublishedVariable(AClassName,
OldVariableName,NewVarName,VarType,
ErrorOnClassNotFound,SourceChangeCache);
except
on e: Exception do Result:=HandleException(e);

View File

@ -68,7 +68,7 @@ type
function GetCompatiblePublishedMethods(const AClassName: string;
PropInstance: TPersistent; const PropName: string;
const Proc: TGetStrProc): boolean;
function GetCompatiblePublishedMethods(const UpperClassName: string;
function GetCompatiblePublishedMethods(const AClassName: string;
TypeData: PTypeData; const Proc: TGetStrProc): boolean;
function GetCompatiblePublishedMethods(ClassNode: TCodeTreeNode;
TypeData: PTypeData; const Proc: TGetStrProc): boolean;
@ -85,16 +85,16 @@ type
const AMethodName: string; TypeData: PTypeData;
out MethodIsCompatible, MethodIsPublished, IdentIsMethod: boolean
): boolean;
function JumpToPublishedMethodBody(const UpperClassName,
UpperMethodName: string;
function JumpToPublishedMethodBody(const AClassName,
AMethodName: string;
out NewPos: TCodeXYPosition; out NewTopLine: integer): boolean;
function RenamePublishedMethod(const UpperClassName, UpperOldMethodName,
function RenamePublishedMethod(const AClassName, AOldMethodName,
NewMethodName: string; SourceChangeCache: TSourceChangeCache): boolean;
function RenamePublishedMethod(ClassNode: TCodeTreeNode;
const UpperOldMethodName, NewMethodName: string;
const AOldMethodName, NewMethodName: string;
SourceChangeCache: TSourceChangeCache): boolean;
function CreateMethod(const UpperClassName,
function CreateMethod(const AClassName,
AMethodName: string; ATypeInfo: PTypeInfo;
const APropertyUnitName, APropertyPath: string;
SourceChangeCache: TSourceChangeCache;
@ -120,10 +120,10 @@ type
function CreateExprListFromMethodTypeData(TypeData: PTypeData;
Params: TFindDeclarationParams; out List: TExprTypeList): boolean;
function FindPublishedMethodNodeInClass(ClassNode: TCodeTreeNode;
const UpperMethodName: string;
const AMethodName: string;
ExceptionOnNotFound: boolean): TFindContext;
function FindMethodNodeInImplementation(const UpperClassName,
UpperMethodName: string; BuildTreeBefore: boolean): TCodeTreeNode;
function FindMethodNodeInImplementation(const AClassName,
AMethodName: string; BuildTreeBefore: boolean): TCodeTreeNode;
function FindMethodTypeInfo(ATypeInfo: PTypeInfo;
const AStartUnitName: string = ''): TFindContext;
function MethodTypeDataToStr(TypeData: PTypeData;
@ -266,7 +266,7 @@ begin
end;
function TEventsCodeTool.GetCompatiblePublishedMethods(
const UpperClassName: string; TypeData: PTypeData;
const AClassName: string; TypeData: PTypeData;
const Proc: TGetStrProc): boolean;
var ClassNode: TCodeTreeNode;
begin
@ -275,10 +275,10 @@ begin
try
{$IFDEF CTDEBUG}
DebugLn('[TEventsCodeTool.GetCompatiblePublishedMethods] A UpperClassName=',
UpperClassName);
AClassName);
{$ENDIF}
BuildTree(lsrImplementationStart);
ClassNode:=FindClassNodeInInterface(UpperClassName,true,false,true);
ClassNode:=FindClassNodeInInterface(AClassName,true,false,true);
{$IFDEF CTDEBUG}
DebugLn('[TEventsCodeTool.GetCompatiblePublishedMethods] B ',dbgs(ClassNode<>nil));
{$ENDIF}
@ -443,13 +443,13 @@ begin
end;
function TEventsCodeTool.FindPublishedMethodNodeInClass(
ClassNode: TCodeTreeNode; const UpperMethodName: string;
ClassNode: TCodeTreeNode; const AMethodName: string;
ExceptionOnNotFound: boolean): TFindContext;
var
Params: TFindDeclarationParams;
begin
Result:=CleanFindContext;
if (ClassNode=nil) or (ClassNode.Desc<>ctnClass) or (UpperMethodName='')
if (ClassNode=nil) or (ClassNode.Desc<>ctnClass) or (AMethodName='')
or (Scanner=nil) then begin
DebugLn(['TEventsCodeTool.FindPublishedMethodNodeInClass invalid parameters']);
exit;
@ -459,7 +459,7 @@ begin
try
Params:=TFindDeclarationParams.Create;
Params.ContextNode:=ClassNode;
Params.SetIdentifier(Self,@UpperMethodName[1],nil);
Params.SetIdentifier(Self,@AMethodName[1],nil);
Params.Flags:=[fdfSearchInAncestors];
if ExceptionOnNotFound then Include(Params.Flags,fdfExceptionOnNotFound);
if FindIdentifierInContext(Params)
@ -474,30 +474,30 @@ begin
end;
end;
function TEventsCodeTool.FindMethodNodeInImplementation(const UpperClassName,
UpperMethodName: string; BuildTreeBefore: boolean): TCodeTreeNode;
function TEventsCodeTool.FindMethodNodeInImplementation(const AClassName,
AMethodName: string; BuildTreeBefore: boolean): TCodeTreeNode;
var SectionNode, ANode: TCodeTreeNode;
begin
Result:=nil;
if (UpperMethodName='') or (UpperClassName='') then exit;
if (AMethodName='') or (AClassName='') then exit;
if BuildTreeBefore then BuildTree(lsrEnd);
// find implementation node
SectionNode:=FindImplementationNode;
if SectionNode=nil then exit;
ANode:=SectionNode.FirstChild;
{$IFDEF CTDEBUG}
DebugLn('[TEventsCodeTool.FindMethodNodeInImplementation] A UpperMethodName=',UpperClassName,'.',UpperMethodName);
DebugLn('[TEventsCodeTool.FindMethodNodeInImplementation] A AMethodName=',AClassName,'.',AMethodName);
{$ENDIF}
while (ANode<>nil) do begin
if (ANode.Desc=ctnProcedure) and (ANode.FirstChild<>nil)
and CompareSrcIdentifiers(ANode.FirstChild.StartPos,@UpperClassName[1])
and CompareSrcIdentifiers(ANode.FirstChild.StartPos,@AClassName[1])
then begin
MoveCursorToNodeStart(ANode.FirstChild);
ReadNextAtom; // read class name
ReadNextAtom; // read '.'
if AtomIsChar('.') then begin
ReadNextAtom;
if CompareSrcIdentifiers(CurPos.StartPos,@UpperMethodName[1]) then
if CompareSrcIdentifiers(CurPos.StartPos,@AMethodName[1]) then
begin
{$IFDEF CTDEBUG}
DebugLn('[TEventsCodeTool.FindMethodNodeInImplementation] B body found');
@ -580,7 +580,7 @@ begin
ActivateGlobalWriteLock;
try
{$IFDEF CTDEBUG}
DebugLn('[TEventsCodeTool.PublishedMethodExists] A UpperClassName=',UpperClassName);
DebugLn('[TEventsCodeTool.PublishedMethodExists] A AClassName=',AClassName);
{$ENDIF}
BuildTree(lsrImplementationStart);
ClassNode:=FindClassNodeInInterface(AClassName,true,false,true);
@ -667,8 +667,8 @@ begin
end;
end;
function TEventsCodeTool.JumpToPublishedMethodBody(const UpperClassName,
UpperMethodName: string;
function TEventsCodeTool.JumpToPublishedMethodBody(const AClassName,
AMethodName: string;
out NewPos: TCodeXYPosition; out NewTopLine: integer): boolean;
var
ANode: TCodeTreeNode;
@ -681,23 +681,23 @@ begin
ActivateGlobalWriteLock;
try
BuildTree(lsrEnd);
ClassNode:=FindClassNodeInInterface(UpperClassName,true,false,true);
AFindContext:=FindPublishedMethodNodeInClass(ClassNode,UpperMethodName,true);
ClassNode:=FindClassNodeInInterface(AClassName,true,false,true);
AFindContext:=FindPublishedMethodNodeInClass(ClassNode,AMethodName,true);
if AFindContext.Node=nil then begin
DebugLn(['TEventsCodeTool.JumpToPublishedMethodBody method not found: ',UpperClassName,'.',UpperMethodName]);
DebugLn(['TEventsCodeTool.JumpToPublishedMethodBody method not found: ',AClassName,'.',AMethodName]);
exit;
end;
SrcTool:=TEventsCodeTool(AFindContext.Tool);
ClassNode:=AFindContext.Node.Parent.Parent;
if ClassNode.Desc<>ctnClass then begin
DebugLn(['TEventsCodeTool.JumpToPublishedMethodBody method found in non class',UpperClassName,'.',UpperMethodName,' in ',SrcTool.MainFilename,' Node=',ClassNode.DescAsString]);
DebugLn(['TEventsCodeTool.JumpToPublishedMethodBody method found in non class',AClassName,'.',AMethodName,' in ',SrcTool.MainFilename,' Node=',ClassNode.DescAsString]);
exit;
end;
SrcClassName:=SrcTool.ExtractClassName(ClassNode,true);
ANode:=SrcTool.FindMethodNodeInImplementation(
SrcClassName,UpperMethodName,true);
SrcClassName,AMethodName,true);
if ANode=nil then begin
DebugLn(['TEventsCodeTool.JumpToPublishedMethodBody method not found ',SrcClassName,'.',UpperMethodName,' in ',SrcTool.MainFilename]);
DebugLn(['TEventsCodeTool.JumpToPublishedMethodBody method not found ',SrcClassName,'.',AMethodName,' in ',SrcTool.MainFilename]);
exit;
end;
Result:=SrcTool.FindJumpPointInProcNode(ANode,NewPos,NewTopLine);
@ -706,45 +706,45 @@ begin
end;
end;
function TEventsCodeTool.RenamePublishedMethod(const UpperClassName,
UpperOldMethodName, NewMethodName: string;
function TEventsCodeTool.RenamePublishedMethod(const AClassName,
AOldMethodName, NewMethodName: string;
SourceChangeCache: TSourceChangeCache): boolean;
var ClassNode: TCodeTreeNode;
begin
BuildTree(lsrEnd);
ClassNode:=FindClassNodeInInterface(UpperClassName,true,false,true);
Result:=RenamePublishedMethod(ClassNode,UpperOldMethodName,NewMethodName,
ClassNode:=FindClassNodeInInterface(AClassName,true,false,true);
Result:=RenamePublishedMethod(ClassNode,AOldMethodName,NewMethodName,
SourceChangeCache);
end;
function TEventsCodeTool.RenamePublishedMethod(ClassNode: TCodeTreeNode;
const UpperOldMethodName, NewMethodName: string;
const AOldMethodName, NewMethodName: string;
SourceChangeCache: TSourceChangeCache): boolean;
// rename published method in class and in procedure itself
var ProcNode, ProcHeadNode: TCodeTreeNode;
NameStart, NameEnd: integer;
UpperClassName: string;
AClassName: string;
ProcBodyNode: TCodeTreeNode;
begin
Result:=false;
if (ClassNode=nil) or (ClassNode.Desc<>ctnClass) then
RaiseException('Invalid class node');
if (UpperOldMethodName='') then
RaiseException('Invalid UpperOldMethodName="'+UpperOldMethodName+'"');
if (AOldMethodName='') then
RaiseException('Invalid AOldMethodName="'+AOldMethodName+'"');
if (NewMethodName='') then
RaiseException('Invalid NewMethodName="'+NewMethodName+'"');
if (SourceChangeCache=nil) or (Scanner=nil) then
RaiseException('Invalid SourceChangeCache or Scanner');
SourceChangeCache.MainScanner:=Scanner;
// rename in class
ProcNode:=FindIdentifierNodeInClass(ClassNode,@UpperOldMethodName[1]);
ProcNode:=FindIdentifierNodeInClass(ClassNode,@AOldMethodName[1]);
if (ProcNode=nil) then begin
MoveCursorToNodeStart(ClassNode);
RaiseExceptionFmt(ctsOldMethodNotFound,[UpperOldMethodName]);
RaiseExceptionFmt(ctsOldMethodNotFound,[AOldMethodName]);
end;
if (ProcNode.Desc<>ctnProcedure) then begin
MoveCursorToNodeStart(ProcNode);
RaiseExceptionFmt(ctsOldMethodNotFound,[UpperOldMethodName]);
RaiseExceptionFmt(ctsOldMethodNotFound,[AOldMethodName]);
end;
ProcHeadNode:=ProcNode.FirstChild;
if ProcHeadNode=nil then begin
@ -765,9 +765,9 @@ begin
Result:=true;
// rename procedure body -> find implementation node
UpperClassName:=ExtractClassName(ClassNode,true);
ProcBodyNode:=FindMethodNodeInImplementation(UpperClassName,
UpperOldMethodName,false);
AClassName:=ExtractClassName(ClassNode,false);
ProcBodyNode:=FindMethodNodeInImplementation(AClassName,
AOldMethodName,false);
if (ProcBodyNode<>nil) and (ProcBodyNode<>nil) then begin
ProcHeadNode:=ProcBodyNode.FirstChild;
MoveCursorToNodeStart(ProcHeadNode);
@ -781,7 +781,7 @@ begin
Result:=SourceChangeCache.Apply;
end;
function TEventsCodeTool.CreateMethod(const UpperClassName,
function TEventsCodeTool.CreateMethod(const AClassName,
AMethodName: string; ATypeInfo: PTypeInfo;
const APropertyUnitName, APropertyPath: string;
SourceChangeCache: TSourceChangeCache;
@ -792,7 +792,7 @@ var AClassNode: TCodeTreeNode;
begin
Result:=false;
BuildTree(lsrEnd);
AClassNode:=FindClassNodeInInterface(UpperClassName,true,false,true);
AClassNode:=FindClassNodeInInterface(ClassName,true,false,true);
Result:=CreateMethod(AClassNode,AMethodName,ATypeInfo,
APropertyUnitName,APropertyPath,
SourceChangeCache,UseTypeInfoForParameters,Section,

View File

@ -82,7 +82,7 @@ type
SourceChangeCache: TSourceChangeCache): boolean;
// uses sections
function RenameUsedUnit(const OldUpperUnitName, NewUnitName,
function RenameUsedUnit(const OldUnitName, NewUnitName,
NewUnitInFile: string;
SourceChangeCache: TSourceChangeCache): boolean;
function ReplaceUsedUnits(UnitNamePairs: TStringToStringTree;
@ -103,15 +103,15 @@ type
SourceChangeCache: TSourceChangeCache;
AsLast: boolean = false; CheckSpecialUnits: boolean = true): boolean;
function UnitExistsInUsesSection(UsesSection: TUsesSection;
const UpperUnitName: string;
const AnUnitName: string;
SourceChangeCache: TSourceChangeCache): boolean;
function UnitExistsInUsesSection(UsesNode: TCodeTreeNode;
const UpperUnitName: string;
const AnUnitName: string;
SourceChangeCache: TSourceChangeCache): boolean;
function RemoveUnitFromUsesSection(UsesNode: TCodeTreeNode;
const UpperUnitName: string;
const AnUnitName: string;
SourceChangeCache: TSourceChangeCache): boolean;
function RemoveUnitFromAllUsesSections(const UpperUnitName: string;
function RemoveUnitFromAllUsesSections(const AnUnitName: string;
SourceChangeCache: TSourceChangeCache): boolean;
function FixUsedUnitCase(SourceChangeCache: TSourceChangeCache): boolean;
function FixUsedUnitCaseInUsesSection(UsesNode: TCodeTreeNode;
@ -156,11 +156,11 @@ type
// Application.Createform statements
function FindCreateFormStatement(StartPos: integer;
const UpperClassName, UpperVarName: string;
const AClassName, AVarName: string;
out Position: TAtomPosition): integer; // 0=found, -1=not found, 1=found, but wrong classname
function AddCreateFormStatement(const AClassName, AVarName: string;
SourceChangeCache: TSourceChangeCache): boolean;
function RemoveCreateFormStatement(const UpperVarName: string;
function RemoveCreateFormStatement(const AVarName: string;
SourceChangeCache: TSourceChangeCache): boolean;
function ChangeCreateFormStatement(StartPos: integer;
const OldClassName, OldVarName: string;
@ -185,19 +185,19 @@ type
function RenameForm(const OldFormName, OldFormClassName: string;
const NewFormName, NewFormClassName: string;
SourceChangeCache: TSourceChangeCache): boolean;
function FindFormAncestor(const UpperClassName: string;
function FindFormAncestor(const AClassName: string;
var AncestorClassName: string): boolean;
// published variables
function FindPublishedVariable(const UpperClassName, UpperVarName: string;
function FindPublishedVariable(const AClassName, AVarName: string;
ExceptionOnClassNotFound: boolean): TCodeTreeNode;
function AddPublishedVariable(const UpperClassName,VarName, VarType: string;
function AddPublishedVariable(const AClassName,VarName, VarType: string;
SourceChangeCache: TSourceChangeCache): boolean; virtual;
function RemovePublishedVariable(const UpperClassName, UpperVarName: string;
function RemovePublishedVariable(const AClassName, AVarName: string;
ExceptionOnClassNotFound: boolean;
SourceChangeCache: TSourceChangeCache): boolean;
function RenamePublishedVariable(const UpperClassName,
UpperOldVarName: string; const NewVarName, VarType: shortstring;
function RenamePublishedVariable(const AClassName,
AOldVarName: string; const NewVarName, VarType: shortstring;
ExceptionOnClassNotFound: boolean;
SourceChangeCache: TSourceChangeCache): boolean;
function GatherPublishedClassElements(const TheClassName: string;
@ -402,17 +402,17 @@ begin
Result:=true;
end;
function TStandardCodeTool.RenameUsedUnit(const OldUpperUnitName,
function TStandardCodeTool.RenameUsedUnit(const OldUnitName,
NewUnitName, NewUnitInFile: string;
SourceChangeCache: TSourceChangeCache): boolean;
var UnitPos, InPos: TAtomPosition;
NewUsesTerm: string;
begin
Result:=false;
if (OldUpperUnitName='') or (length(OldUpperUnitName)>255) or (NewUnitName='')
if (OldUnitName='') or (length(OldUnitName)>255) or (NewUnitName='')
or (length(NewUnitName)>255) then exit;
if not FindUnitInAllUsesSections(OldUpperUnitName,UnitPos,InPos) then begin
//debugln('TStandardCodeTool.RenameUsedUnit not found: ',OldUpperUnitName,' ');
if not FindUnitInAllUsesSections(OldUnitName,UnitPos,InPos) then begin
//debugln('TStandardCodeTool.RenameUsedUnit not found: ',OldUnitName,' ');
exit;
end;
SourceChangeCache.MainScanner:=Scanner;
@ -944,7 +944,7 @@ begin
end;
if UsesNode<>nil then begin
// add unit to existing uses section
if not (FindUnitInUsesSection(UsesNode,UpperCaseStr(NewUnitName),Junk,Junk))
if not (FindUnitInUsesSection(UsesNode,NewUnitName,Junk,Junk))
then begin
if not AddUnitToUsesSection(UsesNode,NewUnitName,NewUnitInFile,
SourceChangeCache,AsLast,CheckSpecialUnits)
@ -1018,12 +1018,12 @@ begin
end;
function TStandardCodeTool.UnitExistsInUsesSection(UsesSection: TUsesSection;
const UpperUnitName: string; SourceChangeCache: TSourceChangeCache): boolean;
const AnUnitName: string; SourceChangeCache: TSourceChangeCache): boolean;
var
UsesNode: TCodeTreeNode;
begin
Result:=false;
if (UpperUnitName='') or (length(UpperUnitName)>255) then
if (AnUnitName='') or (length(AnUnitName)>255) then
exit;
if UsesSection=usMain then
BuildTree(lsrMainUsesSectionEnd)
@ -1034,16 +1034,16 @@ begin
usMain: UsesNode:=FindMainUsesSection;
usImplementation: UsesNode:=FindImplementationUsesSection;
end;
Result:=UnitExistsInUsesSection(UsesNode,UpperUnitName,SourceChangeCache);
Result:=UnitExistsInUsesSection(UsesNode,AnUnitName,SourceChangeCache);
end;
function TStandardCodeTool.UnitExistsInUsesSection(UsesNode: TCodeTreeNode;
const UpperUnitName: string; SourceChangeCache: TSourceChangeCache): boolean;
const AnUnitName: string; SourceChangeCache: TSourceChangeCache): boolean;
var
UnitCount: integer;
begin
Result:=false;
if (UsesNode=nil) or (UpperUnitName='') or (length(UpperUnitName)>255) then
if (UsesNode=nil) or (AnUnitName='') or (length(AnUnitName)>255) then
exit;
MoveCursorToNodeStart(UsesNode);
ReadNextAtom; // read 'uses'
@ -1052,7 +1052,7 @@ begin
ReadNextAtom; // read name
if not AtomIsIdentifier(false) then exit;
inc(UnitCount);
if UpAtomIs(UpperUnitName) then begin
if AtomIs(AnUnitName) then begin
// unit found
Result:=true;
exit;
@ -1068,11 +1068,11 @@ begin
end;
function TStandardCodeTool.RemoveUnitFromUsesSection(UsesNode: TCodeTreeNode;
const UpperUnitName: string; SourceChangeCache: TSourceChangeCache): boolean;
const AnUnitName: string; SourceChangeCache: TSourceChangeCache): boolean;
var UnitPos, StartPos, EndPos: integer;
begin
Result:=false;
if (UsesNode=nil) or (UpperUnitName='') or (length(UpperUnitName)>255) then
if (UsesNode=nil) or (AnUnitName='') or (length(AnUnitName)>255) then
exit;
MoveCursorToNodeStart(UsesNode);
ReadNextAtom; // read 'uses'
@ -1082,7 +1082,7 @@ begin
ReadNextAtom; // read name
if not AtomIsIdentifier(false) then exit;
inc(UnitPos);
if UpAtomIs(UpperUnitName) then begin
if AtomIs(AnUnitName) then begin
// unit found
SourceChangeCache.MainScanner:=Scanner;
StartPos:=CurPos.StartPos;
@ -1127,11 +1127,11 @@ begin
end;
function TStandardCodeTool.RemoveUnitFromAllUsesSections(
const UpperUnitName: string; SourceChangeCache: TSourceChangeCache): boolean;
const AnUnitName: string; SourceChangeCache: TSourceChangeCache): boolean;
var SectionNode: TCodeTreeNode;
begin
Result:=false;
if (UpperUnitName='') or (SourceChangeCache=nil) then exit;
if (AnUnitName='') or (SourceChangeCache=nil) then exit;
BuildTree(lsrImplementationUsesSectionEnd);
SourceChangeCache.BeginUpdate;
@ -1140,7 +1140,7 @@ begin
while (SectionNode<>nil) do begin
if (SectionNode.FirstChild<>nil)
and (SectionNode.FirstChild.Desc=ctnUsesSection) then begin
if not RemoveUnitFromUsesSection(SectionNode.FirstChild,UpperUnitName,
if not RemoveUnitFromUsesSection(SectionNode.FirstChild,AnUnitName,
SourceChangeCache)
then begin
exit;
@ -2668,7 +2668,7 @@ var
LookupRootLFMNode:=TLFMObjectNode(RootLFMNode);
// get type name of root object
LookupRootTypeName:=UpperCaseStr(LookupRootLFMNode.TypeName);
LookupRootTypeName:=LookupRootLFMNode.TypeName;
if LookupRootTypeName='' then begin
LFMTree.AddError(lfmeMissingRoot,nil,'missing type of root object',1);
exit;
@ -2727,7 +2727,7 @@ begin
end;
function TStandardCodeTool.FindCreateFormStatement(StartPos: integer;
const UpperClassName, UpperVarName: string;
const AClassName, AVarName: string;
out Position: TAtomPosition): integer;
// 0=found, -1=not found, 1=found, but wrong classname
var MainBeginNode: TCodeTreeNode;
@ -2735,8 +2735,8 @@ var MainBeginNode: TCodeTreeNode;
begin
Result:=-1;
Position.StartPos:=-1;
if (UpperClassName='') or (UpperVarName='') or (length(UpperClassName)>255)
or (length(UpperVarName)>255) then exit;
if (AClassName='') or (AVarName='') or (length(AClassName)>255)
or (length(AVarName)>255) then exit;
if StartPos<1 then begin
BuildTree(lsrEnd);
MainBeginNode:=FindMainBeginEndNode;
@ -2752,9 +2752,9 @@ begin
if ReadNextAtomIsChar('.') and ReadNextUpAtomIs('CREATEFORM')
and ReadNextAtomIsChar('(') then begin
ReadNextAtom;
ClassNameFits:=UpAtomIs(UpperClassName);
ClassNameFits:=AtomIs(AClassName);
if ReadNextAtomIsChar(',')
and (ReadNextUpAtomIs(UpperVarName) or (UpperVarName='*')) then begin
and (ReadNextAtomIs(AVarName) or (AVarName='*')) then begin
if ReadNextAtomIsChar(')') then ReadNextAtomIsChar(';');
Position.EndPos:=CurPos.EndPos;
if ClassNameFits then
@ -2782,8 +2782,8 @@ begin
MainBeginNode:=FindMainBeginEndNode;
if MainBeginNode=nil then exit;
FromPos:=-1;
if FindCreateFormStatement(MainBeginNode.StartPos,UpperCaseStr(AClassName),
UpperCaseStr(AVarName),OldPosition)=-1
if FindCreateFormStatement(MainBeginNode.StartPos,AClassName,
AVarName,OldPosition)=-1
then begin
// does not exist -> create as last in front of 'Application.Run'
MoveCursorToCleanPos(MainBeginNode.StartPos);
@ -2816,13 +2816,13 @@ begin
Result:=SourceChangeCache.Apply;
end;
function TStandardCodeTool.RemoveCreateFormStatement(const UpperVarName: string;
function TStandardCodeTool.RemoveCreateFormStatement(const AVarName: string;
SourceChangeCache: TSourceChangeCache): boolean;
var Position: TAtomPosition;
FromPos, ToPos: integer;
begin
Result:=false;
if FindCreateFormStatement(-1,'*',UpperVarName,Position)=-1 then
if FindCreateFormStatement(-1,'*',AVarName,Position)=-1 then
exit;
FromPos:=FindLineEndOrCodeInFrontOfPosition(Position.StartPos);
ToPos:=FindLineEndOrCodeAfterPosition(Position.EndPos);
@ -2849,8 +2849,8 @@ begin
MainBeginNode:=FindMainBeginEndNode;
if MainBeginNode=nil then exit;
FromPos:=-1;
if FindCreateFormStatement(MainBeginNode.StartPos,UpperCaseStr(OldClassName),
UpperCaseStr(OldVarName),OldPosition)=-1 then begin
if FindCreateFormStatement(MainBeginNode.StartPos,OldClassName,
OldVarName,OldPosition)=-1 then begin
// does not exist
if OnlyIfExists then begin
Result:=true;
@ -3128,16 +3128,16 @@ begin
end;
end;
function TStandardCodeTool.FindFormAncestor(const UpperClassName: string;
function TStandardCodeTool.FindFormAncestor(const AClassName: string;
var AncestorClassName: string): boolean;
var
ClassNode: TCodeTreeNode;
begin
Result:=false;
AncestorClassName:='';
if UpperClassName='' then exit;
if AClassName='' then exit;
BuildTree(lsrImplementationStart);
ClassNode:=FindClassNodeInInterface(UpperClassName,true,false,false);
ClassNode:=FindClassNodeInInterface(AClassName,true,false,false);
if (ClassNode=nil) then exit;
// search the ancestor name
MoveCursorToNodeStart(ClassNode);
@ -4380,18 +4380,18 @@ begin
//DebugLn('TStandardCodeTool.AddResourcestring END ',Result);
end;
function TStandardCodeTool.FindPublishedVariable(const UpperClassName,
UpperVarName: string; ExceptionOnClassNotFound: boolean): TCodeTreeNode;
function TStandardCodeTool.FindPublishedVariable(const AClassName,
AVarName: string; ExceptionOnClassNotFound: boolean): TCodeTreeNode;
var ClassNode, SectionNode: TCodeTreeNode;
begin
Result:=nil;
if (UpperClassName='') or (length(UpperClassName)>255) then
RaiseException(Format(ctsinvalidClassName, ['"', UpperClassName, '"']));
if (AClassName='') or (length(AClassName)>255) then
RaiseException(Format(ctsinvalidClassName, ['"', AClassName, '"']));
BuildTree(lsrImplementationStart);
ClassNode:=FindClassNodeInInterface(UpperClassName,true,false,false);
ClassNode:=FindClassNodeInInterface(AClassName,true,false,false);
if ClassNode=nil then begin
if ExceptionOnClassNotFound then
RaiseException(Format(ctsclassNotFound, ['"', UpperClassName, '"']))
RaiseException(Format(ctsclassNotFound, ['"', AClassName, '"']))
else
exit;
end;
@ -4402,7 +4402,7 @@ begin
while Result<>nil do begin
if (Result.Desc=ctnVarDefinition) then begin
MoveCursorToNodeStart(Result);
if ReadNextUpAtomIs(UpperVarName) then
if ReadNextAtomIs(AVarName) then
exit;
end;
Result:=Result.NextBrother;
@ -4412,28 +4412,28 @@ begin
end;
end;
function TStandardCodeTool.AddPublishedVariable(const UpperClassName,
function TStandardCodeTool.AddPublishedVariable(const AClassName,
VarName, VarType: string; SourceChangeCache: TSourceChangeCache): boolean;
var ClassNode, SectionNode: TCodeTreeNode;
Indent, InsertPos: integer;
begin
Result:=false;
if (UpperClassName='') or (length(UpperClassName)>255) then
RaiseException(Format(ctsinvalidClassName2, ['"', UpperClassName, '"']));
if (AClassName='') or (length(AClassName)>255) then
RaiseException(Format(ctsinvalidClassName2, ['"', AClassName, '"']));
if (VarName='') or (length(VarName)>255) then
RaiseException(Format(ctsinvalidVariableName, ['"', VarName, '"']));
if (VarType='') or (length(VarType)>255) then
RaiseException(Format(ctsinvalidVariableType, ['"', VarType, '"']));
if (SourceChangeCache=nil) then
RaiseException('missing SourceChangeCache');
if FindPublishedVariable(UpperClassName,UpperCaseStr(VarName),true)<>nil then
if FindPublishedVariable(AClassName,VarName,true)<>nil then
begin
Result:=true;
exit;
end;
ClassNode:=FindClassNodeInInterface(UpperClassName,true,false,true);
ClassNode:=FindClassNodeInInterface(AClassName,true,false,true);
if ClassNode=nil then
RaiseException(Format(ctsclassNotFound, ['"', UpperClassName, '"']));
RaiseException(Format(ctsclassNotFound, ['"', AClassName, '"']));
SectionNode:=ClassNode.FirstChild;
if (SectionNode.NextBrother<>nil)
and (SectionNode.NextBrother.Desc=ctnClassPublished) then
@ -4453,14 +4453,14 @@ begin
Result:=SourceChangeCache.Apply;
end;
function TStandardCodeTool.RemovePublishedVariable(const UpperClassName,
UpperVarName: string; ExceptionOnClassNotFound: boolean;
function TStandardCodeTool.RemovePublishedVariable(const AClassName,
AVarName: string; ExceptionOnClassNotFound: boolean;
SourceChangeCache: TSourceChangeCache): boolean;
var VarNode: TCodeTreeNode;
FromPos, ToPos: integer;
begin
Result:=false;
VarNode:=FindPublishedVariable(UpperClassName,UpperVarName,
VarNode:=FindPublishedVariable(AClassName,AVarName,
ExceptionOnClassNotFound);
if VarNode=nil then exit;
if (VarNode.PriorBrother<>nil)
@ -4495,8 +4495,8 @@ begin
Result:=SourceChangeCache.Apply;
end;
function TStandardCodeTool.RenamePublishedVariable(const UpperClassName,
UpperOldVarName: string; const NewVarName, VarType: shortstring;
function TStandardCodeTool.RenamePublishedVariable(const AClassName,
AOldVarName: string; const NewVarName, VarType: shortstring;
ExceptionOnClassNotFound: boolean;
SourceChangeCache: TSourceChangeCache): boolean;
var
@ -4505,7 +4505,7 @@ var
begin
Result:=false;
BuildTree(lsrEnd);
VarNode:=FindPublishedVariable(UpperClassName,UpperOldVarName,
VarNode:=FindPublishedVariable(AClassName,AOldVarName,
ExceptionOnClassNotFound);
if VarNode<>nil then begin
// old variable found
@ -4525,13 +4525,13 @@ begin
end;
end;
// rename variable in source
if not ReplaceWord(UpperOldVarName,NewVarName,false,SourceChangeCache,true)
if not ReplaceWord(AOldVarName,NewVarName,false,SourceChangeCache,true)
then
exit;
Result:=(not ApplyNeeded) or SourceChangeCache.Apply;
end else begin
// old variable not found -> add it
Result:=AddPublishedVariable(UpperClassName,NewVarName,VarType,
Result:=AddPublishedVariable(AClassName,NewVarName,VarType,
SourceChangeCache);
end;
end;

View File

@ -5092,10 +5092,6 @@ begin
end;
procedure TCustomTreeView.WMLButtonDown(var AMessage: TLMLButtonDown);
{var
Node: TTreeNode;
MousePos: TPoint;
P: TSmallPoint;}
begin
{$IFDEF VerboseDrag}
DebugLn('TCustomTreeView.WMLButtonDown A ',Name,':',ClassName,' ');