-
Notifications
You must be signed in to change notification settings - Fork 41
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
Add inference when using dependency injection via module attribute #133
Conversation
Add a test case of parsing a module attribute which calls to `Application.get_env/3` to ensure future implementations that depends on it does not break
Nice @gugahoa, it looks promising. It shouldn't be to difficult to add support for other types as well.
Oh, did't know that. We can just call fetch/get instead as this is only semantic indicator that it shouldn't be called in runtime.
I'll do some testing but IMO this feature should not impact other usecases. Regarding the moving, the idea was to keep MetadataBuilder rather simple. Anyway, I wouldn't try it in this PR. |
Didn't think of that! It worked nicely 8b74fea |
I believe it's ready for review. Do you want me to squash the fixups and mark as ready for review or do you want me to wait a bit? Edit: There's another way of doing dependency injection that would be nice to add inference to: But to add support to that we would need to add support to parsing lists, and then add support to calling |
I think it's ready. @gugahoa do you plan to do any more changes?
We could handle it but I'm not convinced we should support every expression possible. So far Binding module cannot handle lists (maps, structs, tuples, atoms and integers). |
@gugahoa Please look into test failures |
@lukaszsamson fixed the tests, now the PR is ready for review |
Thanks @gugahoa |
Implements elixir-lsp/elixir-ls#541
This PR adds basic inference when doing dependency injection using module attributes that calls into
Application.compile_env/3
,Application.compile_env!/2
,Application.get_env/3``and
Application.fetch_env!/2`. It works by calling the function and returning the resulting module as the expression type