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