X-Git-Url: https://git.xandkar.net/?a=blobdiff_plain;f=home%2Fbin%2Ferlcode-find-calls-to-module;fp=home%2Fbin%2Ferlcode-find-calls-to-module;h=0000000000000000000000000000000000000000;hb=763a19005e6c4ec420799b8bc531c941b07bfda3;hp=46f5d35a25f3ec78a08b5b99f9850c3c3f1b3730;hpb=4cc39e2abe613081cded4c3fc23b978c2ee4ebdc;p=khome.git diff --git a/home/bin/erlcode-find-calls-to-module b/home/bin/erlcode-find-calls-to-module deleted file mode 100755 index 46f5d35..0000000 --- a/home/bin/erlcode-find-calls-to-module +++ /dev/null @@ -1,53 +0,0 @@ -#! /bin/bash - -target_module="$1" -target_fun_regex="$2" -shift 2 -dirs=$@ - -find $dirs -type f -name '*.erl' -exec grep -Hn "\<$target_module\>:" '{}' \; \ -| sed 's/%.*$//g' \ -| awk \ - -F "${target_module}:" \ - -v target_module="$target_module" \ - -v target_fun_regex="$target_fun_regex" ' - $1 && $2 { - caller_module_file = $1 - sub(":.*$", "", caller_module_file) - - called_function = $2 - sub("\\(.*$", "", called_function) - - if (called_function ~ /^[a-z][a-zA-Z_0-9]+$/) { - 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", \ - caller_module_file, called_function, $0 \ - > "/dev/stderr" - } - } - - END { - indent = " " - - print "group-by-caller" - for (caller_module_file in Caller_modules) { - printf "%s%s\n", indent, caller_module_file; - for (cf in Calls_from) { - split(cf, call, SUBSEP); - if (call[1] == caller_module_file) - printf "%s%s\n", indent indent, call[2] | "sort"; - } - close("sort") - } - - print "all" - for (called_function in Calls) - printf "%s%s\n", indent, called_function | "sort" - close("sort") - }'