mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-09 01:48:03 +02:00
IDE: codebrowser: testing if use unit in unit is possible
git-svn-id: trunk@21523 -
This commit is contained in:
parent
1cb07625ec
commit
7a4efc129b
@ -113,6 +113,7 @@ type
|
||||
FUnitLists: TAVLTree;
|
||||
FUnits: TAVLTree;
|
||||
FUnitsValid: boolean;
|
||||
fClearing: boolean;
|
||||
procedure SetOwner(const AValue: string);
|
||||
procedure InternalAddUnitList(List: TCodeBrowserUnitList);
|
||||
procedure InternalRemoveUnitList(List: TCodeBrowserUnitList);
|
||||
@ -129,6 +130,7 @@ type
|
||||
function IsEmpty: boolean;
|
||||
procedure DeleteUnit(AnUnit: TCodeBrowserUnit);
|
||||
function AddUnit(const Filename: string): TCodeBrowserUnit;
|
||||
procedure AddUnit(AnUnit: TCodeBrowserUnit);
|
||||
property Owner: string read FOwner write SetOwner;// IDE, project, package
|
||||
property ParentList: TCodeBrowserUnitList read FParentList;
|
||||
property Units: TAVLTree read FUnits;
|
||||
@ -316,12 +318,14 @@ begin
|
||||
if FUnits=nil then
|
||||
FUnits:=TAVLTree.Create(@CompareUnitFilenames);
|
||||
FUnits.Add(AnUnit);
|
||||
AnUnit.FUnitList:=Self;
|
||||
end;
|
||||
|
||||
procedure TCodeBrowserUnitList.InternalRemoveUnit(AnUnit: TCodeBrowserUnit);
|
||||
begin
|
||||
if FUnits<>nil then
|
||||
if (not fClearing) and (FUnits<>nil) then
|
||||
FUnits.Remove(AnUnit);
|
||||
AnUnit.FUnitList:=nil;
|
||||
end;
|
||||
|
||||
constructor TCodeBrowserUnitList.Create(TheOwner: string;
|
||||
@ -359,9 +363,14 @@ procedure TCodeBrowserUnitList.Clear;
|
||||
end;
|
||||
|
||||
begin
|
||||
FreeTree(FUnits);
|
||||
FreeTree(FUnitLists);
|
||||
FUnitsValid:=false;
|
||||
fClearing:=true;
|
||||
try
|
||||
FreeTree(FUnits);
|
||||
FreeTree(FUnitLists);
|
||||
FUnitsValid:=false;
|
||||
finally
|
||||
fClearing:=false;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TCodeBrowserUnitList.FindUnit(const Filename: string
|
||||
@ -426,5 +435,13 @@ begin
|
||||
InternalAddUnit(Result);
|
||||
end;
|
||||
|
||||
procedure TCodeBrowserUnitList.AddUnit(AnUnit: TCodeBrowserUnit);
|
||||
begin
|
||||
if (AnUnit.UnitList=Self) then exit;
|
||||
if AnUnit.UnitList<>nil then
|
||||
AnUnit.UnitList.InternalRemoveUnit(AnUnit);
|
||||
InternalAddUnit(AnUnit);
|
||||
end;
|
||||
|
||||
end.
|
||||
|
||||
|
@ -556,7 +556,7 @@ begin
|
||||
CurUnitName:=ExtractFileNameOnly(CurUnit.Filename);
|
||||
SrcEditUnitName:=ExtractFileNameOnly(SrcEditUnitFilename);
|
||||
if SysUtils.CompareText(CurUnitName,SrcEditUnitName)<>0 then begin
|
||||
EnableUnitToCurUnit:=true;
|
||||
// ToDo EnableUnitToCurUnit:=true;
|
||||
AddUnitToCurUnitMenuItem.Caption:=
|
||||
Format(lisUseUnitInUnit, [CurUnitName, SrcEditUnitName]);
|
||||
end;
|
||||
@ -1857,11 +1857,14 @@ var
|
||||
if (not ShowEmptyNodes) and (NewUnit.ChildNodeCount=0) then begin
|
||||
// remove empty unit
|
||||
List.DeleteUnit(NewUnit);
|
||||
NewUnit:=nil;
|
||||
if OldDestParentList=nil then begin
|
||||
DestParentList.Free;
|
||||
DestParentList:=nil;
|
||||
end;
|
||||
end;
|
||||
if (NewUnit<>nil) and (NewUnit.UnitList=nil) and (List<>nil) then
|
||||
List.AddUnit(NewUnit);
|
||||
end;
|
||||
Node:=SrcList.Units.FindSuccessor(Node);
|
||||
end;
|
||||
|
Loading…
Reference in New Issue
Block a user