Skip to content

Fix for multi-line use calls#335

Open
katafrakt wants to merge 6 commits into
elixir-lsp:masterfrom
katafrakt:definition-in-using-transitive
Open

Fix for multi-line use calls#335
katafrakt wants to merge 6 commits into
elixir-lsp:masterfrom
katafrakt:definition-in-using-transitive

Conversation

@katafrakt

Copy link
Copy Markdown
Contributor

When I tried to plug #333 into Expert, I found it not working for some Ecto definitions. At first I thought this is due to transitive use of use (like use AshPostgres.Repo which calls use Ecto.Repo inside its __using__), but ultimately I found this is because of multi-line uses, like AshPostgres does:

        use Ecto.Repo,
          adapter: opts[:adapter] || Ecto.Adapters.Postgres,
          otp_app: otp_app

When we were calling use_site?/3 on the first line, it tried to do Code.string_to_quoted on a line ending with a comma, returning {:error, _} and not finding it as a use site. This PR replaces the check with a regex-based. I was trying to find some false positives it can generate, but I don't think there are some. The obvious one is about comments, but I don't think a line with a comment can be a param to use_site? currently.

The commit history is a mess here of all my previous attempt, so it needs squashing.

@katafrakt

Copy link
Copy Markdown
Contributor Author

@lukaszsamson do you think it's ok to merge? I would love to pull these new changes to Expert, but I think this fix is necessary for that.

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