mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-18 21:59:48 +02:00
IDE: implemented renaming inherited form and references in unit (simple search and replace, but better than no replace)
git-svn-id: trunk@10163 -
This commit is contained in:
parent
2448617cd6
commit
52994ffffc
@ -168,7 +168,7 @@ each control that's dropped onto the form
|
||||
function FindNonControlForm(LookupRoot: TComponent): TNonControlDesignerForm;
|
||||
function CreateNonControlForm(LookupRoot: TComponent): TNonControlDesignerForm;
|
||||
procedure RenameJITComponent(AComponent: TComponent;
|
||||
const NewName: shortstring);
|
||||
const NewClassName: shortstring);
|
||||
procedure RenameJITComponentUnitname(AComponent: TComponent;
|
||||
const NewUnitName: shortstring);
|
||||
procedure UpdateDesignerFormName(AComponent: TComponent);
|
||||
@ -1141,14 +1141,14 @@ begin
|
||||
end;
|
||||
|
||||
procedure TCustomFormEditor.RenameJITComponent(AComponent: TComponent;
|
||||
const NewName: shortstring);
|
||||
const NewClassName: shortstring);
|
||||
var
|
||||
JITComponentList: TJITComponentList;
|
||||
begin
|
||||
JITComponentList:=FindJITList(AComponent);
|
||||
if JITComponentList=nil then
|
||||
RaiseException('TCustomFormEditor.RenameJITComponent');
|
||||
JITComponentList.RenameComponentClass(AComponent,NewName);
|
||||
JITComponentList.RenameComponentClass(AComponent,NewClassName);
|
||||
end;
|
||||
|
||||
procedure TCustomFormEditor.RenameJITComponentUnitname(AComponent: TComponent;
|
||||
|
19
ide/main.pp
19
ide/main.pp
@ -11408,6 +11408,8 @@ var
|
||||
BossResult: boolean;
|
||||
AncestorRoot: TComponent;
|
||||
s: String;
|
||||
OldName: String;
|
||||
OldClassName: String;
|
||||
|
||||
procedure ApplyBossResult(const ErrorMsg: string);
|
||||
var
|
||||
@ -11460,6 +11462,15 @@ var
|
||||
and (DependingUnit.Component.ClassParent=RenamedUnit.Component.ClassType)
|
||||
then begin
|
||||
// the root component inherits from the DependingUnit root component
|
||||
if DependingUnit.Component.ClassParent=AComponent.ClassType then begin
|
||||
if OldClassName<>AComponent.ClassName then begin
|
||||
// replace references to classname, ignoring errors
|
||||
CodeToolBoss.ReplaceWord(DependingUnit.Source,
|
||||
OldClassName,AComponent.ClassName);
|
||||
end;
|
||||
end;
|
||||
|
||||
// rename inherited component
|
||||
InheritedComponent:=
|
||||
DependingUnit.Component.FindComponent(AComponent.Name);
|
||||
if InheritedComponent<>nil then begin
|
||||
@ -11470,6 +11481,7 @@ var
|
||||
try
|
||||
DebugLn(['RenameInheritedComponents ',dbgsName(InheritedComponent),' Owner=',dbgsName(InheritedComponent.Owner)]);
|
||||
if Simulate then begin
|
||||
// only check if rename is possible
|
||||
if (InheritedComponent.Owner<>nil)
|
||||
and (InheritedComponent.Owner.FindComponent(NewName)<>nil) then
|
||||
begin
|
||||
@ -11478,10 +11490,13 @@ var
|
||||
NewName, '"', dbgsName(InheritedComponent.Owner)]);
|
||||
end;
|
||||
end else begin
|
||||
// rename component and references in code
|
||||
InheritedComponent.Name:=NewName;
|
||||
DependingDesigner:=GetDesignerFormOfSource(DependingUnit,false);
|
||||
if DependingDesigner<>nil then
|
||||
DependingUnit.Modified:=true;
|
||||
// replace references, ignoring errors
|
||||
CodeToolBoss.ReplaceWord(DependingUnit.Source,OldName,NewName);
|
||||
end;
|
||||
finally
|
||||
if FRenamingComponents<>nil then begin
|
||||
@ -11529,6 +11544,10 @@ begin
|
||||
raise EComponentError.Create(s);
|
||||
end;
|
||||
|
||||
|
||||
OldName:=AComponent.Name;
|
||||
OldClassName:=AComponent.ClassName;
|
||||
|
||||
// check inherited components
|
||||
RenameInheritedComponents(ActiveUnitInfo,true);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user