cody: show code node info: show complete source

git-svn-id: trunk@37140 -
This commit is contained in:
mattias 2012-05-02 18:03:58 +00:00
parent 3b43d6d9d5
commit edfb38007b
9 changed files with 126 additions and 17 deletions

View File

@ -7,11 +7,11 @@ object CodyNodeInfoDialog: TCodyNodeInfoDialog
ClientHeight = 467
ClientWidth = 581
OnCreate = FormCreate
LCLVersion = '0.9.31'
LCLVersion = '1.1'
object ButtonPanel1: TButtonPanel
Left = 6
Height = 30
Top = 431
Height = 42
Top = 419
Width = 569
OKButton.Name = 'OKButton'
OKButton.DefaultCaption = True
@ -26,20 +26,20 @@ object CodyNodeInfoDialog: TCodyNodeInfoDialog
end
object PageControl1: TPageControl
Left = 0
Height = 425
Height = 413
Top = 0
Width = 581
ActivePage = ReportTabSheet
ActivePage = CodeBuffersTabSheet
Align = alClient
TabIndex = 0
TabIndex = 1
TabOrder = 1
object ReportTabSheet: TTabSheet
Caption = 'ReportTabSheet'
ClientHeight = 386
ClientHeight = 381
ClientWidth = 575
object ReportMemo: TMemo
Left = 0
Height = 386
Height = 381
Top = 0
Width = 575
Align = alClient
@ -51,5 +51,33 @@ object CodyNodeInfoDialog: TCodyNodeInfoDialog
TabOrder = 0
end
end
object CodeBuffersTabSheet: TTabSheet
Caption = 'CodeBuffersTabSheet'
ClientHeight = 381
ClientWidth = 575
object CodeBuffersComboBox: TComboBox
Left = 0
Height = 27
Top = 0
Width = 575
Align = alTop
ItemHeight = 0
OnSelect = CodeBuffersComboBoxSelect
TabOrder = 0
Text = 'CodeBuffersComboBox'
end
object CodeBufferMemo: TMemo
Left = 0
Height = 354
Top = 27
Width = 575
Align = alClient
Lines.Strings = (
'CodeBufferMemo'
)
ScrollBars = ssBoth
TabOrder = 1
end
end
end
end

View File

