Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get the module for the current line of a file #94

Closed
axelson opened this issue May 11, 2020 · 1 comment
Closed

Get the module for the current line of a file #94

axelson opened this issue May 11, 2020 · 1 comment

Comments

@axelson
Copy link
Member

axelson commented May 11, 2020

Is it possible to expose a public API that will return the Module that corresponds to the current line in the file? (i.e. if there are three modules defined in a file, this API will return the module whose body is on the specified line).

This would be a replacement for ElixirLS calling into ElixirSense.Core.Metadata.get_env:

https://github.com/elixir-lsp/elixir-ls/blob/c9b095fc797613b33c7bc39ca72e9b48c69aedac/apps/debugger/lib/debugger/server.ex#L616

Related issue: elixir-lsp/elixir-ls#234

@lukaszsamson
Copy link
Collaborator

I believe with the changes from #234 the need for that is lower.
The problem with our approach is that we use token_metadata from AST. This works well for standard elixir code but it will fail for anything macro generated. In elixir a code position moay correspond to many modules. There's no better standard lib API that returns code ranges for module as of 1.15. Compile tracer only returns begin line in macro env. Docs return begin line and column.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants