mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-16 12:29:29 +02:00
ide: start resolving foreign references (works only when referenced form is already loaded)
git-svn-id: trunk@14798 -
This commit is contained in:
parent
ea223b758a
commit
09b6731e09
@ -48,7 +48,7 @@ uses
|
||||
MemCheck,
|
||||
{$ENDIF}
|
||||
Classes, SysUtils, AvgLvlTree, TypInfo, LCLProc, LResources, Forms, Controls,
|
||||
LCLIntf, Dialogs, JITForm, ComponentReg, IDEProcs;
|
||||
LCLIntf, Dialogs, JITForm, ComponentReg, IDEProcs, BasePkgManager;
|
||||
|
||||
type
|
||||
//----------------------------------------------------------------------------
|
||||
@ -808,7 +808,11 @@ end;
|
||||
function TJITComponentList.OnFindGlobalComponent(
|
||||
const AName: AnsiString): TComponent;
|
||||
begin
|
||||
Result:=Application.FindComponent(AName);
|
||||
// Paul: Do we need search by application?
|
||||
Result := Application.FindComponent(AName);
|
||||
if Result = nil then
|
||||
Result := PkgBoss.FindReferencedRootComponent(CurReadJITComponent, AName);
|
||||
// DebugLn(dbgsName(CurReadJITComponent), ' FIND global component ', AName, ' ', dbgsName(Result));
|
||||
end;
|
||||
|
||||
procedure TJITComponentList.InitReading(BinStream: TStream;
|
||||
|
@ -641,6 +641,7 @@ type
|
||||
function ProjectUnitWithUnitname(const AnUnitName: string): TUnitInfo;
|
||||
function UnitWithEditorIndex(Index:integer): TUnitInfo;
|
||||
function UnitWithComponent(AComponent: TComponent): TUnitInfo;
|
||||
function UnitWithComponentName(AComponentName: String): TUnitInfo;
|
||||
function UnitComponentInheritingFrom(AClass: TComponentClass;
|
||||
Ignore: TUnitInfo): TUnitInfo;
|
||||
function UnitUsingComponentUnit(ComponentUnit: TUnitInfo): TUnitInfo;
|
||||
@ -3619,13 +3620,20 @@ begin
|
||||
|
||||
end;
|
||||
|
||||
Function TProject.UnitWithComponent(AComponent: TComponent) : TUnitInfo;
|
||||
function TProject.UnitWithComponent(AComponent: TComponent): TUnitInfo;
|
||||
begin
|
||||
Result:=fFirst[uilWithComponent];
|
||||
while (Result<>nil) and (Result.Component<>AComponent) do
|
||||
Result:=Result.fNext[uilWithComponent];
|
||||
end;
|
||||
|
||||
function TProject.UnitWithComponentName(AComponentName: String): TUnitInfo;
|
||||
begin
|
||||
Result := fFirst[uilPartOfProject];
|
||||
while (Result<>nil) and (SysUtils.CompareText(Result.ComponentName, AComponentName) <> 0) do
|
||||
Result := Result.fNext[uilPartOfProject];
|
||||
end;
|
||||
|
||||
function TProject.UnitComponentInheritingFrom(AClass: TComponentClass;
|
||||
Ignore: TUnitInfo): TUnitInfo;
|
||||
begin
|
||||
|
@ -144,6 +144,8 @@ type
|
||||
Proc: TGetStringProc); virtual; abstract;
|
||||
function FindUsableComponent(CurRoot: TPersistent;
|
||||
const ComponentPath: string): TComponent; virtual; abstract;
|
||||
function FindReferencedRootComponent(CurRoot: TPersistent;
|
||||
const ComponentName: string): TComponent; virtual; abstract;
|
||||
end;
|
||||
|
||||
var
|
||||
|
@ -306,6 +306,8 @@ type
|
||||
Proc: TGetStringProc); override;
|
||||
function FindUsableComponent(CurRoot: TPersistent;
|
||||
const ComponentPath: string): TComponent; override;
|
||||
function FindReferencedRootComponent(CurRoot: TPersistent;
|
||||
const ComponentName: string): TComponent; override;
|
||||
end;
|
||||
|
||||
|
||||
@ -3876,32 +3878,36 @@ var
|
||||
|
||||
function MainUnitInfo: TUnitInfo;
|
||||
begin
|
||||
if not FMainUnitInfoValid then begin
|
||||
if not FMainUnitInfoValid then
|
||||
begin
|
||||
if CurRoot is TComponent then
|
||||
FMainUnitInfo:=Project1.UnitWithComponent(TComponent(CurRoot));
|
||||
FMainUnitInfoValid:=true;
|
||||
FMainUnitInfo := Project1.UnitWithComponentName(TComponent(CurRoot).Name);
|
||||
FMainUnitInfoValid := True;
|
||||
end;
|
||||
Result:=FMainUnitInfo;
|
||||
Result := FMainUnitInfo;
|
||||
end;
|
||||
|
||||
function MainOwner: TObject;
|
||||
var
|
||||
Owners: TFPList;
|
||||
begin
|
||||
if not FMainOwnerValid then begin
|
||||
if MainUnitInfo<>nil then begin
|
||||
if not FMainOwnerValid then
|
||||
begin
|
||||
if MainUnitInfo <> nil then
|
||||
begin
|
||||
if MainUnitInfo.IsPartOfProject then
|
||||
FMainOwner:=Project1
|
||||
else begin
|
||||
Owners:=GetOwnersOfUnit(MainUnitInfo.Filename);
|
||||
if (Owners<>nil) and (Owners.Count>0) then
|
||||
FMainOwner:=TObject(Owners[0]);
|
||||
FMainOwner := Project1
|
||||
else
|
||||
begin
|
||||
Owners := GetOwnersOfUnit(MainUnitInfo.Filename);
|
||||
if (Owners <> nil) and (Owners.Count > 0) then
|
||||
FMainOwner := TObject(Owners[0]);
|
||||
Owners.Free;
|
||||
end;
|
||||
end;
|
||||
FMainOwnerValid:=true;
|
||||
FMainOwnerValid := True;
|
||||
end;
|
||||
Result:=FMainOwner;
|
||||
Result := FMainOwner;
|
||||
end;
|
||||
|
||||
procedure CheckUnit(AnUnitInfo: TUnitInfo);
|
||||
@ -4029,6 +4035,34 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
function TPkgManager.FindReferencedRootComponent(CurRoot: TPersistent; const ComponentName: string): TComponent;
|
||||
var
|
||||
UnitList: TFPList;
|
||||
ARoot: TComponent;
|
||||
i: integer;
|
||||
begin
|
||||
//DebugLn(['search ', ComponentName, ' CurRoot = ', dbgsName(CurRoot)]);
|
||||
Result := nil;
|
||||
UnitList := GetUsableComponentUnits(CurRoot);
|
||||
if UnitList = nil then
|
||||
Exit;
|
||||
try
|
||||
for i := 0 to UnitList.Count - 1 do
|
||||
begin
|
||||
ARoot := TUnitInfo(UnitList[i]).Component;
|
||||
//DebugLn(dbgsName(ARoot));
|
||||
if (ARoot <> nil) and (SysUtils.CompareText(ComponentName, ARoot.Name) = 0) then
|
||||
begin
|
||||
Result := ARoot;
|
||||
break;
|
||||
end;
|
||||
end;
|
||||
finally
|
||||
UnitList.Free;
|
||||
end;
|
||||
//DebugLn('search end');
|
||||
end;
|
||||
|
||||
function TPkgManager.FindUsableComponent(CurRoot: TPersistent;
|
||||
const ComponentPath: string): TComponent;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user