Use the new parameter signature for RetypeClassVariables.

git-svn-id: trunk@24224 -
This commit is contained in:
juha 2010-03-26 14:34:33 +00:00
parent ca0b3c395b
commit 1d27d08993
2 changed files with 18 additions and 25 deletions

View File

@ -44,7 +44,7 @@ type
// List of units to be commented. // List of units to be commented.
fUnitsToComment: TStringList; fUnitsToComment: TStringList;
// Map of class member object types to be renamed in ReplaceMemberTypes. // Map of class member object types to be renamed in ReplaceMemberTypes.
fMemberTypesToRename: TStringList; // TStringToStringTree; fMemberTypesToRename: TStringToStringTree;
function AddDelphiAndLCLSections: boolean; function AddDelphiAndLCLSections: boolean;
function AddModeDelphiDirective: boolean; function AddModeDelphiDirective: boolean;
function RenameResourceDirectives: boolean; function RenameResourceDirectives: boolean;
@ -68,8 +68,8 @@ type
property UnitsToRename: TStringToStringTree read fUnitsToRename write fUnitsToRename; property UnitsToRename: TStringToStringTree read fUnitsToRename write fUnitsToRename;
property UnitsToAdd: TStringList read fUnitsToAdd write fUnitsToAdd; property UnitsToAdd: TStringList read fUnitsToAdd write fUnitsToAdd;
property UnitsToComment: TStringList read fUnitsToComment write fUnitsToComment; property UnitsToComment: TStringList read fUnitsToComment write fUnitsToComment;
property MemberTypesToRename: TStringList read fMemberTypesToRename property MemberTypesToRename: TStringToStringTree read fMemberTypesToRename
write fMemberTypesToRename; write fMemberTypesToRename;
end; end;
implementation implementation

View File

@ -122,8 +122,7 @@ var
TheNode: TLFMTreeNode; TheNode: TLFMTreeNode;
ObjNode: TLFMObjectNode; ObjNode: TLFMObjectNode;
// Property name --> replacement name. // Property name --> replacement name.
PropNameRepl: TStringToStringTree; NameReplacements: TStringToStringTree;
MemberTypes: TStringList;
// List of TLFMChangeEntry objects. // List of TLFMChangeEntry objects.
ChgEntryRepl: TObjectList; ChgEntryRepl: TObjectList;
OldIdent, NewIdent: string; OldIdent, NewIdent: string;
@ -132,15 +131,14 @@ var
begin begin
Result:=mrNone; Result:=mrNone;
ChgEntryRepl:=TObjectList.Create; ChgEntryRepl:=TObjectList.Create;
PropNameRepl:=TStringToStringTree.Create(false); NameReplacements:=TStringToStringTree.Create(false);
MemberTypes:=TStringList.Create;
try try
// Collect (maybe edited) properties from StringGrid to PropNameRepl. // Collect (maybe edited) properties from StringGrid to NameReplacements.
for i:=1 to fPropReplaceGrid.RowCount-1 do begin // Skip the fixed row. for i:=1 to fPropReplaceGrid.RowCount-1 do begin // Skip the fixed row.
OldIdent:=fPropReplaceGrid.Cells[0,i]; OldIdent:=fPropReplaceGrid.Cells[0,i];
NewIdent:=fPropReplaceGrid.Cells[1,i]; NewIdent:=fPropReplaceGrid.Cells[1,i];
if NewIdent<>'' then if NewIdent<>'' then
PropNameRepl[OldIdent]:=NewIdent; NameReplacements[OldIdent]:=NewIdent;
end; end;
// Replace each missing property / type or delete it if no replacement. // Replace each missing property / type or delete it if no replacement.
CurError:=fLFMTree.LastError; CurError:=fLFMTree.LastError;
@ -153,19 +151,17 @@ begin
OldIdent:=ObjNode.TypeName; OldIdent:=ObjNode.TypeName;
StartPos:=ObjNode.TypeNamePosition; StartPos:=ObjNode.TypeNamePosition;
EndPos:=StartPos+Length(OldIdent); EndPos:=StartPos+Length(OldIdent);
NewIdent:=PropNameRepl[OldIdent]; NewIdent:=NameReplacements[OldIdent];
// Keep the old class name if no replacement. // Keep the old class name if no replacement.
if NewIdent<>'' then begin if NewIdent<>'' then
AddReplacement(ChgEntryRepl,StartPos,EndPos,NewIdent); AddReplacement(ChgEntryRepl,StartPos,EndPos,NewIdent);
MemberTypes.Values[OldIdent]:=NewIdent;
end;
end end
else begin else begin
// Property // Property
TheNode.FindIdentifier(StartPos,EndPos); TheNode.FindIdentifier(StartPos,EndPos);
if StartPos>0 then begin if StartPos>0 then begin
OldIdent:=copy(fLFMBuffer.Source,StartPos,EndPos-StartPos); OldIdent:=copy(fLFMBuffer.Source,StartPos,EndPos-StartPos);
NewIdent:=PropNameRepl[OldIdent]; NewIdent:=NameReplacements[OldIdent];
// Delete the whole property line if no replacement. // Delete the whole property line if no replacement.
if NewIdent='' then if NewIdent='' then
FindNiceNodeBounds(TheNode,StartPos,EndPos); FindNiceNodeBounds(TheNode,StartPos,EndPos);
@ -177,21 +173,18 @@ begin
end; end;
// Apply replacements to LFM. // Apply replacements to LFM.
if ApplyReplacements(ChgEntryRepl) then begin if ApplyReplacements(ChgEntryRepl) then begin
if MemberTypes.Count>0 then begin // Replace the object member types also to pascal source.
// Replace the object member types also to pascal source. ConvTool:=TConvDelphiCodeTool.Create(fPascalBuffer);
ConvTool:=TConvDelphiCodeTool.Create(fPascalBuffer); try
try ConvTool.MemberTypesToRename:=NameReplacements;
ConvTool.MemberTypesToRename:=MemberTypes; ConvTool.ReplaceMemberTypes(TLFMObjectNode(fLFMTree.Root).TypeName);
ConvTool.ReplaceMemberTypes(TLFMObjectNode(fLFMTree.Root).TypeName); finally
finally ConvTool.Free;
ConvTool.Free;
end;
end; end;
Result:=mrOk; Result:=mrOk;
end; end;
finally finally
MemberTypes.Free; NameReplacements.Free;
PropNameRepl.Free;
ChgEntryRepl.Free; ChgEntryRepl.Free;
end; end;
end; end;