@ -30,13 +30,13 @@ unit CodyNodeInfoDlg;
interface
uses
Classes, SysUtils, FileProcs, Forms, Controls, Graphics, Dialogs, ButtonPanel,
ComCtrls, StdCtrls,
Classes, SysUtils, AVL_Tree, FileProcs, Forms, Controls, Graphics, Dialogs,
ButtonPanel, ComCtrls, StdCtrls,
// IDEIntf
SrcEditorIntf,
// CodeTools
CodeToolManager, CodeTree, FindDeclarationCache, PascalParserTool,
LinkScanner, CodeCache, BasicCodeTools, FindDeclarationTool,
LinkScanner, CodeCache, BasicCodeTools, FindDeclarationTool, SourceLog,
CodyUtils, CodyStrConsts;
type
@ -45,15 +45,20 @@ type
TCodyNodeInfoDialog = class(TForm)
ButtonPanel1: TButtonPanel;
CodeBufferMemo: TMemo;
CodeBuffersComboBox: TComboBox;
PageControl1: TPageControl;
ReportMemo: TMemo;
ReportTabSheet: TTabSheet;
CodeBuffersTabSheet: TTabSheet;
procedure CodeBuffersComboBoxSelect(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
procedure ReportBaseTypeCache(Report: TStringList;
Tool: TFindDeclarationTool; Node: TCodeTreeNode);
procedure ReportAllNodes(Report: TStringList;
Tool: TFindDeclarationTool);
procedure ShowCodeBuffer(Filename: string);
public
procedure UpdateReport;
end;
@ -80,11 +85,17 @@ procedure TCodyNodeInfoDialog.FormCreate(Sender: TObject);
begin
Caption:=crsCodeNodeInformation;
ReportTabSheet.Caption:=crsReport;
CodeBuffersTabSheet.Caption:=crsCodeBuffers;
ButtonPanel1.CloseButton.Caption:=crsClose;
PageControl1.PageIndex:=0;
UpdateReport;
end;
procedure TCodyNodeInfoDialog.CodeBuffersComboBoxSelect(Sender: TObject);
begin
ShowCodeBuffer(CodeBuffersComboBox.Text);
end;
procedure TCodyNodeInfoDialog.ReportBaseTypeCache(Report: TStringList;
Tool: TFindDeclarationTool; Node: TCodeTreeNode);
@ -175,6 +186,23 @@ begin
end;
end;
procedure TCodyNodeInfoDialog.ShowCodeBuffer(Filename: string);
var
Code: TCodeBuffer;
i: Integer;
sl: TStringList;
begin
Code:=CodeToolBoss.LoadFile(Filename,false,false);
sl:=TStringList.Create;
if Code<>nil then begin
for i:=0 to Code.LineCount-1 do begin
sl.Add('Line='+dbgs(i+1)+' Start='+dbgs(Code.GetLineStart(i))+' ="'+dbgstr(Code.GetLine(i))+'"');
end;
end;
CodeBufferMemo.Lines.Assign(sl);
sl.Free;
end;
procedure TCodyNodeInfoDialog.UpdateReport;
var
SrcEdit: TSourceEditorInterface;
@ -183,7 +211,12 @@ var
Tool: TCodeTool;
CleanPos: integer;
Node: TCodeTreeNode;
s: String;
SrcCode: TSourceLog;
i: Integer;
UsedCodeBuffers: TAVLTree;
AVLNode: TAVLTreeNode;
Filenames: TStringList;
CodeBuf: TCodeBuffer;
begin
sl:=TStringList.Create;
try
@ -224,14 +257,37 @@ begin
sl.Add('Node.SubDesc=%'+binStr(Node.SubDesc,16));
sl.Add('Node.StartPos='+dbgs(Node.StartPos)+'='+Tool.CleanPosToStr(Node.StartPos));
sl.Add('Node.EndPos='+dbgs(Node.EndPos)+'='+Tool.CleanPosToStr(Node.EndPos));
s:=dbgstr(Tool.Src,Node.StartPos,Node.EndPos-Node.StartPos);
if length(s)>100 then
s:=copy(s,1,48)+'...'+copy(s,length(s)-47,48);
sl.Add('Node Src="'+s+'"');
sl.Add('Node Src>>>>>>>>>>>>>>>>>>');
SrcCode:=TSourceLog.Create(copy(Tool.Src,Node.StartPos,Node.EndPos-Node.StartPos));
for i:=0 to SrcCode.LineCount-1 do begin
sl.Add('Line='+dbgs(i)+',CleanPos='+dbgs(Node.StartPos+SrcCode.GetLineStart(i)-1)+'="'+dbgstr(SrcCode.GetLine(i))+'"');
end;
SrcCode.Free;
sl.Add('Node Src<<<<<<<<<<<<<<<<<<');
ReportBaseTypeCache(sl,Tool,Node);
ReportAllNodes(sl,Tool);
end;
Filenames:=TStringList.Create;
if Tool.Scanner<>nil then begin
UsedCodeBuffers:=Tool.Scanner.CreateTreeOfSourceCodes;
AVLNode:=UsedCodeBuffers.FindLowest;
while AVLNode<>nil do begin
CodeBuf:=TCodeBuffer(AVLNode.Data);
Filenames.Add(CodeBuf.Filename);
AVLNode:=UsedCodeBuffers.FindSuccessor(AVLNode);
end;
UsedCodeBuffers.Free;
end;
CodeBuffersComboBox.Items.Assign(Filenames);
Filenames.Free;
if CodeBuffersComboBox.Items.Count>0 then begin
CodeBuffersComboBox.Text:=CodeBuffersComboBox.Items[0];
ShowCodeBuffer(CodeBuffersComboBox.Text);
end else begin
CodeBuffersComboBox.Text:='';
end;
except
on e: Exception do CodeToolBoss.HandleException(e);
end;

View File

@ -73,6 +73,7 @@ resourcestring
crsProjectOutput = 'Project Output';
crsHelp = '&Help';
crsClose = '&Close';
crsCodeBuffers = 'CodeBuffers';
crsAddAssignMethod = 'Add Assign Method';
crsShowCodeToolsNodeInfo = 'Show CodeTools Node Info ...';
crsShowUnitIdentifierDictionary = 'Show Unit / Identifier Dictionary ...';

View File

@ -153,6 +153,10 @@ msgstr ""
msgid "Close other package and open new"
msgstr "Anderes Package schließen und neues öffnen"
#: codystrconsts.crscodebuffers
msgid "CodeBuffers"
msgstr ""
#: codystrconsts.crscodenodeinformation
msgid "Code Node Information"
msgstr ""

View File

@ -153,6 +153,10 @@ msgstr "&Chiudi"
msgid "Close other package and open new"
msgstr ""
#: codystrconsts.crscodebuffers
msgid "CodeBuffers"
msgstr ""
#: codystrconsts.crscodenodeinformation
msgid "Code Node Information"
msgstr ""

View File

@ -145,6 +145,10 @@ msgstr ""
msgid "Close other package and open new"
msgstr ""
#: codystrconsts.crscodebuffers
msgid "CodeBuffers"
msgstr ""
#: codystrconsts.crscodenodeinformation
msgid "Code Node Information"
msgstr ""

View File

@ -156,6 +156,10 @@ msgstr "&Fechar"
msgid "Close other package and open new"
msgstr "Fechar outro pacote e abrir um novo"
#: codystrconsts.crscodebuffers
msgid "CodeBuffers"
msgstr ""
#: codystrconsts.crscodenodeinformation
msgid "Code Node Information"
msgstr "Informação Nó de Código"

View File

@ -156,6 +156,10 @@ msgstr "&Закрыть"
msgid "Close other package and open new"
msgstr "Закрыть другой пакет и открыть новый"
#: codystrconsts.crscodebuffers
msgid "CodeBuffers"
msgstr ""
#: codystrconsts.crscodenodeinformation
msgid "Code Node Information"
msgstr "Сведения об элементе кода"

View File

@ -157,6 +157,10 @@ msgstr "&Закрити"
msgid "Close other package and open new"
msgstr ""
#: codystrconsts.crscodebuffers
msgid "CodeBuffers"
msgstr ""
#: codystrconsts.crscodenodeinformation
msgid "Code Node Information"
msgstr "Інформація про Вузол Коду"