symlist, support for unittests

This commit is contained in:
Basile Burg 2016-04-24 02:17:15 +02:00
parent 4800a23fab
commit 0d658711bc
3 changed files with 30 additions and 12 deletions

View File

@ -23,7 +23,7 @@ Usage
module cesyms; module cesyms;
import std.stdio, std.path, std.file, std.array, std.string; import std.stdio, std.path, std.file, std.array, std.string;
import std.getopt, std.json, std.conv; import std.getopt, std.json, std.conv, std.format;
import dparse.lexer, dparse.ast, dparse.parser, dparse.rollback_allocator; import dparse.lexer, dparse.ast, dparse.parser, dparse.rollback_allocator;
import std.traits; import std.traits;
@ -161,6 +161,7 @@ enum SymbolType
_struct, _struct,
_template, _template,
_union, _union,
_unittest,
_variable, _variable,
_warning _warning
} }
@ -179,6 +180,8 @@ class SymbolListBuilder(ListFmt Fmt): ASTVisitor
static JSONValue* jarray; static JSONValue* jarray;
} }
static uint utc;
alias visit = ASTVisitor.visit; alias visit = ASTVisitor.visit;
static this() static this()
@ -412,6 +415,12 @@ class SymbolListBuilder(ListFmt Fmt): ASTVisitor
namedVisitorImpl!(UnionDeclaration, SymbolType._union)(decl); namedVisitorImpl!(UnionDeclaration, SymbolType._union)(decl);
} }
final override void visit(const Unittest decl)
{
otherVisitorImpl(decl, SymbolType._unittest, format("test%.4d",utc++),
decl.line, decl.column);
}
final override void visit(const VariableDeclaration decl) final override void visit(const VariableDeclaration decl)
{ {
if (decl.declarators) if (decl.declarators)

View File

@ -36,7 +36,7 @@ inherited CESymbolListWidget: TCESymbolListWidget
OnKeyPress = TreeKeyPress OnKeyPress = TreeKeyPress
Options = [tvoAutoItemHeight, tvoKeepCollapsedNodes, tvoReadOnly, tvoRightClickSelect, tvoShowButtons, tvoShowLines, tvoShowRoot, tvoToolTips, tvoThemedDraw] Options = [tvoAutoItemHeight, tvoKeepCollapsedNodes, tvoReadOnly, tvoRightClickSelect, tvoShowButtons, tvoShowLines, tvoShowRoot, tvoToolTips, tvoThemedDraw]
Items.Data = { Items.Data = {
F9FFFFFF02000D000000000000000000000000000000FFFFFFFF000000000000 F9FFFFFF02000E000000000000000000000000000000FFFFFFFF000000000000
00000005000000416C696173010000000100000001000000FFFFFFFF00000000 00000005000000416C696173010000000100000001000000FFFFFFFF00000000
000000000005000000436C617373020000000200000002000000FFFFFFFF0000 000000000005000000436C617373020000000200000002000000FFFFFFFF0000
0000000000000004000000456E756D030000000300000003000000FFFFFFFF00 0000000000000004000000456E756D030000000300000003000000FFFFFFFF00
@ -48,9 +48,10 @@ inherited CESymbolListWidget: TCESymbolListWidget
6374080000000800000008000000FFFFFFFF0000000000000000000800000054 6374080000000800000008000000FFFFFFFF0000000000000000000800000054
656D706C617465000000000000000000000000FFFFFFFF000000000000000000 656D706C617465000000000000000000000000FFFFFFFF000000000000000000
05000000556E696F6E010000000100000001000000FFFFFFFF00000000000000 05000000556E696F6E010000000100000001000000FFFFFFFF00000000000000
0000080000005661726961626C65090000000900000009000000FFFFFFFF0000 000008000000556E697474657374020000000200000002000000FFFFFFFF0000
00000000000000080000005761726E696E67730A0000000A0000000A000000FF 00000000000000080000005661726961626C65090000000900000009000000FF
FFFFFF000000000000000000060000004572726F7273 FFFFFF000000000000000000080000005761726E696E67730A0000000A000000
0A000000FFFFFFFF000000000000000000060000004572726F7273
} }
TreeLineColor = clDefault TreeLineColor = clDefault
end end

View File

@ -24,6 +24,7 @@ type
_struct, _struct,
_template, _template,
_union, _union,
_unittest,
_variable, _variable,
_warning _warning
); );
@ -137,7 +138,7 @@ type
fSmartExpander: boolean; fSmartExpander: boolean;
ndAlias, ndClass, ndEnum, ndFunc, ndUni: TTreeNode; ndAlias, ndClass, ndEnum, ndFunc, ndUni: TTreeNode;
ndImp, ndIntf, ndMix, ndStruct, ndTmp: TTreeNode; ndImp, ndIntf, ndMix, ndStruct, ndTmp: TTreeNode;
ndVar, ndWarn, ndErr: TTreeNode; ndVar, ndWarn, ndErr, ndUt: TTreeNode;
procedure TreeDblClick(Sender: TObject); procedure TreeDblClick(Sender: TObject);
procedure actRefreshExecute(Sender: TObject); procedure actRefreshExecute(Sender: TObject);
procedure actAutoRefreshExecute(Sender: TObject); procedure actAutoRefreshExecute(Sender: TObject);
@ -368,9 +369,10 @@ begin
ndStruct := Tree.Items[7]; ndStruct := Tree.Items[7];
ndTmp := Tree.Items[8]; ndTmp := Tree.Items[8];
ndUni := Tree.Items[9]; ndUni := Tree.Items[9];
ndVar := Tree.Items[10]; ndUt := Tree.Items[10];
ndWarn := Tree.Items[11]; ndVar := Tree.Items[11];
ndErr := Tree.Items[12]; ndWarn := Tree.Items[12];
ndErr := Tree.Items[13];
// //
png := TPortableNetworkGraphic.Create; png := TPortableNetworkGraphic.Create;
try try
@ -565,6 +567,7 @@ begin
ndStruct.Visible:= ndStruct.Count > 0; ndStruct.Visible:= ndStruct.Count > 0;
ndTmp.Visible := ndTmp.Count > 0; ndTmp.Visible := ndTmp.Count > 0;
ndUni.Visible := ndUni.Count > 0; ndUni.Visible := ndUni.Count > 0;
ndUt.Visible := ndUt.Count > 0;
ndVar.Visible := ndVar.Count > 0; ndVar.Visible := ndVar.Count > 0;
ndWarn.Visible := ndWarn.Count > 0; ndWarn.Visible := ndWarn.Count > 0;
ndErr.Visible := ndErr.Count > 0; ndErr.Visible := ndErr.Count > 0;
@ -580,6 +583,7 @@ begin
ndStruct.Visible:= true; ndStruct.Visible:= true;
ndTmp.Visible := true; ndTmp.Visible := true;
ndUni.Visible := true; ndUni.Visible := true;
ndUt.Visible := true;
ndVar.Visible := true; ndVar.Visible := true;
ndWarn.Visible := true; ndWarn.Visible := true;
ndErr.Visible := true; ndErr.Visible := true;
@ -598,6 +602,7 @@ begin
ndStruct.DeleteChildren; ndStruct.DeleteChildren;
ndTmp.DeleteChildren; ndTmp.DeleteChildren;
ndUni.DeleteChildren; ndUni.DeleteChildren;
ndUt.DeleteChildren;
ndVar.DeleteChildren; ndVar.DeleteChildren;
ndWarn.DeleteChildren; ndWarn.DeleteChildren;
ndErr.DeleteChildren; ndErr.DeleteChildren;
@ -697,9 +702,10 @@ function getCatNode(node: TTreeNode; stype: TSymbolType ): TTreeNode;
_struct : begin result.ImageIndex:=7; result.SelectedIndex:=7; end; _struct : begin result.ImageIndex:=7; result.SelectedIndex:=7; end;
_template : begin result.ImageIndex:=8; result.SelectedIndex:=8; end; _template : begin result.ImageIndex:=8; result.SelectedIndex:=8; end;
_union : begin result.ImageIndex:=0; result.SelectedIndex:=0; end; _union : begin result.ImageIndex:=0; result.SelectedIndex:=0; end;
_variable : begin result.ImageIndex:=1; result.SelectedIndex:=1; end; _unittest : begin result.ImageIndex:=1; result.SelectedIndex:=1; end;
_warning : begin result.ImageIndex:=2; result.SelectedIndex:=2; end; _variable : begin result.ImageIndex:=2; result.SelectedIndex:=2; end;
_error : begin result.ImageIndex:=3; result.SelectedIndex:=3; end; _warning : begin result.ImageIndex:=9; result.SelectedIndex:=9; end;
_error : begin result.ImageIndex:=10; result.SelectedIndex:=10; end;
end; end;
end; end;
// //
@ -716,6 +722,7 @@ begin
_struct : exit(ndStruct); _struct : exit(ndStruct);
_template : exit(ndTmp); _template : exit(ndTmp);
_union : exit(ndUni); _union : exit(ndUni);
_unittest : exit(ndUt);
_variable : exit(ndVar); _variable : exit(ndVar);
_warning : exit(ndWarn); _warning : exit(ndWarn);
_error : exit(ndErr); _error : exit(ndErr);
@ -730,6 +737,7 @@ begin
_struct: exit(newCat('Struct')); _struct: exit(newCat('Struct'));
_template: exit(newCat('Template')); _template: exit(newCat('Template'));
_union: exit(newCat('Union')); _union: exit(newCat('Union'));
_unittest: exit(newCat('Unittest'));
_variable: exit(newCat('Variable')); _variable: exit(newCat('Variable'));
_warning: exit(ndWarn); _warning: exit(ndWarn);
_error: exit(ndErr); _error: exit(ndErr);