mirror of https://gitlab.com/basile.b/dexed.git
libman, import ana, handle item supression
This commit is contained in:
parent
c35cc3c92c
commit
7aae871188
|
|
@ -49,8 +49,6 @@ type
|
||||||
fHasValidSourcePath: boolean;
|
fHasValidSourcePath: boolean;
|
||||||
fHasValidLibFile: boolean;
|
fHasValidLibFile: boolean;
|
||||||
fHasValidLibProject: boolean;
|
fHasValidLibProject: boolean;
|
||||||
procedure setDependencies(value: TStringList);
|
|
||||||
procedure setModules(value: TCollection);
|
|
||||||
procedure setLibProject(const value: string);
|
procedure setLibProject(const value: string);
|
||||||
procedure setLibFile(const value: string);
|
procedure setLibFile(const value: string);
|
||||||
procedure setLibSourcePath(const value: string);
|
procedure setLibSourcePath(const value: string);
|
||||||
|
|
@ -63,9 +61,6 @@ type
|
||||||
property libFile: string read fLibFile write setLibFile;
|
property libFile: string read fLibFile write setLibFile;
|
||||||
property libProject: string read fLibProject write setLibProject;
|
property libProject: string read fLibProject write setLibProject;
|
||||||
property enabled: boolean read fEnabled write fEnabled default true;
|
property enabled: boolean read fEnabled write fEnabled default true;
|
||||||
// TODO-clibman: dont forget that these props are not written
|
|
||||||
property dependencies: TStringList read fDependencies write setDependencies stored false;
|
|
||||||
property modules: TCollection read fModules write setModules stored false;
|
|
||||||
// TODO-cmaintenace: remove this property from 3 update 1
|
// TODO-cmaintenace: remove this property from 3 update 1
|
||||||
property projectFile: string read fLibProject write fLibProject stored false;
|
property projectFile: string read fLibProject write fLibProject stored false;
|
||||||
public
|
public
|
||||||
|
|
@ -77,6 +72,8 @@ type
|
||||||
property hasValidLibFile: boolean read fHasValidLibFile;
|
property hasValidLibFile: boolean read fHasValidLibFile;
|
||||||
property hasValidLibProject: boolean read fHasValidLibProject;
|
property hasValidLibProject: boolean read fHasValidLibProject;
|
||||||
property hasValidLibSourcePath: boolean read fHasValidSourcePath;
|
property hasValidLibSourcePath: boolean read fHasValidSourcePath;
|
||||||
|
property dependencies: TStringList read fDependencies;
|
||||||
|
property modules: TCollection read fModules;
|
||||||
property moduleByIndex[value: integer]: TModuleInfo read getModule;
|
property moduleByIndex[value: integer]: TModuleInfo read getModule;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
@ -85,7 +82,7 @@ type
|
||||||
(**
|
(**
|
||||||
* Represents all the D libraries handled by Coedit.
|
* Represents all the D libraries handled by Coedit.
|
||||||
*)
|
*)
|
||||||
TLibraryManager = class(TWritableLfmTextComponent)
|
TLibraryManager = class(TWritableLfmTextComponent, IFPObserver)
|
||||||
type
|
type
|
||||||
TItemsByAlias = specialize TStringHashMap<TLibraryItem>;
|
TItemsByAlias = specialize TStringHashMap<TLibraryItem>;
|
||||||
strict private
|
strict private
|
||||||
|
|
@ -97,6 +94,7 @@ type
|
||||||
procedure setCollection(value: TCollection);
|
procedure setCollection(value: TCollection);
|
||||||
procedure updateItemsByAlias;
|
procedure updateItemsByAlias;
|
||||||
function getLibrariesCount: integer;
|
function getLibrariesCount: integer;
|
||||||
|
procedure FPOObservedChanged(ASender : TObject; Operation : TFPObservedOperation; Data : Pointer);
|
||||||
published
|
published
|
||||||
property libraries: TCollection read fCollection write setCollection;
|
property libraries: TCollection read fCollection write setCollection;
|
||||||
public
|
public
|
||||||
|
|
@ -120,7 +118,7 @@ type
|
||||||
procedure getLibsForSource(source, libs, paths: TStrings);
|
procedure getLibsForSource(source, libs, paths: TStrings);
|
||||||
//
|
//
|
||||||
procedure updateDCD;
|
procedure updateDCD;
|
||||||
// find the aliases of the libraries used by this library.
|
// find the aliases of the libraries used by the libraries.
|
||||||
procedure updateCrossDependencies;
|
procedure updateCrossDependencies;
|
||||||
property librariesCount: integer read getLibrariesCount;
|
property librariesCount: integer read getLibrariesCount;
|
||||||
property libraryByIndex[value: integer]: TLibraryItem read getLibraryByIndex;
|
property libraryByIndex[value: integer]: TLibraryItem read getLibraryByIndex;
|
||||||
|
|
@ -195,16 +193,6 @@ begin
|
||||||
exit(fModulesByName.contains(value));
|
exit(fModulesByName.contains(value));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TLibraryItem.setModules(value: TCollection);
|
|
||||||
begin
|
|
||||||
fModules.Assign(value);
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TLibraryItem.setDependencies(value: TStringList);
|
|
||||||
begin
|
|
||||||
fDependencies.Assign(value);
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TLibraryItem.setLibProject(const value: string);
|
procedure TLibraryItem.setLibProject(const value: string);
|
||||||
begin
|
begin
|
||||||
if fLibProject = value then
|
if fLibProject = value then
|
||||||
|
|
@ -306,6 +294,7 @@ begin
|
||||||
inherited;
|
inherited;
|
||||||
fItemsByAlias:= TItemsByAlias.create;
|
fItemsByAlias:= TItemsByAlias.create;
|
||||||
fCollection := TCollection.Create(TLibraryItem);
|
fCollection := TCollection.Create(TLibraryItem);
|
||||||
|
fCollection.FPOAttachObserver(self);
|
||||||
fname := getCoeditDocPath + libFname;
|
fname := getCoeditDocPath + libFname;
|
||||||
if fname.fileExists then
|
if fname.fileExists then
|
||||||
loadFromFile(fname);
|
loadFromFile(fname);
|
||||||
|
|
@ -415,6 +404,17 @@ begin
|
||||||
fCollection.assign(value);
|
fCollection.assign(value);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TLibraryManager.FPOObservedChanged(ASender: TObject; Operation:
|
||||||
|
TFPObservedOperation; Data: Pointer);
|
||||||
|
begin
|
||||||
|
if (Operation = ooDeleteItem) and data.isNotNil and
|
||||||
|
fItemsByAlias.contains(TLibraryItem(data).libAlias) then
|
||||||
|
begin
|
||||||
|
fItemsByAlias.delete(TLibraryItem(data).libAlias);
|
||||||
|
updateCrossDependencies;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
function TLibraryManager.getLibraryByIndex(index: integer): TLibraryItem;
|
function TLibraryManager.getLibraryByIndex(index: integer): TLibraryItem;
|
||||||
begin
|
begin
|
||||||
exit(TLibraryItem(fCollection.Items[index]));
|
exit(TLibraryItem(fCollection.Items[index]));
|
||||||
|
|
@ -451,7 +451,8 @@ var
|
||||||
i: Integer;
|
i: Integer;
|
||||||
begin
|
begin
|
||||||
if not DcdWrapper.available then exit;
|
if not DcdWrapper.available then exit;
|
||||||
// note: new libraryByIndex are directly handled but removed ones still in cache until server restarts.
|
// note: new libraries are directly handled but those who are removed
|
||||||
|
// remain in cache until next session.
|
||||||
str := TStringList.Create;
|
str := TStringList.Create;
|
||||||
try
|
try
|
||||||
for i := 0 to fCollection.Count-1 do
|
for i := 0 to fCollection.Count-1 do
|
||||||
|
|
@ -569,11 +570,14 @@ begin
|
||||||
begin
|
begin
|
||||||
sel.insert(itm);
|
sel.insert(itm);
|
||||||
// get libraries for import I dependencies
|
// get libraries for import I dependencies
|
||||||
for j:= 0 to itm.dependencies.Count-1 do
|
for j:= itm.dependencies.Count-1 downto 0 do
|
||||||
begin
|
begin
|
||||||
dep := libraryByAlias[itm.dependencies[j]];
|
dep := libraryByAlias[itm.dependencies[j]];
|
||||||
if dep.isNotNil then
|
if dep.isNotNil then
|
||||||
sel.insert(dep);
|
sel.insert(dep)
|
||||||
|
//auto update: item removed, detect on usage that it has disapeared
|
||||||
|
else
|
||||||
|
itm.dependencies.Delete(j);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue