How to find function clause column information?

@josevalim currently I am able to acquire the line for a function clause definition using the :on_module tracer event, similar to the following code

  def trace({:on_module, bytecode, _}, env) do
    defs = Module.definitions_in(env.module)

    defs =
      for {name, arity} = _def <- defs do
        {name, Module.get_definition(env.module, {name, arity})}

When I eventually loop through each function and its clauses, I get a structure that looks like this:

{[line: 943], ["defmodule"], [],
 {{:., [line: 943, column: 80], [GenLSP.Enumerations.SymbolKind, :module]},
  [closing: [line: 943, column: 88], line: 943, column: 81], []}}

which corresponds to the following code snippet:

  defp elixir_kind_to_lsp_kind("defmodule"), do: GenLSP.Enumerations.SymbolKind.module()

As you can see here, the metadata includes the line [line: 943], but not the column. I currently use columns: true for the compiler options, but the column doesn’t seem to show up here.

Would you know if I’m doing something wrong here?

1 Like

Please open up an issue!

Done! Column info in Module.get_definition/2 · Issue #13029 · elixir-lang/elixir · GitHub