cody: showing linked files of each unit

git-svn-id: trunk@30856 -
This commit is contained in:
mattias 2011-05-22 11:13:07 +00:00
parent 6c0621a69f
commit f7ef16776e
8 changed files with 227 additions and 34 deletions

View File

@ -45,6 +45,10 @@ resourcestring
crsSearching = 'searching ...';
crsMissing = 'missing ...';
crsUnit = 'Unit';
crsLinkedFiles = 'Linked files';
crsType = 'Type';
crsFile = 'File';
crsFlags = 'Flags';
crsPackage = 'Package';
crsKbytes = 'kbytes';
crsMbytes = 'Mbytes';

View File

@ -182,6 +182,14 @@ msgstr ""
msgid "Declare Variable ..."
msgstr ""
#: codystrconsts.crsfile
msgid "File"
msgstr ""
#: codystrconsts.crsflags
msgid "Flags"
msgstr ""
#: codystrconsts.crsgbytes
msgid "Gbytes"
msgstr "Gbyte"
@ -194,6 +202,10 @@ msgstr ""
msgid "kbytes"
msgstr "Kbyte"
#: codystrconsts.crslinkedfiles
msgid "Linked files"
msgstr ""
#: codystrconsts.crsmainsourcefile
msgid "Main source file: %s"
msgstr "File sorgente principale: %s"
@ -288,6 +300,10 @@ msgstr "Sorgente: %s"
msgid "Total"
msgstr "Totale"
#: codystrconsts.crstype
msgid "Type"
msgstr ""
#: codystrconsts.crsunit
msgid "Unit"
msgstr ""

View File

@ -173,6 +173,14 @@ msgstr ""
msgid "Declare Variable ..."
msgstr ""
#: codystrconsts.crsfile
msgid "File"
msgstr ""
#: codystrconsts.crsflags
msgid "Flags"
msgstr ""
#: codystrconsts.crsgbytes
msgid "Gbytes"
msgstr ""
@ -185,6 +193,10 @@ msgstr ""
msgid "kbytes"
msgstr ""
#: codystrconsts.crslinkedfiles
msgid "Linked files"
msgstr ""
#: codystrconsts.crsmainsourcefile
msgid "Main source file: %s"
msgstr ""
@ -277,6 +289,10 @@ msgstr ""
msgid "Total"
msgstr ""
#: codystrconsts.crstype
msgid "Type"
msgstr ""
#: codystrconsts.crsunit
msgid "Unit"
msgstr ""

View File

@ -181,6 +181,14 @@ msgstr "Declarar Variável"
msgid "Declare Variable ..."
msgstr "Declarar Variável ..."
#: codystrconsts.crsfile
msgid "File"
msgstr ""
#: codystrconsts.crsflags
msgid "Flags"
msgstr ""
#: codystrconsts.crsgbytes
msgid "Gbytes"
msgstr "Gbytes"
@ -193,6 +201,10 @@ msgstr "Inserir arquivo na posição do cursor ..."
msgid "kbytes"
msgstr "kbytes"
#: codystrconsts.crslinkedfiles
msgid "Linked files"
msgstr ""
#: codystrconsts.crsmainsourcefile
msgid "Main source file: %s"
msgstr "Arquivo fonte principal: %s"
@ -286,6 +298,10 @@ msgstr "Fonte: %s"
msgid "Total"
msgstr "Total"
#: codystrconsts.crstype
msgid "Type"
msgstr ""
#: codystrconsts.crsunit
msgid "Unit"
msgstr "Unidade"

View File

@ -181,6 +181,14 @@ msgstr "Объявить переменную"
msgid "Declare Variable ..."
msgstr "Объявить переменную ..."
#: codystrconsts.crsfile
msgid "File"
msgstr ""
#: codystrconsts.crsflags
msgid "Flags"
msgstr ""
#: codystrconsts.crsgbytes
msgid "Gbytes"
msgstr "ГБ"
@ -193,6 +201,10 @@ msgstr "Вставить содержимое файла в месте расп
msgid "kbytes"
msgstr "кБ"
#: codystrconsts.crslinkedfiles
msgid "Linked files"
msgstr ""
#: codystrconsts.crsmainsourcefile
msgid "Main source file: %s"
msgstr "Главный файл исходного кода: %s"
@ -287,6 +299,10 @@ msgstr "Файл исходного кода: %s"
msgid "Total"
msgstr "Всего"
#: codystrconsts.crstype
msgid "Type"
msgstr ""
#: codystrconsts.crsunit
msgid "Unit"
msgstr "Модуль"

