commit 7b8aba83ffd2763604ea5abbbae1c4fc352de889
parent 945b113b17a8c5b7a6f7363684cac56560a2b9d1
Author: Lou Woell <lou.woell@posteo.de>
Date: Mon, 22 Sep 2025 19:56:43 +0200
[list] add option to list unexported symbols
Diffstat:
2 files changed, 19 insertions(+), 4 deletions(-)
diff --git a/cmd/harehelper/helper.ha b/cmd/harehelper/helper.ha
@@ -29,7 +29,8 @@ const help: []getopt::help = [
"args",
("list", [
"list symbols in module",
- "module"
+ ('u', "list unexported symbols"),
+ "module",
]: []getopt::help ),
("resolve", [
"resolve namespace for identifier",
diff --git a/cmd/harehelper/list_symbols.ha b/cmd/harehelper/list_symbols.ha
@@ -21,6 +21,8 @@ use hare::parse;
fn list (cmd: getopt::command, ctx: *module::context) void = {
+ let ls_unexported = false;
+
if(len(cmd.args) != 1) fmt::fatal("Expected 1 Argument");
let (id, trailing) = match (identstr_trailing(cmd.args[0])) {
@@ -31,7 +33,15 @@ fn list (cmd: getopt::command, ctx: *module::context) void = {
};
defer ast::ident_free(id);
- let list = list_symbols(ctx, id);
+ for ( let (k, v) .. cmd.opts) {
+ switch (k) {
+ case 'u' =>
+ ls_unexported = true;
+ case => void;
+ };
+ };
+
+ let list = list_symbols(ctx, id, ls_unexported);
defer idents_finish(list);
for (let i .. list) {
@@ -39,7 +49,11 @@ fn list (cmd: getopt::command, ctx: *module::context) void = {
};
};
-fn list_symbols (ctx: *module::context, id: ast::ident) []ast::ident = {
+fn list_symbols (
+ ctx: *module::context,
+ id: ast::ident,
+ unexp: bool = false
+) []ast::ident = {
let (path, src) = match(module::find(ctx, id)){
case let e: module::error =>
@@ -60,7 +74,7 @@ fn list_symbols (ctx: *module::context, id: ast::ident) []ast::ident = {
defer decls_finish(decls);
for (let d .. decls) {
- if (!d.exported) continue;
+ if (!d.exported && !unexp) continue;
match (d.decl) {
case let d: []ast::decl_const =>
for (let t .. d) {