IDE: unit info: added parsed size and total of all include files

git-svn-id: trunk@27538 -
This commit is contained in:
mattias 2010-10-01 13:29:52 +00:00
parent 2c1845b2bd
commit f44d97b839
5 changed files with 134 additions and 66 deletions

View File

@ -91,15 +91,14 @@
- history - history
ToDo: ToDo:
- resourcestrings
- make synedit a package
- make IDEIntf a package
- make LCL a package
- make FCL a package
- make lazbuild lcl independent, independent of packages except one - make lazbuild lcl independent, independent of packages except one
- license gpl2 - license gpl2
- create package lazbuildsystem with some units - create package lazbuildsystem with some units
- move - move
- make synedit a package
- make IDEIntf a package
- make LCL a package
- make FCL a package
- code completion - code completion
- keypress event - keypress event
- help for add/delete macro speedbuttons - help for add/delete macro speedbuttons

View File

@ -4887,6 +4887,9 @@ resourcestring
lisHintADefaultValueCanBeDefinedInTheConditionals = 'Hint: A default value ' lisHintADefaultValueCanBeDefinedInTheConditionals = 'Hint: A default value '
+'can be defined in the conditionals.'; +'can be defined in the conditionals.';
lisConditionals = 'Conditionals:'; lisConditionals = 'Conditionals:';
lisWithIncludes = '%s, with includes %s';
lisWithIncludes2 = ', with includes ';
lisParsed = ', parsed ';
implementation implementation

View File

