-
-
Notifications
You must be signed in to change notification settings - Fork 32
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
fix: find app_name when kw list is defined at the end #236
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,8 +26,10 @@ defmodule Igniter.Project.Application do | |
|> Sourceror.Zipper.zip() | ||
|
||
with {:ok, zipper} <- Igniter.Code.Function.move_to_def(zipper, :project, 0), | ||
zipper <- Igniter.Code.Common.rightmost(zipper), | ||
true <- Igniter.Code.List.list?(zipper), | ||
{:ok, zipper} <- | ||
Igniter.Code.Common.move_to(zipper, &match?({:__block__, _, [:app]}, &1.node)), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this might be too liberal. Any other keyword list that contains an There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was busy when I typed the above, sorry 😆 its not very clear. The current feature could have a false positive, i.e if someone had something like this: def project() do
[
foo: [app: :foo], # <- we'd find this one.
app: :foo
]
end And false positives are dangerous. I think "left most list" is really the only safe heuristic to apply for now. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It was clear enough 😄 Yeah that makes sense, I'm gonna look at that |
||
zipper = Zipper.up(zipper), | ||
zipper = Zipper.up(zipper), | ||
{:ok, zipper} <- Igniter.Code.Keyword.get_key(zipper, :app), | ||
{:ok, app_name} when is_atom(app_name) <- expand_key_value(zipper) do | ||
app_name | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keyword.get_key/2
does check if it's a list already.