X-Git-Url: https://git.xandkar.net/?a=blobdiff_plain;f=home%2Fbin%2Ferlcode-find-calls-to-module;h=46f5d35a25f3ec78a08b5b99f9850c3c3f1b3730;hb=4cc39e2abe613081cded4c3fc23b978c2ee4ebdc;hp=a3a86854e9458ada1de6d958ab77ea8064482b09;hpb=15f22284bb881be22ea8af6b36a857a17628706a;p=khome.git diff --git a/home/bin/erlcode-find-calls-to-module b/home/bin/erlcode-find-calls-to-module index a3a8685..46f5d35 100755 --- a/home/bin/erlcode-find-calls-to-module +++ b/home/bin/erlcode-find-calls-to-module @@ -19,9 +19,11 @@ find $dirs -type f -name '*.erl' -exec grep -Hn "\<$target_module\>:" '{}' \; \ sub("\\(.*$", "", called_function) if (called_function ~ /^[a-z][a-zA-Z_0-9]+$/) { - Calls[called_function]++ - Calls_from[caller_module_file, called_function]++ - Caller_modules[caller_module_file]++ + if (called_function ~ target_fun_regex) { + Calls[called_function]++ + 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", \ @@ -32,18 +34,19 @@ find $dirs -type f -name '*.erl' -exec grep -Hn "\<$target_module\>:" '{}' \; \ END { indent = " " + + print "group-by-caller" for (caller_module_file in Caller_modules) { - print caller_module_file; + printf "%s%s\n", indent, caller_module_file; for (cf in Calls_from) { split(cf, call, SUBSEP); - if (call[1] == caller_module_file && call[2] ~ target_fun_regex) - printf "%s%s\n", indent, call[2] | "sort"; + if (call[1] == caller_module_file) + printf "%s%s\n", indent indent, call[2] | "sort"; } close("sort") } - print "" - printf "Inferred API of %s:\n", target_module + print "all" for (called_function in Calls) printf "%s%s\n", indent, called_function | "sort" close("sort")