Obtaining source file and line for function/macro definition

40 views
Skip to first unread message

James Norton

unread,
Jul 6, 2015, 10:41:13 AM7/6/15
to elixir-l...@googlegroups.com
Is it possible to obtain the source file and start line for a function/macro definition programmatically? I know that __info__/1 can provide the source file for a module, but I would like to be able to get the same information for function and macro definitions. I want to implement 'goto definition' for the Atom iex package.

I can get the source file for a module from __info__ and then use regex to try to locate the line in the file with the definition, but this is clunky. I was hoping there was some means of acquiring the file and line info directly.

Thank,

James

José Valim

unread,
Jul 6, 2015, 11:15:19 AM7/6/15
to elixir-l...@googlegroups.com
You can get the file source with:

iex> String.__info__(:compile)

You can get the line for each function with:

iex> Code.get_docs String, :all



José Valim
Skype: jv.ptec
Founder and Director of R&D

--
You received this message because you are subscribed to the Google Groups "elixir-lang-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-ta...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-talk/d30b08fd-53be-4148-aa2e-4a1480b8dbd6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

James Norton

unread,
Jul 6, 2015, 8:01:52 PM7/6/15
to elixir-l...@googlegroups.com, jose....@plataformatec.com.br
Excellent. Thank you.

-James
Reply all
Reply to author
Forward
0 new messages