commit cb8ef6d85454af7d85014606f31c6f5349046c69
parent d3bbb0c0676ce7901de15ab7affa66a1cb0261c3
Author: Lou Woell <lou.woell@posteo.de>
Date:   Thu,  4 Sep 2025 15:59:12 +0200

rename `find`->`resolve`

Also make it return the original symbol if it can't resolve further.

Diffstat:
Mcmd/harehelper/find.ha | 17+++++++++--------
Mcmd/harehelper/helper.ha | 8++++----
Mharedoc.el | 2+-
3 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/cmd/harehelper/find.ha b/cmd/harehelper/find.ha @@ -9,18 +9,19 @@ use hare::unparse; use io; use os; -fn find(cmd: getopt::command) void = { +fn resolve(cmd: getopt::command) void = { let id = parse::identstr(cmd.args[0])!; - let file = cmd.args[1]; + let file = if(len(cmd.args) > 1){ + yield cmd.args[1]; + } else { + printident(id); + return void; + }; match(find_uid(id, file)) { case let id_exp: ast::ident => - unparse::ident( - os::stdout, - id_exp, - )!; - fmt::println()!; + printident(id_exp); case => void; }; }; @@ -84,5 +85,5 @@ fn find_uid (id: ast::ident, path: str) (void | ast::ident) = { }; }; - return void; + return id; }; diff --git a/cmd/harehelper/helper.ha b/cmd/harehelper/helper.ha @@ -19,8 +19,8 @@ const help: []getopt::help = [ "list symbols in module", "module" ]: []getopt::help ), - ("find", [ - "find module for identifier", + ("resolve", [ + "resolve namespace for identifier", "identifier", "file" ]: []getopt::help), @@ -73,8 +73,8 @@ export fn main () void = { case void => void; case let c: (str, *getopt::command) => switch (c.0) { - case "find" => - find(*c.1); + case "resolve" => + resolve(*c.1); case "list" => list(*c.1, &ctx); case "list-modules" => diff --git a/haredoc.el b/haredoc.el @@ -59,7 +59,7 @@ "\\(\\(\\sw\\|\\s_\\)+::\\)*\\(\\sw\\|\\s_\\)+") (string-replace "*" "" (match-string 0))))))) ;; resolve identifier - (or (hh/exec (list hare/helperbin "-p" (hare/root-dir) "find" id + (or (hh/exec (list hare/helperbin "-p" (hare/root-dir) "resolve" id (buffer-file-name))) id)))