mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-05 10:20:40 +02:00
IDE: codebrowser update of root item
git-svn-id: trunk@10631 -
This commit is contained in:
parent
cbbec503b1
commit
ed3137cc14
@ -41,8 +41,13 @@ interface
|
|||||||
uses
|
uses
|
||||||
Classes, SysUtils, LCLProc, LResources, Forms, Controls, Graphics, Dialogs,
|
Classes, SysUtils, LCLProc, LResources, Forms, Controls, Graphics, Dialogs,
|
||||||
LCLIntf, AvgLvlTree, StdCtrls, ExtCtrls, ComCtrls, Buttons,
|
LCLIntf, AvgLvlTree, StdCtrls, ExtCtrls, ComCtrls, Buttons,
|
||||||
CodeTree, CodeCache, CodeToolManager, LazConfigStorage, PackageSystem,
|
// codetools
|
||||||
PackageDefs, LazarusIDEStrConsts, IDEOptionDefs, EnvironmentOpts;
|
CodeTree, CodeCache, CodeToolManager,
|
||||||
|
// IDEIntf
|
||||||
|
LazConfigStorage, Project,
|
||||||
|
// IDE
|
||||||
|
PackageSystem, PackageDefs, LazarusIDEStrConsts, IDEOptionDefs,
|
||||||
|
EnvironmentOpts;
|
||||||
|
|
||||||
type
|
type
|
||||||
TCodeBrowserUnit = class;
|
TCodeBrowserUnit = class;
|
||||||
@ -96,14 +101,17 @@ type
|
|||||||
private
|
private
|
||||||
FOwner: string;
|
FOwner: string;
|
||||||
FParentList: TCodeBrowserUnitList;
|
FParentList: TCodeBrowserUnitList;
|
||||||
|
FUnitLists: TAvgLvlTree;
|
||||||
FUnits: TAvgLvlTree;
|
FUnits: TAvgLvlTree;
|
||||||
|
procedure SetOwner(const AValue: string);
|
||||||
public
|
public
|
||||||
constructor Create(TheOwner: string; TheParent: TCodeBrowserUnitList);
|
constructor Create(TheOwner: string; TheParent: TCodeBrowserUnitList);
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
procedure Clear;
|
procedure Clear;
|
||||||
property Owner: string read FOwner;// IDE, project, package
|
property Owner: string read FOwner write SetOwner;// IDE, project, package
|
||||||
property ParentList: TCodeBrowserUnitList read FParentList;
|
property ParentList: TCodeBrowserUnitList read FParentList;
|
||||||
property Units: TAvgLvlTree read FUnits;
|
property Units: TAvgLvlTree read FUnits;
|
||||||
|
property UnitLists: TAvgLvlTree read FUnitLists;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
type
|
type
|
||||||
@ -176,6 +184,7 @@ type
|
|||||||
TCodeBrowserWorkStage = (
|
TCodeBrowserWorkStage = (
|
||||||
cbwsGetOptions,
|
cbwsGetOptions,
|
||||||
cbwsGatherPackages,
|
cbwsGatherPackages,
|
||||||
|
cbwsFreeUnusedPackages,
|
||||||
cbwsGatherFiles,
|
cbwsGatherFiles,
|
||||||
cbwsUpdateUnits,
|
cbwsUpdateUnits,
|
||||||
cbwsUpdateNodes,
|
cbwsUpdateNodes,
|
||||||
@ -215,7 +224,8 @@ type
|
|||||||
fLocalizedSortItems: TStrings;
|
fLocalizedSortItems: TStrings;
|
||||||
FOptions: TCodeBrowserViewOptions;
|
FOptions: TCodeBrowserViewOptions;
|
||||||
FProjectAlias: string;
|
FProjectAlias: string;
|
||||||
FUnitList: TCodeBrowserUnitList;
|
FRoot: TCodeBrowserUnitList;
|
||||||
|
FWorkingRoot: TCodeBrowserUnitList;
|
||||||
fUpdateCount: integer;
|
fUpdateCount: integer;
|
||||||
fStage: TCodeBrowserWorkStage;
|
fStage: TCodeBrowserWorkStage;
|
||||||
procedure LoadOptions;
|
procedure LoadOptions;
|
||||||
@ -228,10 +238,12 @@ type
|
|||||||
procedure Work;
|
procedure Work;
|
||||||
procedure WorkGetOptions;
|
procedure WorkGetOptions;
|
||||||
procedure WorkGatherPackages;
|
procedure WorkGatherPackages;
|
||||||
|
procedure WorkFreeUnusedPackages;
|
||||||
public
|
public
|
||||||
procedure BeginUpdate;
|
procedure BeginUpdate;
|
||||||
procedure EndUpdate;
|
procedure EndUpdate;
|
||||||
property UnitList: TCodeBrowserUnitList read FUnitList;
|
property Root: TCodeBrowserUnitList read FRoot;
|
||||||
|
property WorkingRoot: TCodeBrowserUnitList read FWorkingRoot;
|
||||||
property Options: TCodeBrowserViewOptions read FOptions;
|
property Options: TCodeBrowserViewOptions read FOptions;
|
||||||
property IDEAlias: string read FIDEAlias;
|
property IDEAlias: string read FIDEAlias;
|
||||||
property ProjectAlias: string read FProjectAlias;
|
property ProjectAlias: string read FProjectAlias;
|
||||||
@ -291,6 +303,8 @@ end;
|
|||||||
|
|
||||||
procedure TCodeBrowserView.FormDestroy(Sender: TObject);
|
procedure TCodeBrowserView.FormDestroy(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
|
FreeAndNil(FRoot);
|
||||||
|
FreeAndNil(FWorkingRoot);
|
||||||
FreeAndNil(FOptions);
|
FreeAndNil(FOptions);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -470,9 +484,11 @@ procedure TCodeBrowserView.Work;
|
|||||||
// do some work
|
// do some work
|
||||||
// This is called during OnIdle, so progress in small steps
|
// This is called during OnIdle, so progress in small steps
|
||||||
begin
|
begin
|
||||||
|
DebugLn(['TCodeBrowserView.Work START']);
|
||||||
case fStage of
|
case fStage of
|
||||||
cbwsGetOptions: WorkGetOptions;
|
cbwsGetOptions: WorkGetOptions;
|
||||||
cbwsGatherPackages: WorkGatherPackages;
|
cbwsGatherPackages: WorkGatherPackages;
|
||||||
|
cbwsFreeUnusedPackages: WorkFreeUnusedPackages;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -480,6 +496,7 @@ procedure TCodeBrowserView.WorkGetOptions;
|
|||||||
var
|
var
|
||||||
i: Integer;
|
i: Integer;
|
||||||
begin
|
begin
|
||||||
|
DebugLn(['TCodeBrowserView.WorkGetOptions START']);
|
||||||
Options.WithRequiredPackages:=ScopeWithRequiredPackagesCheckBox.Checked;
|
Options.WithRequiredPackages:=ScopeWithRequiredPackagesCheckBox.Checked;
|
||||||
Options.Scope:=ScopeComboBox.Text;
|
Options.Scope:=ScopeComboBox.Text;
|
||||||
Options.Levels.Clear;
|
Options.Levels.Clear;
|
||||||
@ -488,15 +505,39 @@ begin
|
|||||||
Options.Levels.Add(CodeBrowserLevelNames[TCodeBrowserLevel(i)]);
|
Options.Levels.Add(CodeBrowserLevelNames[TCodeBrowserLevel(i)]);
|
||||||
Options.SortItems.Clear;
|
Options.SortItems.Clear;
|
||||||
Options.SortItems.Assign(SortListBox.Items);
|
Options.SortItems.Assign(SortListBox.Items);
|
||||||
|
|
||||||
// this stage finished -> next stage
|
// this stage finished -> next stage
|
||||||
fStage:=cbwsGatherPackages;
|
fStage:=cbwsGatherPackages;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCodeBrowserView.WorkGatherPackages;
|
procedure TCodeBrowserView.WorkGatherPackages;
|
||||||
|
|
||||||
|
procedure AddPackage(APackage: TLazPackage);
|
||||||
|
begin
|
||||||
|
TCodeBrowserUnitList.Create(APackage.Name,fWorkingRoot);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure AddPackages(FirstDependency: TPkgDependency);
|
||||||
|
var
|
||||||
|
List: TFPList;
|
||||||
|
i: Integer;
|
||||||
|
begin
|
||||||
|
List:=nil;
|
||||||
|
try
|
||||||
|
PackageGraph.GetAllRequiredPackages(Project1.FirstRequiredDependency,List);
|
||||||
|
if (List=nil) then exit;
|
||||||
|
for i:=0 to List.Count-1 do begin
|
||||||
|
if TObject(List[i]) is TLazPackage then
|
||||||
|
AddPackage(TLazPackage(List[i]));
|
||||||
|
end;
|
||||||
|
finally
|
||||||
|
List.Free;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
APackage: TLazPackage;
|
APackage: TLazPackage;
|
||||||
RootOwner: string;
|
RootOwner: string;
|
||||||
Root: TCodeBrowserUnitList;
|
|
||||||
i: Integer;
|
i: Integer;
|
||||||
begin
|
begin
|
||||||
// find root
|
// find root
|
||||||
@ -510,20 +551,70 @@ begin
|
|||||||
if APackage<>nil then
|
if APackage<>nil then
|
||||||
RootOwner:=APackage.Name;
|
RootOwner:=APackage.Name;
|
||||||
end;
|
end;
|
||||||
Root:=TCodeBrowserUnitList.Create(RootOwner,nil);
|
DebugLn(['TCodeBrowserView.WorkGatherPackages RootOwner="',RootOwner,'"']);
|
||||||
|
FreeAndNil(FWorkingRoot);
|
||||||
|
FWorkingRoot:=TCodeBrowserUnitList.Create(RootOwner,nil);
|
||||||
|
|
||||||
// find required packages
|
// find required packages
|
||||||
if Options.WithRequiredPackages then begin
|
if Options.WithRequiredPackages then begin
|
||||||
if CompareText(Root.Owner,CodeBrowserIDEAlias)=0 then begin
|
if CompareText(FWorkingRoot.Owner,CodeBrowserIDEAlias)=0 then begin
|
||||||
for i:=0 to PackageGraph.Count-1 do begin
|
for i:=0 to PackageGraph.Count-1 do
|
||||||
|
AddPackage(PackageGraph[i]);
|
||||||
end;
|
end else if CompareText(FWorkingRoot.Owner,CodeBrowserProjectAlias)=0 then begin
|
||||||
end else if CompareText(Root.Owner,CodeBrowserIDEAlias)=0 then begin
|
AddPackages(Project1.FirstRequiredDependency);
|
||||||
|
end else if FWorkingRoot.Owner<>'' then begin
|
||||||
end else begin
|
APackage:=PackageGraph.FindAPackageWithName(FWorkingRoot.Owner,nil);
|
||||||
|
if APackage<>nil then
|
||||||
|
AddPackages(APackage.FirstRequiredDependency);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
// update root item (childs will be updated on next Idle)
|
||||||
|
if FRoot=nil then begin
|
||||||
|
FRoot:=TCodeBrowserUnitList.Create(FWorkingRoot.Owner,nil);
|
||||||
|
end else begin
|
||||||
|
FRoot.Owner:=FWorkingRoot.Owner;
|
||||||
|
end;
|
||||||
|
|
||||||
|
// this stage finished -> next stage
|
||||||
|
fStage:=cbwsFreeUnusedPackages;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TCodeBrowserView.WorkFreeUnusedPackages;
|
||||||
|
|
||||||
|
function FindUnusedUnitList: TCodeBrowserUnitList;
|
||||||
|
var
|
||||||
|
Node: TAvgLvlTreeNode;
|
||||||
|
UnusedPackage: TCodeBrowserUnitList;
|
||||||
|
begin
|
||||||
|
// find an unused package
|
||||||
|
Result:=nil;
|
||||||
|
if (FRoot<>nil) and (FRoot.UnitLists<>nil) then begin
|
||||||
|
Node:=FRoot.UnitLists.FindLowest;
|
||||||
|
while Node<>nil do begin
|
||||||
|
UnusedPackage:=TCodeBrowserUnitList(Node.Data);
|
||||||
|
if UnusedPackage<>nil then begin
|
||||||
|
|
||||||
|
end;
|
||||||
|
Node:=FRoot.UnitLists.FindSuccessor(Node);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
var
|
||||||
|
UnusedPackage: TCodeBrowserUnitList;
|
||||||
|
begin
|
||||||
|
DebugLn(['TCodeBrowserView.WorkFreeUnusedPackages START']);
|
||||||
|
// find an unused package
|
||||||
|
UnusedPackage:=FindUnusedUnitList;
|
||||||
|
if UnusedPackage=nil then begin
|
||||||
|
// this stage finished -> next stage
|
||||||
|
fStage:=cbwsFreeUnusedPackages;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
|
||||||
|
// free this unused package
|
||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCodeBrowserView.BeginUpdate;
|
procedure TCodeBrowserView.BeginUpdate;
|
||||||
@ -587,6 +678,13 @@ end;
|
|||||||
|
|
||||||
{ TCodeBrowserUnitList }
|
{ TCodeBrowserUnitList }
|
||||||
|
|
||||||
|
procedure TCodeBrowserUnitList.SetOwner(const AValue: string);
|
||||||
|
begin
|
||||||
|
if Owner=AValue then exit;
|
||||||
|
if ParentList<>nil then RaiseGDBException('not allowed');
|
||||||
|
FOwner:=AValue;
|
||||||
|
end;
|
||||||
|
|
||||||
constructor TCodeBrowserUnitList.Create(TheOwner: string;
|
constructor TCodeBrowserUnitList.Create(TheOwner: string;
|
||||||
TheParent: TCodeBrowserUnitList);
|
TheParent: TCodeBrowserUnitList);
|
||||||
begin
|
begin
|
||||||
@ -605,6 +703,9 @@ begin
|
|||||||
if FUnits<>nil then
|
if FUnits<>nil then
|
||||||
FUnits.FreeAndClear;
|
FUnits.FreeAndClear;
|
||||||
FreeAndNil(FUnits);
|
FreeAndNil(FUnits);
|
||||||
|
if FUnitLists<>nil then
|
||||||
|
FUnitLists.FreeAndClear;
|
||||||
|
FreeAndNil(FUnitLists);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TCodeBrowserViewOptions }
|
{ TCodeBrowserViewOptions }
|
||||||
|
@ -1982,7 +1982,9 @@ begin
|
|||||||
itmViewSourceEditor.OnClick := @mnuViewSourceEditorClicked;
|
itmViewSourceEditor.OnClick := @mnuViewSourceEditorClicked;
|
||||||
itmViewCodeExplorer.OnClick := @mnuViewCodeExplorerClick;
|
itmViewCodeExplorer.OnClick := @mnuViewCodeExplorerClick;
|
||||||
itmViewCodeBrowser.OnClick := @mnuViewCodeBrowserClick;
|
itmViewCodeBrowser.OnClick := @mnuViewCodeBrowserClick;
|
||||||
|
{$IFNDEF EnableCodeBrowser}
|
||||||
itmViewCodeBrowser.Visible:=false;
|
itmViewCodeBrowser.Visible:=false;
|
||||||
|
{$ENDIF}
|
||||||
itmViewLazDoc.OnClick := @mnuViewLazDocClicked; //DBlaszijk 5-sep-05
|
itmViewLazDoc.OnClick := @mnuViewLazDocClicked; //DBlaszijk 5-sep-05
|
||||||
itmViewUnits.OnClick := @mnuViewUnitsClicked;
|
itmViewUnits.OnClick := @mnuViewUnitsClicked;
|
||||||
itmViewForms.OnClick := @mnuViewFormsClicked;
|
itmViewForms.OnClick := @mnuViewFormsClicked;
|
||||||
|
@ -62,7 +62,8 @@ type
|
|||||||
icvIdentifier,
|
icvIdentifier,
|
||||||
icvProcWithParams,
|
icvProcWithParams,
|
||||||
icvIndexedProp,
|
icvIndexedProp,
|
||||||
icvCompleteProcDeclaration
|
icvCompleteProcDeclaration,
|
||||||
|
icvUnitName
|
||||||
);
|
);
|
||||||
|
|
||||||
// completion form and functions
|
// completion form and functions
|
||||||
@ -370,6 +371,17 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function FindUnitName(IdentList: TIdentifierList;
|
||||||
|
IdentItem: TIdentifierListItem): string;
|
||||||
|
var
|
||||||
|
CodeBuf: TCodeBuffer;
|
||||||
|
begin
|
||||||
|
Result:=GetIdentifier(IdentItem.Identifier);
|
||||||
|
CodeBuf:=CodeToolBoss.FindUnitSource(IdentList.StartContextPos.Code,Result,'');
|
||||||
|
if CodeBuf=nil then exit;
|
||||||
|
Result:=CodeToolBoss.GetSourceName(CodeBuf,true);
|
||||||
|
end;
|
||||||
|
|
||||||
function GetIdentCompletionValue(aCompletion : TSynCompletion;
|
function GetIdentCompletionValue(aCompletion : TSynCompletion;
|
||||||
AddChar: TUTF8Char;
|
AddChar: TUTF8Char;
|
||||||
out ValueType: TIdentComplValue; out CursorToLeft: integer): string;
|
out ValueType: TIdentComplValue; out CursorToLeft: integer): string;
|
||||||
@ -413,6 +425,8 @@ begin
|
|||||||
if IdentItem.IsPropertyWithParams then
|
if IdentItem.IsPropertyWithParams then
|
||||||
ValueType:=icvIndexedProp;
|
ValueType:=icvIndexedProp;
|
||||||
|
|
||||||
|
ctnUnit, ctnPackage, ctnLibrary:
|
||||||
|
ValueType:=icvUnitName;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
case ValueType of
|
case ValueType of
|
||||||
@ -465,6 +479,11 @@ begin
|
|||||||
.BeautifyCodeOptions.BeautifyProc(
|
.BeautifyCodeOptions.BeautifyProc(
|
||||||
Result,CodeToolBoss.IdentifierList.StartContextPos.X,false));
|
Result,CodeToolBoss.IdentifierList.StartContextPos.X,false));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
icvUnitName:
|
||||||
|
begin
|
||||||
|
Result:=FindUnitName(IdentList,IdentItem);
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{if (ilcfStartIsLValue in IdentList.ContextFlags)
|
{if (ilcfStartIsLValue in IdentList.ContextFlags)
|
||||||
|
@ -63,7 +63,7 @@ type
|
|||||||
TIteratePackagesEvent =
|
TIteratePackagesEvent =
|
||||||
procedure(APackage: TLazPackageID) of object;
|
procedure(APackage: TLazPackageID) of object;
|
||||||
TGetAllRequiredPackagesEvent =
|
TGetAllRequiredPackagesEvent =
|
||||||
procedure(FirstDependency: TPkgDependency; var List: TFPList) of object;
|
procedure(FirstDependency: TPkgDependency; out List: TFPList) of object;
|
||||||
TGetDependencyOwnerDescription =
|
TGetDependencyOwnerDescription =
|
||||||
procedure(Dependency: TPkgDependency; out Description: string) of object;
|
procedure(Dependency: TPkgDependency; out Description: string) of object;
|
||||||
TGetDependencyOwnerDirectory =
|
TGetDependencyOwnerDirectory =
|
||||||
|
@ -219,7 +219,7 @@ type
|
|||||||
function PackageNameExists(const PkgName: string;
|
function PackageNameExists(const PkgName: string;
|
||||||
IgnorePackage: TLazPackage): boolean;
|
IgnorePackage: TLazPackage): boolean;
|
||||||
procedure GetAllRequiredPackages(FirstDependency: TPkgDependency;
|
procedure GetAllRequiredPackages(FirstDependency: TPkgDependency;
|
||||||
var List: TFPList);
|
out List: TFPList);
|
||||||
procedure GetConnectionsTree(FirstDependency: TPkgDependency;
|
procedure GetConnectionsTree(FirstDependency: TPkgDependency;
|
||||||
var PkgList: TFPList; var Tree: TPkgPairTree);
|
var PkgList: TFPList; var Tree: TPkgPairTree);
|
||||||
function GetAutoCompilationOrder(APackage: TLazPackage;
|
function GetAutoCompilationOrder(APackage: TLazPackage;
|
||||||
@ -3553,7 +3553,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TLazPackageGraph.GetAllRequiredPackages(
|
procedure TLazPackageGraph.GetAllRequiredPackages(
|
||||||
FirstDependency: TPkgDependency; var List: TFPList);
|
FirstDependency: TPkgDependency; out List: TFPList);
|
||||||
// returns packages in topological order, beginning with the top level package
|
// returns packages in topological order, beginning with the top level package
|
||||||
|
|
||||||
procedure GetTopologicalOrder(CurDependency: TPkgDependency);
|
procedure GetTopologicalOrder(CurDependency: TPkgDependency);
|
||||||
|
Loading…
Reference in New Issue
Block a user