symlist, add the 'deep' option, default = on, off = only top level decl

This commit is contained in:
Basile Burg 2016-04-24 18:35:27 +02:00
parent aa368843b5
commit f4793e2290
2 changed files with 14 additions and 7 deletions

View File

@ -34,11 +34,13 @@ enum ListFmt
Json
}
__gshared bool deep;
void main(string[] args)
{
// format
bool asJson;
getopt(args, std.getopt.config.passThrough, "j", &asJson);
getopt(args, config.passThrough, "j", &asJson, "d", &deep);
// get either the module from stdin or from first arg
string fname;
@ -73,8 +75,7 @@ void main(string[] args)
SymbolListBuilder!(ListFmt.Pas) slb = construct!(SymbolListBuilder!(ListFmt.Pas));
auto ast = parseModule(getTokensForParser(source, config, &scache), fname,
&alloc, &slb.astError);
foreach (Declaration decl; ast.declarations)
slb.visit(decl);
slb.visit(ast);
write(slb.serialize);
slb.destruct;
}
@ -83,8 +84,7 @@ void main(string[] args)
SymbolListBuilder!(ListFmt.Json) slb = construct!(SymbolListBuilder!(ListFmt.Json));
auto ast = parseModule(getTokensForParser(source, config, &scache), fname,
&alloc, &slb.astError);
foreach (Declaration decl; ast.declarations)
slb.visit(decl);
slb.visit(ast);
write(slb.serialize);
slb.destruct;
}
@ -249,7 +249,7 @@ class SymbolListBuilder(ListFmt Fmt): ASTVisitor
pasStream.put(format("col = %d\r", dt.name.column));
pasStream.put(format("name = '%s'\r", dt.name.text));
pasStream.put(format("symType = %s\r", st));
static if (dig)
static if (dig) if (deep)
{
pasStream.put("subs = <");
dt.accept(this);
@ -264,7 +264,7 @@ class SymbolListBuilder(ListFmt Fmt): ASTVisitor
item["col"] = JSONValue(dt.name.column);
item["name"] = JSONValue(dt.name.text);
item["type"] = JSONValue(to!string(st));
static if (dig)
static if (dig) if (deep)
{
JSONValue subs = parseJSON("[]");
JSONValue* old = jarray;

View File

@ -84,6 +84,7 @@ type
fAutoExpandErrors: boolean;
fSmartExpander: boolean;
fSortSymbols: boolean;
fDeep: boolean;
published
property autoRefresh: boolean read fAutoRefresh write fAutoRefresh;
property refreshOnChange: boolean read fRefreshOnChange write fRefreshOnChange;
@ -94,6 +95,7 @@ type
property autoExpandErrors: boolean read fAutoExpandErrors write fAutoExpandErrors;
property sortSymbols: boolean read fSortSymbols write fSortSymbols;
property smartExpander: boolean read fSmartExpander write fSmartExpander;
property deep: boolean read fDeep write fDeep default true;
public
constructor Create(AOwner: TComponent); override;
procedure Assign(Source: TPersistent); override;
@ -131,6 +133,7 @@ type
fAutoRefresh: boolean;
fRefreshOnChange: boolean;
fRefreshOnFocus: boolean;
fDeep: boolean;
fShowChildCategories: boolean;
fSmartFilter: boolean;
fAutoExpandErrors: boolean;
@ -256,6 +259,7 @@ end;
constructor TCESymbolListOptions.Create(AOwner: TComponent);
begin
inherited;
fDeep := true;
fRefreshOnFocus := true;
fShowChildCategories := true;
fAutoExpandErrors := true;
@ -273,6 +277,7 @@ begin
begin
widg := TCESymbolListWidget(Source);
//
fDeep := widg.fDeep;
fAutoRefreshDelay := widg.updaterByDelayDuration;
fRefreshOnFocus := widg.fRefreshOnFocus;
fRefreshOnChange := widg.fRefreshOnChange;
@ -303,6 +308,7 @@ begin
widg.fAutoExpandErrors := fAutoExpandErrors;
widg.fSortSymbols := fSortSymbols;
widg.fSmartExpander := fSmartExpander;
widg.fDeep := fDeep;
//
widg.fActAutoRefresh.Checked := fAutoRefresh;
widg.fActRefreshOnChange.Checked:= fRefreshOnChange;
@ -676,6 +682,7 @@ begin
fToolProc.Executable := fToolExeName;
fToolProc.OnTerminate := @toolTerminated;
fToolProc.CurrentDirectory := Application.ExeName.extractFileDir;
if fDeep then fToolProc.Parameters.Add('-d');
fToolProc.Execute;
str := fDoc.Text;
fToolProc.Input.Write(str[1], str.length);