mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-24 17:40:26 +02:00
cody: show uses path
git-svn-id: trunk@29515 -
This commit is contained in:
parent
d1c893c176
commit
bba3e2b3fc
@ -34,7 +34,9 @@ resourcestring
|
||||
crsPleaseOpenAProjectFirst = 'Please open a project first.';
|
||||
crsPPUFilesOfProject = 'PPU files of project "%s"';
|
||||
crsUses = 'Uses';
|
||||
lisCOGeneral = 'General';
|
||||
crsUsedBy = 'Used by';
|
||||
lisCOUsesPath = 'Uses path';
|
||||
crsProjectHasNoMainSourceFile = 'Project has no main source file.';
|
||||
crsMainSourceFile = 'Main source file: %s';
|
||||
crsSizeOfPpuFile = 'Size of .ppu file';
|
||||
|
@ -49,3 +49,11 @@ msgstr ""
|
||||
msgid "Uses"
|
||||
msgstr ""
|
||||
|
||||
#: codystrconsts.liscogeneral
|
||||
msgid "General"
|
||||
msgstr ""
|
||||
|
||||
#: codystrconsts.liscousespath
|
||||
msgid "Uses path"
|
||||
msgstr ""
|
||||
|
||||
|
@ -57,3 +57,11 @@ msgstr "Используется"
|
||||
msgid "Uses"
|
||||
msgstr "Использует"
|
||||
|
||||
#: codystrconsts.liscogeneral
|
||||
msgid "General"
|
||||
msgstr ""
|
||||
|
||||
#: codystrconsts.liscousespath
|
||||
msgid "Uses path"
|
||||
msgstr ""
|
||||
|
||||
|
@ -1,11 +1,11 @@
|
||||
object PPUListDialog: TPPUListDialog
|
||||
Left = 275
|
||||
Height = 526
|
||||
Height = 531
|
||||
Top = 250
|
||||
Width = 613
|
||||
Width = 740
|
||||
Caption = 'PPUListDialog'
|
||||
ClientHeight = 526
|
||||
ClientWidth = 613
|
||||
ClientHeight = 531
|
||||
ClientWidth = 740
|
||||
OnClose = FormClose
|
||||
OnCreate = FormCreate
|
||||
OnDestroy = FormDestroy
|
||||
@ -14,8 +14,8 @@ object PPUListDialog: TPPUListDialog
|
||||
object ButtonPanel1: TButtonPanel
|
||||
Left = 6
|
||||
Height = 40
|
||||
Top = 480
|
||||
Width = 601
|
||||
Top = 485
|
||||
Width = 728
|
||||
OKButton.Name = 'OKButton'
|
||||
OKButton.Caption = '&OK'
|
||||
OKButton.Enabled = False
|
||||
@ -34,7 +34,7 @@ object PPUListDialog: TPPUListDialog
|
||||
Left = 6
|
||||
Height = 244
|
||||
Top = 30
|
||||
Width = 601
|
||||
Width = 728
|
||||
Align = alTop
|
||||
AutoFillColumns = True
|
||||
BorderSpacing.Around = 6
|
||||
@ -42,27 +42,27 @@ object PPUListDialog: TPPUListDialog
|
||||
item
|
||||
SizePriority = 10
|
||||
Title.Caption = 'Unit'
|
||||
Width = 119
|
||||
Width = 145
|
||||
end
|
||||
item
|
||||
SizePriority = 10
|
||||
Title.Caption = 'Size of .ppu file'
|
||||
Width = 119
|
||||
Width = 145
|
||||
end
|
||||
item
|
||||
SizePriority = 10
|
||||
Title.Caption = 'Size of .o file'
|
||||
Width = 119
|
||||
Width = 145
|
||||
end
|
||||
item
|
||||
SizePriority = 5
|
||||
Title.Caption = 'Uses'
|
||||
Width = 119
|
||||
Width = 145
|
||||
end
|
||||
item
|
||||
SizePriority = 5
|
||||
Title.Caption = 'Used by'
|
||||
Width = 123
|
||||
Width = 146
|
||||
end>
|
||||
DefaultColWidth = 150
|
||||
FixedCols = 0
|
||||
@ -72,18 +72,18 @@ object PPUListDialog: TPPUListDialog
|
||||
OnMouseDown = UnitsStringGridMouseDown
|
||||
OnSelectCell = UnitsStringGridSelectCell
|
||||
ColWidths = (
|
||||
119
|
||||
119
|
||||
119
|
||||
119
|
||||
123
|
||||
145
|
||||
145
|
||||
145
|
||||
145
|
||||
146
|
||||
)
|
||||
end
|
||||
object ScopeLabel: TLabel
|
||||
Left = 6
|
||||
Height = 18
|
||||
Top = 6
|
||||
Width = 601
|
||||
Width = 728
|
||||
Align = alTop
|
||||
BorderSpacing.Around = 6
|
||||
Caption = 'ScopeLabel'
|
||||
@ -94,77 +94,121 @@ object PPUListDialog: TPPUListDialog
|
||||
Left = 0
|
||||
Height = 5
|
||||
Top = 280
|
||||
Width = 613
|
||||
Width = 740
|
||||
Align = alTop
|
||||
ResizeAnchor = akTop
|
||||
end
|
||||
object UnitGroupBox: TGroupBox
|
||||
Left = 6
|
||||
Height = 183
|
||||
Height = 188
|
||||
Top = 291
|
||||
Width = 601
|
||||
Width = 728
|
||||
Align = alClient
|
||||
BorderSpacing.Around = 6
|
||||
Caption = 'UnitGroupBox'
|
||||
ClientHeight = 162
|
||||
ClientWidth = 593
|
||||
ClientHeight = 167
|
||||
ClientWidth = 720
|
||||
TabOrder = 3
|
||||
object UnitPageControl: TPageControl
|
||||
Left = 0
|
||||
Height = 162
|
||||
Height = 167
|
||||
Top = 0
|
||||
Width = 593
|
||||
ActivePage = UnitUsesTabSheet
|
||||
Width = 720
|
||||
ActivePage = UsesPathTabSheet
|
||||
Align = alClient
|
||||
TabIndex = 0
|
||||
TabIndex = 3
|
||||
TabOrder = 0
|
||||
object UnitUsesTabSheet: TTabSheet
|
||||
Caption = 'UnitUsesTabSheet'
|
||||
ClientHeight = 129
|
||||
ClientWidth = 589
|
||||
object UnitUsesStringGrid: TStringGrid
|
||||
object InfoTabSheet: TTabSheet
|
||||
Caption = 'InfoTabSheet'
|
||||
ClientHeight = 134
|
||||
ClientWidth = 716
|
||||
object SourceFileLabel: TLabel
|
||||
Left = 9
|
||||
Height = 18
|
||||
Top = 14
|
||||
Width = 109
|
||||
Caption = 'SourceFileLabel'
|
||||
ParentColor = False
|
||||
end
|
||||
object PPUFileLabel: TLabel
|
||||
AnchorSideTop.Control = SourceFileLabel
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 9
|
||||
Height = 18
|
||||
Top = 38
|
||||
Width = 91
|
||||
BorderSpacing.Top = 6
|
||||
Caption = 'PPUFileLabel'
|
||||
ParentColor = False
|
||||
end
|
||||
end
|
||||
object UsesTabSheet: TTabSheet
|
||||
Caption = 'UsesTabSheet'
|
||||
ClientHeight = 134
|
||||
ClientWidth = 716
|
||||
object UsesStringGrid: TStringGrid
|
||||
Left = 0
|
||||
Height = 129
|
||||
Height = 134
|
||||
Top = 0
|
||||
Width = 589
|
||||
Width = 716
|
||||
Align = alClient
|
||||
AutoFillColumns = True
|
||||
ColCount = 1
|
||||
Columns = <
|
||||
item
|
||||
Title.Caption = 'Unit'
|
||||
Width = 587
|
||||
Width = 714
|
||||
end>
|
||||
FixedCols = 0
|
||||
Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goThumbTracking, goSmoothScroll]
|
||||
TabOrder = 0
|
||||
ColWidths = (
|
||||
587
|
||||
714
|
||||
)
|
||||
end
|
||||
end
|
||||
object UnitUsedByTabSheet: TTabSheet
|
||||
Caption = 'UnitUsedByTabSheet'
|
||||
ClientHeight = 129
|
||||
ClientWidth = 589
|
||||
object UnitUsedByStringGrid: TStringGrid
|
||||
object UsedByTabSheet: TTabSheet
|
||||
Caption = 'UsedByTabSheet'
|
||||
ClientHeight = 134
|
||||
ClientWidth = 716
|
||||
object UsedByStringGrid: TStringGrid
|
||||
Left = 0
|
||||
Height = 129
|
||||
Height = 134
|
||||
Top = 0
|
||||
Width = 589
|
||||
Width = 716
|
||||
Align = alClient
|
||||
AutoFillColumns = True
|
||||
ColCount = 1
|
||||
Columns = <
|
||||
item
|
||||
Title.Caption = 'Unit'
|
||||
Width = 589
|
||||
Width = 714
|
||||
end>
|
||||
FixedCols = 0
|
||||
Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goThumbTracking, goSmoothScroll]
|
||||
TabOrder = 0
|
||||
ColWidths = (
|
||||
589
|
||||
714
|
||||
)
|
||||
end
|
||||
end
|
||||
object UsesPathTabSheet: TTabSheet
|
||||
Caption = 'UsesPathTabSheet'
|
||||
ClientHeight = 134
|
||||
ClientWidth = 716
|
||||
object UsesPathStringGrid: TStringGrid
|
||||
Left = 0
|
||||
Height = 134
|
||||
Top = 0
|
||||
Width = 716
|
||||
Align = alClient
|
||||
AutoFillColumns = True
|
||||
ColCount = 1
|
||||
FixedCols = 0
|
||||
FixedRows = 0
|
||||
TabOrder = 0
|
||||
ColWidths = (
|
||||
714
|
||||
)
|
||||
end
|
||||
end
|
||||
|
@ -82,10 +82,15 @@ type
|
||||
ButtonPanel1: TButtonPanel;
|
||||
ScopeLabel: TLabel;
|
||||
Splitter1: TSplitter;
|
||||
UnitUsedByStringGrid: TStringGrid;
|
||||
UnitUsesStringGrid: TStringGrid;
|
||||
UnitUsesTabSheet: TTabSheet;
|
||||
UnitUsedByTabSheet: TTabSheet;
|
||||
InfoTabSheet: TTabSheet;
|
||||
PPUFileLabel: TLabel;
|
||||
SourceFileLabel: TLabel;
|
||||
UsesPathStringGrid: TStringGrid;
|
||||
UsesPathTabSheet: TTabSheet;
|
||||
UsedByStringGrid: TStringGrid;
|
||||
UsesStringGrid: TStringGrid;
|
||||
UsesTabSheet: TTabSheet;
|
||||
UsedByTabSheet: TTabSheet;
|
||||
UnitGroupBox: TGroupBox;
|
||||
UnitPageControl: TPageControl;
|
||||
UnitsStringGrid: TStringGrid;
|
||||
@ -97,6 +102,7 @@ type
|
||||
procedure UnitsStringGridSelectCell(Sender: TObject; {%H-}aCol, aRow: Integer;
|
||||
var {%H-}CanSelect: Boolean);
|
||||
private
|
||||
FMainItem: TPPUListItem;
|
||||
FProject: TLazProject;
|
||||
FIdleConnected: boolean;
|
||||
FSearchingItems: TAvgLvlTree; // tree of TPPUListItem sorted for TheUnitName
|
||||
@ -111,6 +117,7 @@ type
|
||||
|
||||
function FindUnit(AnUnitName: string): TPPUListItem;
|
||||
function FindUnitInList(AnUnitName: string; List: TStrings): integer;
|
||||
function FindUnitOfListitem(List: TStrings; Index: integer): TPPUListItem;
|
||||
|
||||
procedure UpdateAll;
|
||||
|
||||
@ -120,12 +127,14 @@ type
|
||||
|
||||
// units info
|
||||
procedure FillUnitsInfo(AnUnitName: string);
|
||||
function FindUsesPath(UsingUnit, UsedUnit: TPPUListItem): TFPList;
|
||||
|
||||
function DoubleAsPercentage(const d: double): string;
|
||||
function BytesToStr(b: int64): string;
|
||||
public
|
||||
property AProject: TLazProject read FProject write SetProject;
|
||||
property IdleConnected: boolean read FIdleConnected write SetIdleConnected;
|
||||
property MainItem: TPPUListItem read FMainItem;
|
||||
end;
|
||||
|
||||
procedure ShowPPUList(Sender: TObject);
|
||||
@ -221,9 +230,11 @@ begin
|
||||
FSort[2].Category:=plsName;
|
||||
FSort[3].Category:=plsPPUSize;
|
||||
|
||||
UnitUsesTabSheet.Caption:=crsUses;
|
||||
UnitUsedByTabSheet.Caption:=crsUsedBy;
|
||||
InfoTabSheet.Caption:=lisCOGeneral;
|
||||
UsesTabSheet.Caption:=crsUses;
|
||||
UsedByTabSheet.Caption:=crsUsedBy;
|
||||
UnitPageControl.PageIndex:=0;
|
||||
UsesPathTabSheet.Caption:=lisCOUsesPath;
|
||||
|
||||
IDEDialogLayoutList.ApplyLayout(Self);
|
||||
end;
|
||||
@ -295,6 +306,7 @@ procedure TPPUListDialog.SetProject(const AValue: TLazProject);
|
||||
begin
|
||||
if FProject=AValue then exit;
|
||||
FProject:=AValue;
|
||||
FMainItem:=nil;
|
||||
UpdateAll;
|
||||
end;
|
||||
|
||||
@ -308,6 +320,16 @@ begin
|
||||
Application.RemoveOnIdleHandler(@OnIdle);
|
||||
end;
|
||||
|
||||
function TPPUListDialog.FindUnitOfListitem(List: TStrings; Index: integer
|
||||
): TPPUListItem;
|
||||
begin
|
||||
Result:=TPPUListItem(List.Objects[Index]);
|
||||
if Result<>nil then exit;
|
||||
Result:=FindUnit(List[Index]);
|
||||
if Result<>nil then
|
||||
List.Objects[Index]:=Result;
|
||||
end;
|
||||
|
||||
procedure TPPUListDialog.UpdateAll;
|
||||
var
|
||||
s: String;
|
||||
@ -334,6 +356,7 @@ begin
|
||||
end else begin
|
||||
ScopeLabel.Caption:=Format(crsMainSourceFile, [MainUnit.Filename]);
|
||||
Item:=TPPUListItem.Create;
|
||||
FMainItem:=Item;
|
||||
Item.TheUnitName:=ExtractFileName(MainUnit.Filename);
|
||||
Item.SrcFile:=MainUnit.Filename;
|
||||
Item.PPUFile:=AProject.LazCompilerOptions.CreatePPUFilename(Item.SrcFile);
|
||||
@ -543,6 +566,7 @@ var
|
||||
i: Integer;
|
||||
UsesUnitName: string;
|
||||
UsedByUnitName: string;
|
||||
UsesPath: TFPList;
|
||||
begin
|
||||
Item:=FindUnit(AnUnitName);
|
||||
if Item=nil then begin
|
||||
@ -551,26 +575,79 @@ begin
|
||||
end else begin
|
||||
UnitGroupBox.Caption:='Unit: '+AnUnitName;
|
||||
UnitGroupBox.Enabled:=true;
|
||||
// info
|
||||
SourceFileLabel.Caption:='Source: '+Item.SrcFile;
|
||||
PPUFileLabel.Caption:='PPU: '+Item.PPUFile;
|
||||
// uses
|
||||
if Item.UsesUnits<>nil then begin
|
||||
UnitUsesStringGrid.RowCount:=1+Item.UsesUnits.Count;
|
||||
UsesStringGrid.RowCount:=1+Item.UsesUnits.Count;
|
||||
for i:=0 to Item.UsesUnits.Count-1 do begin
|
||||
UsesUnitName:=Item.UsesUnits[i];
|
||||
UnitUsesStringGrid.Cells[0,i+1]:=UsesUnitName;
|
||||
UsesStringGrid.Cells[0,i+1]:=UsesUnitName;
|
||||
end;
|
||||
end else begin
|
||||
UnitUsesStringGrid.RowCount:=1;
|
||||
UsesStringGrid.RowCount:=1;
|
||||
end;
|
||||
// used by
|
||||
if Item.UsedByUnits<>nil then begin
|
||||
UnitUsedByStringGrid.RowCount:=1+Item.UsedByUnits.Count;
|
||||
UsedByStringGrid.RowCount:=1+Item.UsedByUnits.Count;
|
||||
for i:=0 to Item.UsedByUnits.Count-1 do begin
|
||||
UsedByUnitName:=Item.UsedByUnits[i];
|
||||
UnitUsedByStringGrid.Cells[0,i+1]:=UsedByUnitName;
|
||||
UsedByStringGrid.Cells[0,i+1]:=UsedByUnitName;
|
||||
end;
|
||||
end else begin
|
||||
UnitUsedByStringGrid.RowCount:=1;
|
||||
UsedByStringGrid.RowCount:=1;
|
||||
end;
|
||||
// uses path
|
||||
UsesPath:=FindUsesPath(MainItem,Item);
|
||||
try
|
||||
UsesPathStringGrid.RowCount:=UsesPath.Count;
|
||||
for i:=0 to UsesPath.Count-1 do begin
|
||||
UsesPathStringGrid.Cells[0,i]:=TPPUListItem(UsesPath[i]).TheUnitName;
|
||||
end;
|
||||
finally
|
||||
UsesPath.Free;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TPPUListDialog.FindUsesPath(UsingUnit, UsedUnit: TPPUListItem): TFPList;
|
||||
{ Search a path from UsingUnit to UsedUnit
|
||||
Result is a list of TPPUListItem
|
||||
}
|
||||
var
|
||||
Visited: TAvgLvlTree;
|
||||
|
||||
function Search(Item: TPPUListItem; Path: TFPList): boolean;
|
||||
var
|
||||
i: Integer;
|
||||
ParentUnit: TPPUListItem;
|
||||
begin
|
||||
Result:=false;
|
||||
if Visited.Find(Item)<>nil then exit;
|
||||
Visited.Add(Item);
|
||||
if Item.UsedByUnits<>nil then begin
|
||||
for i:=0 to Item.UsedByUnits.Count-1 do begin
|
||||
ParentUnit:=FindUnitOfListitem(Item.UsedByUnits,i);
|
||||
if (ParentUnit=nil) or (Visited.Find(ParentUnit)<>nil) then continue;
|
||||
if (ParentUnit=UsingUnit) or Search(ParentUnit,Path) then begin
|
||||
// path found
|
||||
Path.Add(ParentUnit);
|
||||
exit(true);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
begin
|
||||
Result:=TFPList.Create;
|
||||
if (UsingUnit=nil) or (UsedUnit=nil) then exit;
|
||||
Visited:=TAvgLvlTree.Create(@ComparePPUListItems);
|
||||
try
|
||||
if Search(UsedUnit,Result) then
|
||||
Result.Add(UsedUnit);
|
||||
finally
|
||||
Visited.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -700,13 +777,14 @@ begin
|
||||
for i:=0 to UsedUnits.Count-1 do begin
|
||||
AnUnitName:=UsedUnits[i];
|
||||
//debugln(['TPPUListDialog.AddUses ',SrcItem.TheUnitName,' uses ',AnUnitName]);
|
||||
UsedUnit:=FindUnit(AnUnitName);
|
||||
UsedUnit:=FindUnitOfListitem(UsedUnits,i);
|
||||
if UsedUnit=nil then begin
|
||||
// new unit
|
||||
UsedUnit:=TPPUListItem.Create;
|
||||
UsedUnit.TheUnitName:=AnUnitName;
|
||||
FItems.Add(UsedUnit);
|
||||
FSearchingItems.Add(UsedUnit);
|
||||
UsedUnits.Objects[i]:=UsedUnit;
|
||||
UsedUnit.UsedByUnits:=TStringList.Create;
|
||||
end;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user