IDEIntf: added PackageEditingInterface.FindInstalledPackageWithUnit

git-svn-id: trunk@55556 -
This commit is contained in:
mattias 2017-07-21 13:14:01 +00:00
parent 2fa1c8a50c
commit 6aebb896b0
3 changed files with 34 additions and 0 deletions

View File

@ -261,6 +261,7 @@ type
function GetPackageCount: integer; virtual; abstract;
function GetPackages(Index: integer): TIDEPackage; virtual; abstract;
function FindPackageWithName(const PkgName: string; IgnorePackage: TIDEPackage = nil): TIDEPackage; virtual; abstract;
function FindInstalledPackageWithUnit(const AnUnitName: string): TIDEPackage; virtual; abstract;
// dependencies
function IsOwnerDependingOnPkg(AnOwner: TObject; const PkgName: string;

View File

@ -326,6 +326,8 @@ type
WithRequiredPackages, IgnoreDeleted: boolean): TPkgFile;
function FindUnitInAllPackages(const TheUnitName: string;
IgnoreDeleted: boolean): TPkgFile;
function FindUnitInInstalledPackages(const TheUnitName: string;
IgnoreDeleted: boolean): TPkgFile;
function GetMapSourceDirectoryToPackage(IgnorePackage: TLazPackage = nil): TFilenameToPointerTree;
function EstimateCompileLoad(APackage: TLazPackage): int64;
function PackageCanBeReplaced(OldPackage, NewPackage: TLazPackage): boolean;
@ -1634,6 +1636,23 @@ begin
Result:=nil;
end;
function TLazPackageGraph.FindUnitInInstalledPackages(
const TheUnitName: string; IgnoreDeleted: boolean): TPkgFile;
var
Cnt: Integer;
i: Integer;
Pkg: TLazPackage;
begin
Cnt:=Count;
for i:=0 to Cnt-1 do begin
Pkg:=Packages[i];
if Pkg.Installed=pitNope then continue;
Result:=FindUnit(Pkg,TheUnitName,false,IgnoreDeleted);
if Result<>nil then exit;
end;
Result:=nil;
end;
function TLazPackageGraph.GetMapSourceDirectoryToPackage(
IgnorePackage: TLazPackage): TFilenameToPointerTree;
var

View File

@ -252,6 +252,8 @@ type
function GetPackageCount: integer; override;
function GetPackages(Index: integer): TIDEPackage; override;
function FindPackageWithName(const PkgName: string; IgnorePackage: TIDEPackage = nil): TIDEPackage; override;
function FindInstalledPackageWithUnit(const AnUnitName: string
): TIDEPackage; override;
function IsOwnerDependingOnPkg(AnOwner: TObject; const PkgName: string;
out DependencyOwner: TObject): boolean; override;
procedure GetRequiredPackages(AnOwner: TObject; out PkgList: TFPList;
@ -4113,6 +4115,18 @@ begin
Result:=PackageGraph.FindPackageWithName(PkgName, IgnorePackage as TLazPackage);
end;
function TPkgManager.FindInstalledPackageWithUnit(const AnUnitName: string
): TIDEPackage;
var
PkgFile: TPkgFile;
begin
PkgFile:=PackageGraph.FindUnitInInstalledPackages(AnUnitName, true);
if PkgFile=nil then
Result:=nil
else
Result:=PkgFile.LazPackage;
end;
function TPkgManager.RedirectPackageDependency(APackage: TIDEPackage): TIDEPackage;
begin
Result:=APackage;