mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-16 04:39:22 +02:00
IDE: when adding designer form child names to source, consider ancestor
git-svn-id: trunk@10279 -
This commit is contained in:
parent
6e3467a93b
commit
185cecd04e
@ -527,8 +527,8 @@ type
|
|||||||
var AncestorClassName: string; DirtySearch: boolean): boolean;
|
var AncestorClassName: string; DirtySearch: boolean): boolean;
|
||||||
|
|
||||||
// form components
|
// form components
|
||||||
function CompleteComponent(Code: TCodeBuffer; AComponent: TComponent
|
function CompleteComponent(Code: TCodeBuffer;
|
||||||
): boolean;
|
AComponent, AncestorComponent: TComponent): boolean;
|
||||||
function PublishedVariableExists(Code: TCodeBuffer;
|
function PublishedVariableExists(Code: TCodeBuffer;
|
||||||
const AClassName, AVarName: string;
|
const AClassName, AVarName: string;
|
||||||
ErrorOnClassNotFound: boolean): boolean;
|
ErrorOnClassNotFound: boolean): boolean;
|
||||||
@ -3511,15 +3511,16 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
function TCodeToolManager.CompleteComponent(Code: TCodeBuffer;
|
function TCodeToolManager.CompleteComponent(Code: TCodeBuffer;
|
||||||
AComponent: TComponent): boolean;
|
AComponent, AncestorComponent: TComponent): boolean;
|
||||||
begin
|
begin
|
||||||
Result:=false;
|
Result:=false;
|
||||||
{$IFDEF CTDEBUG}
|
{$IFDEF CTDEBUG}
|
||||||
DebugLn('TCodeToolManager.CompleteComponent A ',Code.Filename,' ',AComponent.Name,':',AComponent.ClassName);
|
DebugLn('TCodeToolManager.CompleteComponent A ',Code.Filename,' ',AComponent.Name,':',AComponent.ClassName,' ',dbgsName(AncestorComponent));
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
if not InitCurCodeTool(Code) then exit;
|
if not InitCurCodeTool(Code) then exit;
|
||||||
try
|
try
|
||||||
Result:=FCurCodeTool.CompleteComponent(AComponent,SourceChangeCache);
|
Result:=FCurCodeTool.CompleteComponent(AComponent,AncestorComponent,
|
||||||
|
SourceChangeCache);
|
||||||
except
|
except
|
||||||
on e: Exception do Result:=HandleException(e);
|
on e: Exception do Result:=HandleException(e);
|
||||||
end;
|
end;
|
||||||
|
@ -61,7 +61,7 @@ type
|
|||||||
function CollectPublishedMethods(Params: TFindDeclarationParams;
|
function CollectPublishedMethods(Params: TFindDeclarationParams;
|
||||||
const FoundContext: TFindContext): TIdentifierFoundResult;
|
const FoundContext: TFindContext): TIdentifierFoundResult;
|
||||||
public
|
public
|
||||||
function CompleteComponent(AComponent: TComponent;
|
function CompleteComponent(AComponent, AncestorComponent: TComponent;
|
||||||
SourceChangeCache: TSourceChangeCache): boolean;
|
SourceChangeCache: TSourceChangeCache): boolean;
|
||||||
|
|
||||||
function GetCompatiblePublishedMethods(const UpperClassName: string;
|
function GetCompatiblePublishedMethods(const UpperClassName: string;
|
||||||
@ -831,7 +831,8 @@ begin
|
|||||||
Result:=ifrProceedSearch;
|
Result:=ifrProceedSearch;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TEventsCodeTool.CompleteComponent(AComponent: TComponent;
|
function TEventsCodeTool.CompleteComponent(AComponent,
|
||||||
|
AncestorComponent: TComponent;
|
||||||
SourceChangeCache: TSourceChangeCache): boolean;
|
SourceChangeCache: TSourceChangeCache): boolean;
|
||||||
{ - Adds all missing published variable declarations to the class definition
|
{ - Adds all missing published variable declarations to the class definition
|
||||||
in the source
|
in the source
|
||||||
@ -861,6 +862,8 @@ begin
|
|||||||
DebugLn('[TEventsCodeTool.CompleteComponent] CurComponent=',CurComponent.Name,':',CurComponent.ClassName);
|
DebugLn('[TEventsCodeTool.CompleteComponent] CurComponent=',CurComponent.Name,':',CurComponent.ClassName);
|
||||||
VarName:=CurComponent.Name;
|
VarName:=CurComponent.Name;
|
||||||
if VarName='' then continue;
|
if VarName='' then continue;
|
||||||
|
if (AncestorComponent<>nil)
|
||||||
|
and (AncestorComponent.FindComponent(VarName)<>nil) then continue;
|
||||||
UpperCurComponentName:=UpperCaseStr(VarName);
|
UpperCurComponentName:=UpperCaseStr(VarName);
|
||||||
VarType:=CurComponent.ClassName;
|
VarType:=CurComponent.ClassName;
|
||||||
// add missing published variable
|
// add missing published variable
|
||||||
|
19
ide/main.pp
19
ide/main.pp
@ -596,7 +596,6 @@ type
|
|||||||
Flags: TCloseFlags): TModalResult;
|
Flags: TCloseFlags): TModalResult;
|
||||||
function UnitComponentIsUsed(AnUnitInfo: TUnitInfo;
|
function UnitComponentIsUsed(AnUnitInfo: TUnitInfo;
|
||||||
CheckHasDesigner: boolean): boolean;
|
CheckHasDesigner: boolean): boolean;
|
||||||
function GetAncestorUnit(AnUnitInfo: TUnitInfo): TUnitInfo;
|
|
||||||
|
|
||||||
// methods for creating a project
|
// methods for creating a project
|
||||||
function CreateProjectObject(ProjectDesc,
|
function CreateProjectObject(ProjectDesc,
|
||||||
@ -748,6 +747,8 @@ type
|
|||||||
function GetSourceEditorForUnitInfo(AnUnitInfo: TUnitInfo): TSourceEditor; override;
|
function GetSourceEditorForUnitInfo(AnUnitInfo: TUnitInfo): TSourceEditor; override;
|
||||||
function CreateSrcEditPageName(const AnUnitName, AFilename: string;
|
function CreateSrcEditPageName(const AnUnitName, AFilename: string;
|
||||||
IgnorePageIndex: integer): string;
|
IgnorePageIndex: integer): string;
|
||||||
|
function GetAncestorUnit(AnUnitInfo: TUnitInfo): TUnitInfo;
|
||||||
|
function GetAncestorLookupRoot(AnUnitInfo: TUnitInfo): TComponent;
|
||||||
|
|
||||||
// useful file methods
|
// useful file methods
|
||||||
function FindUnitFile(const AFilename: string): string; override;
|
function FindUnitFile(const AFilename: string): string; override;
|
||||||
@ -5305,6 +5306,17 @@ begin
|
|||||||
Result:=AnUnitInfo.FindAncestorUnit;
|
Result:=AnUnitInfo.FindAncestorUnit;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TMainIDE.GetAncestorLookupRoot(AnUnitInfo: TUnitInfo): TComponent;
|
||||||
|
var
|
||||||
|
AncestorUnit: TUnitInfo;
|
||||||
|
begin
|
||||||
|
AncestorUnit:=GetAncestorUnit(AnUnitInfo);
|
||||||
|
if AncestorUnit<>nil then
|
||||||
|
Result:=AncestorUnit.Component
|
||||||
|
else
|
||||||
|
Result:=nil;
|
||||||
|
end;
|
||||||
|
|
||||||
function TMainIDE.CreateProjectObject(ProjectDesc,
|
function TMainIDE.CreateProjectObject(ProjectDesc,
|
||||||
FallbackProjectDesc: TProjectDescriptor): TProject;
|
FallbackProjectDesc: TProjectDescriptor): TProject;
|
||||||
begin
|
begin
|
||||||
@ -12436,6 +12448,7 @@ var
|
|||||||
AComponent: TComponent;
|
AComponent: TComponent;
|
||||||
ActiveSrcEdit: TSourceEditor;
|
ActiveSrcEdit: TSourceEditor;
|
||||||
ActiveUnitInfo: TUnitInfo;
|
ActiveUnitInfo: TUnitInfo;
|
||||||
|
Ancestor: TComponent;
|
||||||
begin
|
begin
|
||||||
DebugLn('TMainIDE.OnPropHookPersistentAdded A ',dbgsName(APersistent));
|
DebugLn('TMainIDE.OnPropHookPersistentAdded A ',dbgsName(APersistent));
|
||||||
ADesigner:=nil;
|
ADesigner:=nil;
|
||||||
@ -12480,7 +12493,9 @@ begin
|
|||||||
ActiveUnitInfo.Modified:=true;
|
ActiveUnitInfo.Modified:=true;
|
||||||
|
|
||||||
// add component definitions to form source
|
// add component definitions to form source
|
||||||
CodeToolBoss.CompleteComponent(ActiveUnitInfo.Source,ADesigner.LookupRoot);
|
Ancestor:=GetAncestorLookupRoot(ActiveUnitInfo);
|
||||||
|
CodeToolBoss.CompleteComponent(ActiveUnitInfo.Source,ADesigner.LookupRoot,
|
||||||
|
Ancestor);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
ObjectInspector1.FillPersistentComboBox;
|
ObjectInspector1.FillPersistentComboBox;
|
||||||
|
Loading…
Reference in New Issue
Block a user