View File

@ -118,9 +118,9 @@ object PPUListDialog: TPPUListDialog
Height = 165
Top = 0
Width = 720
ActivePage = UsesTabSheet
ActivePage = LinkedFilesTabSheet
Align = alClient
TabIndex = 1
TabIndex = 4
TabOrder = 0
object InfoTabSheet: TTabSheet
Caption = 'InfoTabSheet'
@ -174,11 +174,11 @@ object PPUListDialog: TPPUListDialog
end
object UsedByTabSheet: TTabSheet
Caption = 'UsedByTabSheet'
ClientHeight = 134
ClientHeight = 132
ClientWidth = 716
object UsedByStringGrid: TStringGrid
Left = 0
Height = 134
Height = 132
Top = 0
Width = 716
Align = alClient
@ -187,24 +187,24 @@ object PPUListDialog: TPPUListDialog
Columns = <
item
Title.Caption = 'Unit'
Width = 716
Width = 714
end>
FixedCols = 0
Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goThumbTracking, goSmoothScroll]
TabOrder = 0
OnMouseDown = UnitStringGridMouseDown
ColWidths = (
716
714
)
end
end
object UsesPathTabSheet: TTabSheet
Caption = 'UsesPathTabSheet'
ClientHeight = 134
ClientHeight = 132
ClientWidth = 716
object UsesPathStringGrid: TStringGrid
Left = 0
Height = 134
Height = 132
Top = 0
Width = 716
Align = alClient
@ -213,13 +213,47 @@ object PPUListDialog: TPPUListDialog
Columns = <
item
Title.Caption = 'Unit'
Width = 716
Width = 714
end>
FixedCols = 0
TabOrder = 0
OnMouseDown = UnitStringGridMouseDown
ColWidths = (
716
714
)
end
end
object LinkedFilesTabSheet: TTabSheet
Caption = 'LinkedFilesTabSheet'
ClientHeight = 132
ClientWidth = 716
object UnitLinkedFilesStringGrid: TStringGrid
Left = 0
Height = 132
Top = 0
Width = 716
Align = alClient
AutoFillColumns = True
ColCount = 3
Columns = <
item
Title.Caption = 'Type'
Width = 238
end
item
Title.Caption = 'File'
Width = 238
end
item
Title.Caption = 'Flags'
Width = 238
end>
FixedCols = 0
TabOrder = 0
ColWidths = (
238
238
238
)
end
end

View File

