mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-20 01:49:11 +02:00
IDE: Show methods when clicked in OI also when they are in another unit/form. Issue #25954.
git-svn-id: trunk@52020 -
This commit is contained in:
parent
3855ea4ebd
commit
75791c984b
@ -1165,8 +1165,8 @@ type
|
|||||||
// methods
|
// methods
|
||||||
TPropHookCreateMethod = function(const Name: ShortString; ATypeInfo: PTypeInfo;
|
TPropHookCreateMethod = function(const Name: ShortString; ATypeInfo: PTypeInfo;
|
||||||
APersistent: TPersistent; const APropertyPath: string): TMethod of object;
|
APersistent: TPersistent; const APropertyPath: string): TMethod of object;
|
||||||
TPropHookGetMethodName = function(const Method: TMethod;
|
TPropHookGetMethodName = function(const Method: TMethod; CheckOwner: TObject;
|
||||||
CheckOwner: TObject): String of object;
|
OrigLookupRoot: TPersistent): String of object;
|
||||||
TPropHookGetCompatibleMethods = procedure(InstProp: PInstProp; const Proc: TGetStrProc) of object;
|
TPropHookGetCompatibleMethods = procedure(InstProp: PInstProp; const Proc: TGetStrProc) of object;
|
||||||
TPropHookGetMethods = procedure(TypeData: PTypeData; Proc: TGetStrProc) of object;
|
TPropHookGetMethods = procedure(TypeData: PTypeData; Proc: TGetStrProc) of object;
|
||||||
TPropHookCompatibleMethodExists = function(const Name: String; InstProp: PInstProp;
|
TPropHookCompatibleMethodExists = function(const Name: String; InstProp: PInstProp;
|
||||||
@ -4283,6 +4283,22 @@ begin
|
|||||||
Result := True;
|
Result := True;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function IsValidPropName(const PropName: string): boolean;
|
||||||
|
var
|
||||||
|
i, len: integer;
|
||||||
|
begin
|
||||||
|
result := false;
|
||||||
|
len := length(PropName);
|
||||||
|
if len <> 0 then begin
|
||||||
|
result := PropName[1] in ['A'..'Z', 'a'..'z', '_'];
|
||||||
|
i := 1;
|
||||||
|
while (result) and (i < len) do begin
|
||||||
|
i := i + 1;
|
||||||
|
result := result and (PropName[i] in ['A'..'Z', 'a'..'z', '0'..'9', '_', '.']);
|
||||||
|
end ;
|
||||||
|
end ;
|
||||||
|
end ;
|
||||||
|
|
||||||
procedure TMethodPropertyEditor.Edit;
|
procedure TMethodPropertyEditor.Edit;
|
||||||
{ If the method does not exist in current lookuproot: create it
|
{ If the method does not exist in current lookuproot: create it
|
||||||
Then jump to the source.
|
Then jump to the source.
|
||||||
@ -4291,11 +4307,11 @@ procedure TMethodPropertyEditor.Edit;
|
|||||||
the ancestor value is added. Then the IDE jumps to the new method body.
|
the ancestor value is added. Then the IDE jumps to the new method body.
|
||||||
}
|
}
|
||||||
var
|
var
|
||||||
NewMethodName: shortstring;
|
NewMethodName: String;
|
||||||
begin
|
begin
|
||||||
NewMethodName := GetValue;
|
NewMethodName := GetValue;
|
||||||
//DebugLn('### TMethodPropertyEditor.Edit A OldValue=',NewMethodName);
|
//DebugLn('### TMethodPropertyEditor.Edit A OldValue=',NewMethodName);
|
||||||
if not IsValidIdent(NewMethodName) or PropertyHook.MethodFromAncestor(GetMethodValue) then
|
if not IsValidPropName(NewMethodName) or PropertyHook.MethodFromAncestor(GetMethodValue) then
|
||||||
begin
|
begin
|
||||||
// the current method is from the ancestor
|
// the current method is from the ancestor
|
||||||
// -> add an override with the default name
|
// -> add an override with the default name
|
||||||
@ -5592,7 +5608,7 @@ var
|
|||||||
begin
|
begin
|
||||||
i:=GetHandlerCount(htGetMethodName);
|
i:=GetHandlerCount(htGetMethodName);
|
||||||
if GetNextHandlerIndex(htGetMethodName,i) then begin
|
if GetNextHandlerIndex(htGetMethodName,i) then begin
|
||||||
Result:=TPropHookGetMethodName(FHandlers[htGetMethodName][i])(Method,PropOwner);
|
Result:=TPropHookGetMethodName(FHandlers[htGetMethodName][i])(Method,PropOwner,LookupRoot);
|
||||||
end else begin
|
end else begin
|
||||||
// search the method name with the given code pointer
|
// search the method name with the given code pointer
|
||||||
if Assigned(Method.Code) then begin
|
if Assigned(Method.Code) then begin
|
||||||
|
24
ide/main.pp
24
ide/main.pp
@ -506,8 +506,8 @@ type
|
|||||||
function OIOnPropertyHint(Sender: TObject; PointedRow: TOIPropertyGridRow;
|
function OIOnPropertyHint(Sender: TObject; PointedRow: TOIPropertyGridRow;
|
||||||
out AHint: string): boolean;
|
out AHint: string): boolean;
|
||||||
procedure OIOnUpdateRestricted(Sender: TObject);
|
procedure OIOnUpdateRestricted(Sender: TObject);
|
||||||
function OnPropHookGetMethodName(const Method: TMethod;
|
function OnPropHookGetMethodName(const Method: TMethod; PropOwner: TObject;
|
||||||
PropOwner: TObject): String;
|
OrigLookupRoot: TPersistent): String;
|
||||||
procedure OnPropHookGetMethods(TypeData: PTypeData; Proc:TGetStrProc);
|
procedure OnPropHookGetMethods(TypeData: PTypeData; Proc:TGetStrProc);
|
||||||
procedure OnPropHookGetCompatibleMethods(InstProp: PInstProp;
|
procedure OnPropHookGetCompatibleMethods(InstProp: PInstProp;
|
||||||
const Proc:TGetStrProc);
|
const Proc:TGetStrProc);
|
||||||
@ -1832,8 +1832,10 @@ begin
|
|||||||
(Sender as TObjectInspectorDlg).RestrictedProps := GetRestrictedProperties;
|
(Sender as TObjectInspectorDlg).RestrictedProps := GetRestrictedProperties;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TMainIDE.OnPropHookGetMethodName(const Method: TMethod;
|
function TMainIDE.OnPropHookGetMethodName(const Method: TMethod; PropOwner: TObject;
|
||||||
PropOwner: TObject): String;
|
OrigLookupRoot: TPersistent): String;
|
||||||
|
// OrigLookupRoot can be different from the PropOwner's LookupRoot when we refer
|
||||||
|
// to an object (eg. TAction) in another form / unit.
|
||||||
var
|
var
|
||||||
JITMethod: TJITMethod;
|
JITMethod: TJITMethod;
|
||||||
LookupRoot: TPersistent;
|
LookupRoot: TPersistent;
|
||||||
@ -1845,18 +1847,19 @@ begin
|
|||||||
Result:='<Unpublished>';
|
Result:='<Unpublished>';
|
||||||
end else
|
end else
|
||||||
Result:='<No LookupRoot>';
|
Result:='<No LookupRoot>';
|
||||||
end else if IsJITMethod(Method) then begin
|
end
|
||||||
|
else if IsJITMethod(Method) then begin
|
||||||
JITMethod:=TJITMethod(Method.Data);
|
JITMethod:=TJITMethod(Method.Data);
|
||||||
Result:=JITMethod.TheMethodName;
|
Result:=JITMethod.TheMethodName;
|
||||||
if PropOwner is TComponent then begin
|
if PropOwner is TComponent then begin
|
||||||
LookupRoot:=GetLookupRootForComponent(TComponent(PropOwner));
|
LookupRoot:=GetLookupRootForComponent(TComponent(PropOwner));
|
||||||
if LookupRoot is TComponent then begin
|
if LookupRoot is TComponent then begin
|
||||||
//DebugLn(['TMainIDE.OnPropHookGetMethodName ',Result,' GlobalDesignHook.LookupRoot=',dbgsName(GlobalDesignHook.LookupRoot),' JITMethod.TheClass=',dbgsName(JITMethod.TheClass),' PropOwner=',DbgSName(PropOwner),' PropOwner-LookupRoot=',DbgSName(LookupRoot)]);
|
//DebugLn(['TMainIDE.OnPropHookGetMethodName ',Result,' GlobalDesignHook.LookupRoot=',dbgsName(GlobalDesignHook.LookupRoot),' JITMethod.TheClass=',dbgsName(JITMethod.TheClass),' PropOwner=',DbgSName(PropOwner),' PropOwner-LookupRoot=',DbgSName(LookupRoot)]);
|
||||||
if (LookupRoot.ClassType<>JITMethod.TheClass) then begin
|
if (LookupRoot.ClassType<>JITMethod.TheClass)
|
||||||
|
or (LookupRoot<>OrigLookupRoot) then
|
||||||
Result:=JITMethod.TheClass.ClassName+'.'+Result;
|
Result:=JITMethod.TheClass.ClassName+'.'+Result;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
|
||||||
end else
|
end else
|
||||||
Result:='';
|
Result:='';
|
||||||
{$IFDEF VerboseDanglingComponentEvents}
|
{$IFDEF VerboseDanglingComponentEvents}
|
||||||
@ -9305,13 +9308,14 @@ begin
|
|||||||
Result:=TObject(Method.Data).MethodName(Method.Code)
|
Result:=TObject(Method.Data).MethodName(Method.Code)
|
||||||
else
|
else
|
||||||
Result:='';
|
Result:='';
|
||||||
end else if IsJITMethod(Method) then begin
|
end
|
||||||
|
else if IsJITMethod(Method) then begin
|
||||||
JITMethod:=TJITMethod(Method.Data);
|
JITMethod:=TJITMethod(Method.Data);
|
||||||
Result:=JITMethod.TheMethodName;
|
Result:=JITMethod.TheMethodName;
|
||||||
if PropOwner is TComponent then begin
|
if PropOwner is TComponent then begin
|
||||||
LookupRoot:=GetLookupRootForComponent(TComponent(PropOwner));
|
LookupRoot:=GetLookupRootForComponent(TComponent(PropOwner));
|
||||||
if LookupRoot is TComponent then begin
|
if LookupRoot is TComponent then begin
|
||||||
//DebugLn(['TMainIDE.OnPropHookGetMethodName ',Result,' ',dbgsName(GlobalDesignHook.LookupRoot),' ',dbgsName(JITMethod.TheClass)]);
|
//DebugLn(['TMainIDE.OnCodeToolBossGetMethodName ',Result,' GlobalDesignHook.LookupRoot=',dbgsName(GlobalDesignHook.LookupRoot),' JITMethod.TheClass=',dbgsName(JITMethod.TheClass),' PropOwner=',DbgSName(PropOwner),' PropOwner-LookupRoot=',DbgSName(LookupRoot)]);
|
||||||
if (LookupRoot.ClassType<>JITMethod.TheClass) then begin
|
if (LookupRoot.ClassType<>JITMethod.TheClass) then begin
|
||||||
Result:=JITMethod.TheClass.ClassName+'.'+Result;
|
Result:=JITMethod.TheClass.ClassName+'.'+Result;
|
||||||
end;
|
end;
|
||||||
@ -9321,7 +9325,7 @@ begin
|
|||||||
Result:='';
|
Result:='';
|
||||||
{$IFDEF VerboseDanglingComponentEvents}
|
{$IFDEF VerboseDanglingComponentEvents}
|
||||||
if IsJITMethod(Method) then
|
if IsJITMethod(Method) then
|
||||||
DebugLn(['TMainIDE.OnPropHookGetMethodName ',Result,' ',IsJITMethod(Method)]);
|
DebugLn(['TMainIDE.OnCodeToolBossGetMethodName ',Result,' ',IsJITMethod(Method)]);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user