From fc84ff9cee33f706bb84ef10b9b99718c9271f28 Mon Sep 17 00:00:00 2001 From: Siraaj Khandkar Date: Wed, 3 Mar 2021 10:46:26 -0500 Subject: [PATCH] Show only matching caller modules --- home/bin/erlcode-find-calls-to-module | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/home/bin/erlcode-find-calls-to-module b/home/bin/erlcode-find-calls-to-module index a3a8685..cf663b2 100755 --- a/home/bin/erlcode-find-calls-to-module +++ b/home/bin/erlcode-find-calls-to-module @@ -19,9 +19,14 @@ find $dirs -type f -name '*.erl' -exec grep -Hn "\<$target_module\>:" '{}' \; \ sub("\\(.*$", "", called_function) if (called_function ~ /^[a-z][a-zA-Z_0-9]+$/) { + # Gather full API of the target_module Calls[called_function]++ - Calls_from[caller_module_file, called_function]++ - Caller_modules[caller_module_file]++ + + # Gather target call sites + if (called_function ~ target_fun_regex) { + Calls_from[caller_module_file, called_function]++ + Caller_modules[caller_module_file]++ + } } else { printf \ "[WARN] skipped an invalid erlang function name. File: \"%s\", function: \"%s\", original line: \"%s\"\n", \ @@ -36,7 +41,7 @@ find $dirs -type f -name '*.erl' -exec grep -Hn "\<$target_module\>:" '{}' \; \ print caller_module_file; for (cf in Calls_from) { split(cf, call, SUBSEP); - if (call[1] == caller_module_file && call[2] ~ target_fun_regex) + if (call[1] == caller_module_file) printf "%s%s\n", indent, call[2] | "sort"; } close("sort") -- 2.20.1