@ -30,9 +30,9 @@ unit PPUListDlg;
interface
uses
Classes, SysUtils, math, LCLProc, FileUtil, LResources, Forms, Controls,
Graphics, Dialogs, ButtonPanel, Grids, StdCtrls, AvgLvlTree, ExtCtrls,
ComCtrls,
Classes, SysUtils, contnrs, math, LCLProc, FileUtil, LResources, Forms,
Controls, Graphics, Dialogs, ButtonPanel, Grids, StdCtrls, AvgLvlTree,
ExtCtrls, ComCtrls,
// IDEIntf
ProjectIntf, LazIDEIntf, IDEDialogs, IDEWindowIntf,
PackageIntf,
@ -74,6 +74,7 @@ type
OFileSize: int64;
UsesUnits: TStrings; // =nil means uses section not yet scanned
UsedByUnits: TStrings;
LinkedFiles: TObjectList; // list of TPPULinkedFile
PackageName: string;
destructor Destroy; override;
function UsesCount: integer;
@ -89,6 +90,8 @@ type
InfoTabSheet: TTabSheet;
PPUFileLabel: TLabel;
SourceFileLabel: TLabel;
LinkedFilesTabSheet: TTabSheet;
UnitLinkedFilesStringGrid: TStringGrid;
UsesPathStringGrid: TStringGrid;
UsesPathTabSheet: TTabSheet;
UsedByStringGrid: TStringGrid;
@ -194,6 +197,7 @@ destructor TPPUListItem.Destroy;
begin
FreeAndNil(UsesUnits);
FreeAndNil(UsedByUnits);
FreeAndNil(LinkedFiles);
inherited Destroy;
end;
@ -232,15 +236,23 @@ begin
UnitsStringGrid.Columns[5].Title.Caption:=crsPackage;
InfoTabSheet.Caption:=lisCOGeneral;
UsesTabSheet.Caption:=crsUses;
UsedByTabSheet.Caption:=crsUsedBy;
UnitPageControl.PageIndex:=0;
UsesPathTabSheet.Caption:=lisCOUsesPath;
UsesTabSheet.Caption:=crsUses;
UsesStringGrid.Columns[0].Title.Caption:=crsUnit;
UsedByTabSheet.Caption:=crsUsedBy;
UsedByStringGrid.Columns[0].Title.Caption:=crsUnit;
UsesPathTabSheet.Caption:=lisCOUsesPath;
UsesPathStringGrid.Columns[0].Title.Caption:=crsUnit;
LinkedFilesTabSheet.Caption:=crsLinkedFiles;
UnitLinkedFilesStringGrid.Columns[0].Title.Caption:=crsType;
UnitLinkedFilesStringGrid.Columns[1].Title.Caption:=crsFile;
UnitLinkedFilesStringGrid.Columns[2].Title.Caption:=crsFlags;
UnitPageControl.PageIndex:=0;
ButtonPanel1.CloseButton.Caption:=crsClose;
IDEDialogLayoutList.ApplyLayout(Self);
@ -691,6 +703,8 @@ var
UsesUnitName: string;
UsedByUnitName: string;
UsesPath: TFPList;
LinkedFile: TPPULinkedFile;
Grid: TStringGrid;
begin
Item:=FindUnit(AnUnitName);
if Item=nil then begin
@ -734,6 +748,20 @@ begin
finally
UsesPath.Free;
end;
// linked files
Grid:=UnitLinkedFilesStringGrid;
if Item.LinkedFiles<>nil then begin
Grid.RowCount:=1+Item.LinkedFiles.Count;
for i:=0 to Item.LinkedFiles.Count-1 do begin
LinkedFile:=TPPULinkedFile(Item.LinkedFiles[i]);
Grid.Cells[0,i+1]:=PPUEntryName(LinkedFile.ID);
Grid.Cells[1,i+1]:=LinkedFile.Filename;
Grid.Cells[2,i+1]:=PPULinkContainerFlagToStr(LinkedFile.Flags);
end;
end else begin
Grid.RowCount:=1;
end;
end;
end;
@ -852,11 +880,13 @@ begin
//debugln(['TPPUListDialog.OnIdle parsed ppu "',Item.PPUFile,'"']);
MainUsesSection:=nil;
ImplementationUsesSection:=nil;
FreeAndNil(Item.LinkedFiles);
try
PPUTool.PPU.GetMainUsesSectionNames(MainUsesSection);
AddUses(Item,MainUsesSection);
PPUTool.PPU.GetImplementationUsesSectionNames(ImplementationUsesSection);
AddUses(Item,ImplementationUsesSection);
PPUTool.PPU.GetLinkedFiles(Item.LinkedFiles);
Scanned:=true;
finally
MainUsesSection.Free;

View File

