axelson
Scenic Core Team
CLI tool to get function name from line of source code
Has anyone written a CLI tool/script that when given a file path (to a .ex or .exs) file and a line number, will return the module name and function? i.e.
$ extract_line_number.bash ~/code/my_cool_proj/lib/utils.ex:15
MyCoolProj.Utils.find_by_id/2
This could be probably be built using the Elixir treesitter grammar (are there already any CLI tools that use the grammar in similar ways?). Before I embark on writing such a tool/script I wanted to see if anyone has already written one.
Most Liked
sodapopcan
It would have to be in conjunction with a scripting language. Maybe a terser way but I was thinking along these lines:
ast-grep scan --inline-rules '
id: find-def
language: Elixir
rule:
any:
- pattern: def $$$
- pattern: def $$$()
- pattern: def $$$($$$)
' --json=compact -- path/to/file.ex
giving you all the (public) function definitions in path/to/file.ex. The json includes their start and end lines.
2
axelson
Scenic Core Team
Ah, that’s a good idea. I’ll give that a try when I have a chance. Thanks!
1
Popular in Questions
I want to try my hand at web scraping. What tools/libraries do I need to use. I’m hoping to turn this into something professional so don’...
New
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
Hi, I’m just starting to build a side-project with Elixir and Phoenix and doing some basic test with Elixir alone.
What strikes me is th...
New
I have VueJS GUIs with the project generated using Webpack.
I have Elixir modules that will need to be used by the VueJS GUIs.
I forese...
New
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
I have followed this StackOverflow post to install the specific version of Erlang.
And When I am running mix ecto.setup then getting fol...
New
I’m brand new to Phoenix and I have stripped one of the demo applications to the bone. I just want to get an svg up on the screen. Here i...
New
Hi guys, i’m new in the Elixir world, and i have to say, that i love it!
i’m having some problem to understand anonymous functions with ...
New
Hi! May someone helps me, please!
I have two apps into an umbrella project: the first one is Database, which manages queries, and the se...
New
Other popular topics
This post is an instruction guide to help you setup your Neovim for Elixir development from scratch. It includes general information on h...
New
Hello, I have map which I want to convert it to string like this:
the map:
%{last_name: "tavakkoli", name: "shahryar"}
the string I ne...
New
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
Please see the new poll here: Which code editor or IDE do you use? (Poll) (2022 Edition)
It’s been a while since we first asked this, I...
New
I am trying to run a deploy with docker and I successfully runned with this command:
docker build -t romenigld/blog-prod .
but when I t...
New
Hi there,
I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New
Hi everyone,
I was playing with phoenix liveView but I run into an issue. I have a form and want to validate each input text when the te...
New
I would like to know what is the best IDE for elixir development?
New
Hello!
Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
I wrote this comment on r/haskell, and it’s not popular there. :wink: But I think I’m on to something…
Haskell reminds me of Java, and e...
New