@ -8934,16 +8934,65 @@ var ActiveSrcEdit:TSourceEditor;
ShortUnitName, AFilename, FileDir: string; ShortUnitName, AFilename, FileDir: string;
ClearIncludedByFile: boolean; ClearIncludedByFile: boolean;
DlgResult: TModalResult; DlgResult: TModalResult;
SizeInBytes: Integer;
UnitSizeWithIncludeFiles: integer;
UnitSizeParsed: integer;
LineCount: LongInt;
UnitLineCountWithIncludes: LongInt;
UnitLineCountParsed: LongInt;
Code: TCodeBuffer;
CTTool: TCodeTool;
TreeOfSourceCodes: TAVLTree;
Node: TAVLTreeNode;
SubCode: TCodeBuffer;
begin begin
GetCurrentUnit(ActiveSrcEdit,ActiveUnitInfo); GetCurrentUnit(ActiveSrcEdit,ActiveUnitInfo);
if (ActiveSrcEdit=nil) or (ActiveUnitInfo=nil) then exit; if (ActiveSrcEdit=nil) or (ActiveUnitInfo=nil) then exit;
ShortUnitName:=ActiveSrcEdit.PageName; ShortUnitName:=ActiveSrcEdit.PageName;
AFilename:=ActiveUnitInfo.Filename; AFilename:=ActiveUnitInfo.Filename;
FileDir:=ExtractFilePath(AFilename); FileDir:=ExtractFilePath(AFilename);
SizeInBytes:=length(ActiveSrcEdit.Source.Text);
UnitSizeWithIncludeFiles:=SizeInBytes;
UnitSizeParsed:=SizeInBytes;
LineCount:=ActiveSrcEdit.Source.Count;
UnitLineCountWithIncludes:=LineCount;
UnitLineCountParsed:=LineCount;
// check size of parsed source (without skipped code due to $ELSE)
// and total size of all include files
Code:=ActiveSrcEdit.CodeBuffer;
if Code<>nil then
begin
CodeToolBoss.Explore(ActiveSrcEdit.CodeBuffer,CTTool,false,false);
if CTTool<>nil then
begin
UnitSizeParsed:=CTTool.SrcLen;
UnitLineCountParsed:=LineEndCount(CTTool.Src);
if CTTool.Scanner<>nil then
begin
TreeOfSourceCodes:=CTTool.Scanner.CreateTreeOfSourceCodes;
if TreeOfSourceCodes<>nil then
begin
UnitSizeWithIncludeFiles:=0;
UnitLineCountWithIncludes:=0;
Node:=TreeOfSourceCodes.FindLowest;
while Node<>nil do begin
SubCode:=TCodeBuffer(Node.Data);
inc(UnitSizeWithIncludeFiles,SubCode.SourceLength);
inc(UnitLineCountWithIncludes,SubCode.LineCount);
Node:=TreeOfSourceCodes.FindSuccessor(Node);
end;
end;
end;
end;
end;
DlgResult:=ShowUnitInfoDlg(ShortUnitName, DlgResult:=ShowUnitInfoDlg(ShortUnitName,
LazSyntaxHighlighterNames[ActiveUnitInfo.DefaultSyntaxHighlighter], LazSyntaxHighlighterNames[ActiveUnitInfo.DefaultSyntaxHighlighter],
ActiveUnitInfo.IsPartOfProject, length(ActiveSrcEdit.Source.Text), ActiveUnitInfo.IsPartOfProject,
ActiveSrcEdit.Source.Count, SizeInBytes,UnitSizeWithIncludeFiles,UnitSizeParsed,
LineCount,UnitLineCountWithIncludes,UnitLineCountParsed,
AFilename, AFilename,
ActiveUnitInfo.Source.LastIncludedByFile, ActiveUnitInfo.Source.LastIncludedByFile,
ClearIncludedByFile, ClearIncludedByFile,

View File

@ -3,20 +3,20 @@ object UnitInfoDialog: TUnitInfoDialog
Height = 283 Height = 283
Top = 251 Top = 251
Width = 500 Width = 500
ActiveControl = OkButton ActiveControl = Notebook
BorderStyle = bsSizeToolWin BorderStyle = bsSizeToolWin
Caption = 'UnitInfoDialog' Caption = 'UnitInfoDialog'
ClientHeight = 283 ClientHeight = 283
ClientWidth = 500 ClientWidth = 500
OnCreate = FormCreate OnCreate = FormCreate
Position = poScreenCenter Position = poScreenCenter
LCLVersion = '0.9.27' LCLVersion = '0.9.29'
object OkButton: TBitBtn object OkButton: TBitBtn
AnchorSideBottom.Control = Owner AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom AnchorSideBottom.Side = asrBottom
Left = 419 Left = 419
Height = 26 Height = 32
Top = 251 Top = 245
Width = 75 Width = 75
Anchors = [akRight, akBottom] Anchors = [akRight, akBottom]
AutoSize = True AutoSize = True
@ -33,22 +33,24 @@ object UnitInfoDialog: TUnitInfoDialog
object Notebook: TPageControl object Notebook: TPageControl
AnchorSideBottom.Control = OkButton AnchorSideBottom.Control = OkButton
Left = 6 Left = 6
Height = 239 Height = 233
Top = 6 Top = 6
Width = 488 Width = 488
ActivePage = GeneralPage
Align = alTop Align = alTop
Anchors = [akTop, akLeft, akRight, akBottom] Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Around = 6 BorderSpacing.Around = 6
TabIndex = 0
TabOrder = 1 TabOrder = 1
object GeneralPage: TTabSheet object GeneralPage: TTabSheet
Caption = 'GeneralPage' Caption = 'GeneralPage'
ClientWidth = 480
ClientHeight = 206 ClientHeight = 206
ClientWidth = 486
object ULines: TLabel object ULines: TLabel
Left = 12 Left = 12
Height = 13 Height = 18
Top = 92 Top = 92
Width = 39 Width = 52
Alignment = taRightJustify Alignment = taRightJustify
Caption = 'ULines' Caption = 'ULines'
Font.Style = [fsBold] Font.Style = [fsBold]
@ -58,10 +60,10 @@ object UnitInfoDialog: TUnitInfoDialog
object OutLines: TLabel object OutLines: TLabel
AnchorSideLeft.Control = ULines AnchorSideLeft.Control = ULines
AnchorSideLeft.Side = asrBottom AnchorSideLeft.Side = asrBottom
Left = 63 Left = 76
Height = 13 Height = 18
Top = 92 Top = 92
Width = 51 Width = 58
BorderSpacing.Left = 12 BorderSpacing.Left = 12
Caption = 'OutLines' Caption = 'OutLines'
ParentColor = False ParentColor = False
@ -69,19 +71,19 @@ object UnitInfoDialog: TUnitInfoDialog
object OutPath: TLabel object OutPath: TLabel
AnchorSideLeft.Control = UPath AnchorSideLeft.Control = UPath
AnchorSideLeft.Side = asrBottom AnchorSideLeft.Side = asrBottom
Left = 58 Left = 70
Height = 13 Height = 18
Top = 112 Top = 112
Width = 46 Width = 52
BorderSpacing.Left = 12 BorderSpacing.Left = 12
Caption = 'OutPath' Caption = 'OutPath'
ParentColor = False ParentColor = False
end end
object UPath: TLabel object UPath: TLabel
Left = 12 Left = 12
Height = 13 Height = 18
Top = 112 Top = 112
Width = 34 Width = 46
Alignment = taRightJustify Alignment = taRightJustify
Caption = 'UPath' Caption = 'UPath'
Font.Style = [fsBold] Font.Style = [fsBold]
@ -90,9 +92,9 @@ object UnitInfoDialog: TUnitInfoDialog
end end
object UIncludedBy: TLabel object UIncludedBy: TLabel
Left = 12 Left = 12
Height = 13 Height = 18
Top = 132 Top = 132
Width = 72 Width = 96
Alignment = taRightJustify Alignment = taRightJustify
Caption = 'UIncludedBy' Caption = 'UIncludedBy'
Font.Style = [fsBold] Font.Style = [fsBold]
@ -102,10 +104,10 @@ object UnitInfoDialog: TUnitInfoDialog
object OutIncludedBy: TLabel object OutIncludedBy: TLabel
AnchorSideLeft.Control = UIncludedBy AnchorSideLeft.Control = UIncludedBy
AnchorSideLeft.Side = asrBottom AnchorSideLeft.Side = asrBottom
Left = 96 Left = 120
Height = 13 Height = 18
Top = 132 Top = 132
Width = 84 Width = 96
BorderSpacing.Left = 12 BorderSpacing.Left = 12
Caption = 'OutIncludedBy' Caption = 'OutIncludedBy'
ParentColor = False ParentColor = False
@ -113,19 +115,19 @@ object UnitInfoDialog: TUnitInfoDialog
object OutSize: TLabel object OutSize: TLabel
AnchorSideLeft.Control = USize AnchorSideLeft.Control = USize
AnchorSideLeft.Side = asrBottom AnchorSideLeft.Side = asrBottom
Left = 57 Left = 68
Height = 13 Height = 18
Top = 72 Top = 72
Width = 45 Width = 51
BorderSpacing.Left = 12 BorderSpacing.Left = 12
Caption = 'OutSize' Caption = 'OutSize'
ParentColor = False ParentColor = False
end end
object USize: TLabel object USize: TLabel
Left = 12 Left = 12
Height = 13 Height = 18
Top = 72 Top = 72
Width = 33 Width = 44
Alignment = taRightJustify Alignment = taRightJustify
Caption = 'USize' Caption = 'USize'
Font.Style = [fsBold] Font.Style = [fsBold]
@ -134,9 +136,9 @@ object UnitInfoDialog: TUnitInfoDialog
end end
object UInProject: TLabel object UInProject: TLabel
Left = 12 Left = 12
Height = 13 Height = 18
Top = 52 Top = 52
Width = 58 Width = 80
Alignment = taRightJustify Alignment = taRightJustify
Caption = 'UInProject' Caption = 'UInProject'
Font.Style = [fsBold] Font.Style = [fsBold]
@ -146,10 +148,10 @@ object UnitInfoDialog: TUnitInfoDialog
object OutInProject: TLabel object OutInProject: TLabel
AnchorSideLeft.Control = UInProject AnchorSideLeft.Control = UInProject
AnchorSideLeft.Side = asrBottom AnchorSideLeft.Side = asrBottom
Left = 82 Left = 104
Height = 13 Height = 18
Top = 52 Top = 52
Width = 70 Width = 81
BorderSpacing.Left = 12 BorderSpacing.Left = 12
Caption = 'OutInProject' Caption = 'OutInProject'
ParentColor = False ParentColor = False
@ -157,19 +159,19 @@ object UnitInfoDialog: TUnitInfoDialog
object OutType: TLabel object OutType: TLabel
AnchorSideLeft.Control = UType AnchorSideLeft.Control = UType
AnchorSideLeft.Side = asrBottom AnchorSideLeft.Side = asrBottom
Left = 61 Left = 71
Height = 13 Height = 18
Top = 32 Top = 32
Width = 49 Width = 54
BorderSpacing.Left = 12 BorderSpacing.Left = 12
Caption = 'OutType' Caption = 'OutType'
ParentColor = False ParentColor = False
end end
object UType: TLabel object UType: TLabel
Left = 12 Left = 12
Height = 13 Height = 18
Top = 32 Top = 32
Width = 37 Width = 47
Alignment = taRightJustify Alignment = taRightJustify
Caption = 'UType' Caption = 'UType'
Font.Style = [fsBold] Font.Style = [fsBold]
@ -179,19 +181,19 @@ object UnitInfoDialog: TUnitInfoDialog
object OutName: TLabel object OutName: TLabel
AnchorSideLeft.Control = UName AnchorSideLeft.Control = UName
AnchorSideLeft.Side = asrBottom AnchorSideLeft.Side = asrBottom
Left = 65 Left = 79
Height = 13 Height = 18
Top = 12 Top = 12
Width = 53 Width = 63
BorderSpacing.Left = 12 BorderSpacing.Left = 12
Caption = 'OutName' Caption = 'OutName'
ParentColor = False ParentColor = False
end end
object UName: TLabel object UName: TLabel
Left = 12 Left = 12
Height = 13 Height = 18
Top = 12 Top = 12
Width = 41 Width = 55
Alignment = taRightJustify Alignment = taRightJustify
Caption = 'UName' Caption = 'UName'
Font.Style = [fsBold] Font.Style = [fsBold]
@ -201,9 +203,9 @@ object UnitInfoDialog: TUnitInfoDialog
object ClearIncludedBy: TButton object ClearIncludedBy: TButton
AnchorSideTop.Control = UIncludedBy AnchorSideTop.Control = UIncludedBy
Left = 12 Left = 12
Height = 26 Height = 29
Top = 152 Top = 152
Width = 107 Width = 118
AutoSize = True AutoSize = True
BorderSpacing.Top = 20 BorderSpacing.Top = 20
Caption = 'ClearIncludedBy' Caption = 'ClearIncludedBy'
@ -213,8 +215,8 @@ object UnitInfoDialog: TUnitInfoDialog
end end
object UnitPathsPage: TTabSheet object UnitPathsPage: TTabSheet
Caption = 'UnitPathsPage' Caption = 'UnitPathsPage'
ClientWidth = 480
ClientHeight = 206 ClientHeight = 206
ClientWidth = 486
object UnitPathMemo: TMemo object UnitPathMemo: TMemo
Left = 6 Left = 6
Height = 194 Height = 194
@ -229,8 +231,8 @@ object UnitInfoDialog: TUnitInfoDialog
end end
object IncludePathsPage: TTabSheet object IncludePathsPage: TTabSheet
Caption = 'IncludePathsPage' Caption = 'IncludePathsPage'
ClientWidth = 480 ClientHeight = 206
ClientHeight = 213 ClientWidth = 486
object IncludePathMemo: TMemo object IncludePathMemo: TMemo
Left = 6 Left = 6
Height = 201 Height = 201
@ -245,13 +247,13 @@ object UnitInfoDialog: TUnitInfoDialog
end end
object CompleteUnitPathsPage: TTabSheet object CompleteUnitPathsPage: TTabSheet
Caption = 'CompleteUnitPathsPage' Caption = 'CompleteUnitPathsPage'
ClientWidth = 480
ClientHeight = 206 ClientHeight = 206
ClientWidth = 486
object SrcPathMemo: TMemo object SrcPathMemo: TMemo
Left = 6 Left = 6
Height = 194 Height = 194
Top = 6 Top = 6
Width = 468 Width = 474
Align = alClient Align = alClient
BorderSpacing.Around = 6 BorderSpacing.Around = 6
ReadOnly = True ReadOnly = True
@ -265,9 +267,9 @@ object UnitInfoDialog: TUnitInfoDialog
AnchorSideBottom.Control = OkButton AnchorSideBottom.Control = OkButton
AnchorSideBottom.Side = asrBottom AnchorSideBottom.Side = asrBottom
Left = 6 Left = 6
Height = 26 Height = 32
Top = 251 Top = 245
Width = 130 Width = 151
Anchors = [akTop, akLeft, akBottom] Anchors = [akTop, akLeft, akBottom]
AutoSize = True AutoSize = True
Caption = 'CodeToolsDefsButton' Caption = 'CodeToolsDefsButton'
@ -279,10 +281,10 @@ object UnitInfoDialog: TUnitInfoDialog
AnchorSideRight.Control = OkButton AnchorSideRight.Control = OkButton
AnchorSideBottom.Control = OkButton AnchorSideBottom.Control = OkButton
AnchorSideBottom.Side = asrBottom AnchorSideBottom.Side = asrBottom
Left = 256 Left = 221
Height = 26 Height = 32
Top = 251 Top = 245
Width = 157 Width = 192
Anchors = [akTop, akRight, akBottom] Anchors = [akTop, akRight, akBottom]
AutoSize = True AutoSize = True
BorderSpacing.Right = 6 BorderSpacing.Right = 6

View File

@ -73,7 +73,8 @@ type
end; end;
function ShowUnitInfoDlg(const AnUnitName, AType: string; function ShowUnitInfoDlg(const AnUnitName, AType: string;
IsPartOfProject: boolean; SizeInBytes, LineCount: integer; IsPartOfProject: boolean; SizeInBytes, UnitSizeWithIncludeFiles, UnitSizeParsed,
LineCount, UnitLineCountWithIncludes, UnitLineCountParsed: integer;
const FilePath: string; const IncludedBy: string; var ClearIncludedBy: boolean; const FilePath: string; const IncludedBy: string; var ClearIncludedBy: boolean;
const UnitPath, IncludePath, SrcPath: string): TModalResult; const UnitPath, IncludePath, SrcPath: string): TModalResult;
@ -82,10 +83,13 @@ implementation
{$R *.lfm} {$R *.lfm}
function ShowUnitInfoDlg(const AnUnitName, AType: string; function ShowUnitInfoDlg(const AnUnitName, AType: string;
IsPartOfProject: boolean; SizeInBytes, LineCount: integer; IsPartOfProject: boolean;
SizeInBytes, UnitSizeWithIncludeFiles, UnitSizeParsed,
LineCount, UnitLineCountWithIncludes, UnitLineCountParsed: integer;
const FilePath: string; const IncludedBy: string; var ClearIncludedBy: boolean; const FilePath: string; const IncludedBy: string; var ClearIncludedBy: boolean;
const UnitPath, IncludePath, SrcPath: string): TModalResult; const UnitPath, IncludePath, SrcPath: string): TModalResult;
var Dlg: TUnitInfoDialog; var Dlg: TUnitInfoDialog;
s: String;
begin begin
Dlg:=TUnitInfoDialog.Create(nil); Dlg:=TUnitInfoDialog.Create(nil);
with Dlg do begin with Dlg do begin
@ -101,9 +105,20 @@ begin
else else
OutInProject.Caption:=lisUIDno; OutInProject.Caption:=lisUIDno;
OutSize.Caption:=Format(lisUIDbytes, [IntToStr(SizeInBytes)]); s:=Format(lisUIDbytes, [IntToStr(SizeInBytes)]);
if UnitSizeWithIncludeFiles<>SizeInBytes then
s:=s+lisWithIncludes2+IntToStr(UnitSizeWithIncludeFiles);
if UnitSizeParsed<>UnitSizeWithIncludeFiles then
s:=s+lisParsed+IntToStr(UnitSizeParsed);
OutSize.Caption:=s;
s:=IntToStr(LineCount);
if UnitLineCountWithIncludes<>LineCount then
s:=s+lisWithIncludes2+IntToStr(UnitLineCountWithIncludes);
if UnitLineCountParsed<>LineCount then
s:=s+lisParsed+IntToStr(UnitLineCountParsed);
OutLines.Caption:=s;
OutLines.Caption:=IntToStr(LineCount);
OutPath.Caption:=FilePath; OutPath.Caption:=FilePath;
OutIncludedBy.Caption:=IncludedBy; OutIncludedBy.Caption:=IncludedBy;