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

goto-definition-at-point dosen't work on aliases #195

Closed
TheoAndersen opened this issue Dec 21, 2015 · 18 comments
Closed

goto-definition-at-point dosen't work on aliases #195

TheoAndersen opened this issue Dec 21, 2015 · 18 comments

Comments

@TheoAndersen
Copy link

The alchemist-goto-definition-at-point is great, but if you use an alias it can't find the definition of function calls. (Alchemist version 1.6.0)

  alias Rumb1.User

  def new(conn, _params) do
    changeset = User.changeset(%User{})    # <-- definition cannot be found
    render conn, "new.html", changeset: changeset
  end

  def create(conn, %{"user" => user_params}) do
    changeset = Rumb1.User.registration_changeset(%User{}, user_params)  # <-- can be found

If i were more proficient at elisp i would take a go at this my self :)

/Theo

@TheoAndersen
Copy link
Author

now i look at the alchemist code, it seems like it takes aliases into account in some way - but it does not work when i try it. Maybe i have something setup wrong?

@tonini
Copy link
Owner

tonini commented Dec 22, 2015

Thanks @TheoAndersen I'll have a look at it as soon as possible 👍

@TheoAndersen
Copy link
Author

Now i have an example where M-. can't find its way into import Plug.Conn or the reference too it which is a call to get_session(conn, :user_id)

on the first i get an error in process filter: Wrong type argument: strings, nil and on the get_session it returns Don't know how to find get_session

@gausby
Copy link
Contributor

gausby commented Dec 22, 2015

I have the same problem and I am working in a project located in an umbrella.

@TheoAndersen
Copy link
Author

Just tried debugging the problem - and it seems to happen at the call to the elixir backend - i can't figure out why though :) (stumbling my way around here)

Now I'm a total ELisp newbie, so don't take this the wrong way - i think this project is excellent and you do great work. But looking at tests, they seem very unit testy (small / focused). Wouldn't it be cool to include some broader tests, which would test all the way though to the server and back? This way you could hopefully have more accept-like tests of bigger features? (I've seen some project use ecukes for this kind of tests, but thats just a framework)
But I'm not at alle sure how easy this is to setup and automate in elisp+emacs though.

@tonini
Copy link
Owner

tonini commented Dec 27, 2015

Hey @TheoAndersen and @gausby

Thanks guys for having a deep look at this issue so far.

My apology for responding a bit late to this issue. I really had some busy holidays and my kids were ill too. But it looks like everything getting better and I try to get back in shape with my projects. 👍

@TheoAndersen about the test suite I think you're right, I'll start adding integration tests for covering the work between alchemist and the server.

@TheoAndersen About the issue now, I'll have a look at it right now and will get back to you about it as soon as possible.

Thanks a lot for your patience.

@tonini
Copy link
Owner

tonini commented Dec 27, 2015

@TheoAndersen What Elixir version are you using? And it is possible to get the source of your codebase?

I tested it in my own environment and codebases, and it always works. So I need some codebase to test it.

@tonini
Copy link
Owner

tonini commented Dec 27, 2015

@TheoAndersen is it possible to catch you on #elixir-lang irc channel or slack?

@TheoAndersen
Copy link
Author

Hi @tonini

Np with the timing. I have kids as well and the holidays are always busy busy :)

I'm running Elixir 1.1.1.

And the codebase I'm working on are the examples from the Programming Phoenix book.
Just pushed my hacky version of it to here; https://github.com/TheoAndersen/rumbl (yes i misspelled rumbl as rumb1 in the source :S)

And my emacs config is here if that's relevant. https://github.com/TheoAndersen/.emacs.d

I haven't been that much on irc or slack - but Ill try to improve that. Whats most people on? both?

@gausby
Copy link
Contributor

gausby commented Dec 27, 2015

@TheoAndersen there are elixir emacs related channels on both Slack and IRC. I don't know much about slack but we are hanging out at #emacs-elixir on irc.freenode.net—We are not the lively at the moment, but I hope that we can improve that :)

@safi
Copy link
Contributor

safi commented Dec 29, 2015

Hi @TheoAndersen, I guess the convention you have used for naming the modules 'Rumb1' instead of 'Rumbl'(as per the directory structure) isn't helping alchemist to resolve the alias.

@TheoAndersen
Copy link
Author

:) it was a typo that i didn't bother to fix. I'll try it and see if it dosen't help it.

By the way, should the go-to defintion be able to hop down to the code in deps as well? - its sometimes helpfull to be able to jump inside phoenix code to see how it works in there.

@TheoAndersen
Copy link
Author

I have pushed a fix to my Rumbl project so that it now is Rumbl and not Rumb1, and now the part where User was aliased in user_controller seems to work.

In the same file theres a reference to Repo (without using the Rumbl namespace) which dosen't seem to work. But that might be something i have done again - and maybe we're beginning to nitpick..

Only thing left was that @gausby also had similar problems in a another project of his?

@safi
Copy link
Contributor

safi commented Dec 29, 2015

alias for Repo is injected from 'use Rumbl.Web', which is why go-to definition is not able to resolve it. Otherwise, go-to definitions can resolve code in deps/ as well.

@tonini
Copy link
Owner

tonini commented Dec 29, 2015

@gausby the issue with an umbrella projects are still the thing that the root of the main project cant be detected because of the .mix file. So we should talk about that issue here #185

@tonini
Copy link
Owner

tonini commented Dec 29, 2015

@TheoAndersen I tested it with the codebase of rumbl and everything works correctly. Did you compile the whole project before trying to jump to definitions? Because without BEAM files the informations wouldn't be there at all.

@tonini
Copy link
Owner

tonini commented Jan 14, 2016

@TheoAndersen whats the status about that?

@TheoAndersen
Copy link
Author

I've updated to 1.7.0 of Alchemist and tested it again and it works.

So for my point of view this issue is resolved :)

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

4 participants