@ -37,7 +37,7 @@ unit PPUParser;
interface
uses
Classes, SysUtils, FileProcs;
Classes, SysUtils, FileProcs, contnrs;
const
PPUIsEndianBig = {$IFDEF ENDIAN_BIG}True{$ELSE}False{$ENDIF};
@ -497,6 +497,13 @@ type
constructor Create(ASender: TPPU; const AMessage: string);
end;
TPPULinkedFile = class
public
ID: byte; // see iblinkunitofiles, iblink...
Filename: string;
Flags: Longint;
end;
{ TPPU }
TPPU = class
@ -515,6 +522,8 @@ type
FData: Pointer;
FDataPos: integer;
FDataSize: integer;
FInterfaceHeaderPos: integer; // start of the interface header entries
FImplementationHeaderPos: integer; // start of the implementation header entries
FMainUsesSectionPos: integer;// start of the ibloadunit entry
FImplementationUsesSectionPos: integer;// start of the ibloadunit entry
FInitProcPos: integer;// start of the ibprocdef entry
@ -574,6 +583,7 @@ type
procedure DumpHeader(const Prefix: string = '');
procedure GetMainUsesSectionNames(var List: TStrings);
procedure GetImplementationUsesSectionNames(var List: TStrings);
procedure GetLinkedFiles(var ListOfTPPULinkedFile: TObjectList);
function GetInitProcName: string;
function GetFinalProcName: string;
property Version: integer read FVersion;
@ -585,6 +595,8 @@ function PPUCpuToStr(w: longint): string;
function PPUFlagsToStr(flags: longint): string;
function PPUTimeToStr(t: longint): string;
function PPULinkContainerFlagToStr(Flags: longint): string;
function PPUEntryName(Entry: byte): string;
implementation
@ -872,6 +884,27 @@ begin
Result := L0(Year)+'/'+L0(Month)+'/'+L0(Day)+' '+L0(Hour)+':'+L0(min)+':'+L0(sec);
end;
function PPULinkContainerFlagToStr(Flags: longint): string;
const
{ link options }
link_none = $0;
link_always = $1;
link_static = $2;
link_smart = $4;
link_shared = $8;
begin
Result:='';
if (Flags and link_always)<>0 then
Result:=Result+'always,';
if (Flags and link_static)<>0 then
Result:=Result+'static,';
if (Flags and link_smart)<>0 then
Result:=Result+'smart,';
if (Flags and link_shared)<>0 then
Result:=Result+'shared,';
if Result<>'' then Result:=copy(Result,1,length(Result)-1);
end;
function PPUEntryName(Entry: byte): string;
begin
case Entry of
@ -1067,6 +1100,7 @@ var
IsUsed: Boolean;
{$ENDIF}
begin
FInterfaceHeaderPos:=FDataPos;
repeat
EntryNr:=ReadEntry;
{$IFDEF VerbosePPUParser}
@ -1149,6 +1183,7 @@ procedure TPPU.ReadImplementationHeader;
var
EntryNr: Byte;
begin
FImplementationHeaderPos:=FDataPos;
repeat
EntryNr:=ReadEntry;
case EntryNr of
@ -1997,13 +2032,6 @@ end;
procedure TPPU.ReadLinkContainer(Nr: byte);
{$IFDEF VerbosePPUParser}
const
{ link options }
link_none = $0;
link_always = $1;
link_static = $2;
link_smart = $4;
link_shared = $8;
var
Desc: String;
var
@ -2031,15 +2059,7 @@ begin
iblinkotherframeworks:
Desc:='Link framework: ';
end;
Desc:=Desc+Filename;
if (Flags and link_always)<>0 then
Desc:=Desc+' always';
if (Flags and link_static)<>0 then
Desc:=Desc+' static';
if (Flags and link_smart)<>0 then
Desc:=Desc+' smart';
if (Flags and link_shared)<>0 then
Desc:=Desc+' shared';
Desc:=Desc+Filename+' '+PPULinkContainerFlagToStr(Flags);
DebugLn(['TPPU.ReadLinkContainer ',Desc]);
{$ENDIF}
end;
@ -2202,7 +2222,9 @@ begin
FDataSize:=0;
FDataPos:=0;
FInterfaceHeaderPos:=0;
FMainUsesSectionPos:=0;
FImplementationHeaderPos:=0;
FImplementationUsesSectionPos:=0;
FInitProcPos:=0;
FFinalProcPos:=0;
@ -2268,6 +2290,45 @@ begin
GetUsesSection(FImplementationUsesSectionPos,List);
end;
procedure TPPU.GetLinkedFiles(var ListOfTPPULinkedFile: TObjectList);
var
EntryNr: Byte;
Item: TPPULinkedFile;
Filename: String;
Flags: LongInt;
begin
if FInterfaceHeaderPos=0 then exit;
SetDataPos(FInterfaceHeaderPos);
repeat
EntryNr:=ReadEntry;
case EntryNr of
iblinkunitofiles,iblinkunitstaticlibs,iblinkunitsharedlibs,
iblinkotherofiles,iblinkotherstaticlibs,iblinkothersharedlibs,
iblinkotherframeworks:
begin
while not EndOfEntry do begin
Filename:=ReadEntryShortstring;
Flags:=ReadEntryLongint;
//debugln(['TPPU.GetLinkedFiles ',PPUEntryName(EntryNr),' ',Filename]);
if ListOfTPPULinkedFile=nil then
ListOfTPPULinkedFile:=TObjectList.Create(true);
Item:=TPPULinkedFile.Create;
Item.ID:=EntryNr;
Item.Filename:=Filename;
Item.Flags:=Flags;
ListOfTPPULinkedFile.Add(Item);
end;
end;
ibendinterface:
break;
else
FEntryPos:=FEntry.size;
end;
until false;
end;
function TPPU.GetInitProcName: string;
begin
Result:=GetProcMangledName(FInitProcPos);