erlide_eclipse
erlide_eclipse copied to clipboard
Go to declaration of macro or record doesn't work if they are defined in included(include_lib) header file
The title says it all, there is no error in the module, the header file could be resolved, still, if I hit F3 while cursor is on either a macro or record that are defined in the header file, nothing happens whereas it should go to declaration. F3 on any function works fine...
Thanks a lot for the report! I created https://www.assembla.com/spaces/erlide/tickets/943 to track the issue.
It's been a while since I last checked, but with 13.9 I get an error for macros and records defined in another file and consequently in all the functions using other functions using the macro. That is a lot of red in my case :-/
Nevermind, the errors come from actual errors, the propagation of errors to calling functions makes it hard to keep track of the original problem. The "got to declaration" problem persists though for makros which definitely exist, are just defined in another file.
Could you please send me a minimal example? It works for me and we have large projects with many macros defined everywhere...
I have in project/lib/app/include
a file a.hrl:
-define(MAX, 3).
and in project/lib/app/src
the file a.erl:
-module(a).
-export([do_something/0]).
-include_lib("app/include/a.hrl").
-define(MIN, 1).
do_something() -> case ?MAX of 3 -> io:format("3") end, case ?MIN of 1 -> io:format("1") end.
project/lib/app/src is configured as a source directory. As it is, I don't get any error, F3 on MIN works fine and jumps to its definition, F3 on MAX doesn't work. If I rename MAX in a.erl to something else, I get an error. So the header file is analyzed properly, only the got to declaration doesn't work...
Did you configure the "include" directory as an include directory?
No I didn't, but I tried and it didn't change anything. Also, if I had to, that would many include directories in my case :-/
Ok, I see. I had a momentary blind spot and forgot that the problem was about include_lib. We will fix this as soon as possible.
I think I finally understood what's going on and why it failed. In fact, this was a configuration problem. I wrote a little script to do what Erlide will hopefully do at some point (see #39). To not get an include error, I need to have the base folder relative to which the path given to include_lib is resolved configured as include folder, i.e. /lib in my case assuming app lives in /lib and the include uses app/include/header.hrl. However, to get F3(and Erlang search) to work, I have to have lib/app/include configured as include folder as well. My script looks for src, test and include folders in the apps and modifies the Erlang preference file accordingly. I then have to clean my project(I think that was my problem with the example I gave). The only cases where this doesn't work is include_lib(include/header.hrl) - relative includes that is(webmachine uses this for example) because I don't handle this in my script, but I could, and "recursive" includes. If file.erl includes header1.hrl and header1.hrl includes header2.hrl which contains the actual definitions, F3 doesn't work for these in file.erl. Erlang Search works though which is good enough for me. It would be great if this could be fixed and the whole include directory configuration automated, but a little help link on the config page would do as well I guess.
Thank you, these observations are very helpful! I will try to address this very soon.
At least in the latest nightly, I have another problem with going to macro definitions. Say I'm in a file, there is a macro, I do F3 to go to the declaration and it works, it goes to the header file where it is defined, when I switch back to the original file and try to use F3 again, it doesn't work anymore. When I close the header file still open in the background and retry, it works again.
I can confirm that, created http://www.assembla.com/spaces/erlide/tickets/997-navigation-to-an-open-file-doesn-t-work
BTW, please open different issues for different problems, it's easier to track. Thanks!