From f4793e2290fe943abb930d8660f87a5e8d22ee7d Mon Sep 17 00:00:00 2001 From: Basile Burg Date: Sun, 24 Apr 2016 18:35:27 +0200 Subject: [PATCH] symlist, add the 'deep' option, default = on, off = only top level decl --- cesyms/cesyms.d | 14 +++++++------- src/ce_symlist.pas | 7 +++++++ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/cesyms/cesyms.d b/cesyms/cesyms.d index 9ac2fad1..f5764411 100644 --- a/cesyms/cesyms.d +++ b/cesyms/cesyms.d @@ -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; diff --git a/src/ce_symlist.pas b/src/ce_symlist.pas index 6fc06d69..dfc438d6 100644 --- a/src/ce_symlist.pas +++ b/src/ce_symlist.pas @@ -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);