Skip to content

Fix multi-line use site detection without regex#339

Merged
lukaszsamson merged 1 commit into
masterfrom
codex/parser-use-site
Jul 4, 2026
Merged

Fix multi-line use site detection without regex#339
lukaszsamson merged 1 commit into
masterfrom
codex/parser-use-site

Conversation

@lukaszsamson

Copy link
Copy Markdown
Collaborator

Summary

This is an alternative to #335 that keeps the same regression coverage but avoids the regex-based use detector.

It changes use_site?/3 to:

  • parse complete single-line candidates with Code.string_to_quoted/2
  • fall back to Code.Fragment.container_cursor_to_quoted/2 for incomplete lines such as use Foo,
  • inspect the AST for a use / Kernel.use call on the recorded definition line

Validation

  • mix format --check-formatted
  • mix test test/elixir_sense/providers/definition/locator_using_macro_test.exs
  • mix test

@lukaszsamson lukaszsamson changed the title [codex] Fix multi-line use site detection without regex Fix multi-line use site detection without regex Jul 4, 2026
@lukaszsamson
lukaszsamson marked this pull request as ready for review July 4, 2026 06:56
@lukaszsamson
lukaszsamson merged commit da065ae into master Jul 4, 2026
17 checks passed
katafrakt added a commit to expert-lsp/expert that referenced this pull request Jul 6, 2026
This is especially useful with Ecto and jumping to functions like
`MyApp.Repo.all`. Currently it takes the user to `use Ecto.Repo` inside
`my_app/repo.ex`, but after this change the user actually lands in Ecto
source.

The real changes are made in ElixirSense, this just updates the
dependency and unskips the test verifying this behaviour.

* elixir-lsp/elixir_sense#333
* elixir-lsp/elixir_sense#339
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

Successfully merging this pull request may close these issues.

1 participant