gcv / julia-snail

An Emacs development environment for Julia
GNU General Public License v3.0
230 stars 21 forks source link

Support module detection for included files #9

Closed gcv closed 4 years ago

gcv commented 4 years ago

Consider the following case:

File MyModule.jl:

module MyModule

include("a1.jl")

end

File a1.jl:

function f1()
    "hello world"
end

The contents of file a1.jl are part of MyModule, and should be detected as such by Snail.

The parser should detect include calls inside (potentially nested) modules, and when called upon to detect what module a1.jl is in return MyModule instead of Main. This should be doable with an in-memory data structure, mapping from filename to module.

gcv commented 4 years ago

@orialb: I finished a first attempt at implementing this feature, which we discussed on Discourse. I still have to write some tests for it, but it seems to work for me so far.

The feature branch is not merged yet: https://github.com/gcv/julia-snail/tree/include-detection Documentation link: https://github.com/gcv/julia-snail/tree/include-detection#module-nested-includes

If you have time to try this branch, I'll appreciate any comments or bug reports.

orialb commented 4 years ago

Awesome! I will have a look this week.

orialb commented 4 years ago

Just wanted to let you know that I started using the feature branch on my machine. From a quick check it seems that completion and xref commands are working across module files, very nice!

Unfortunately at the moment I am mainly writing Latex instead of Julia code, so I didn't have the chance to really test this in regular usage. Hopefully soon I will have some excuse to do some coding work for one of my projects so I could test this more thoroughly.

gcv commented 4 years ago

Cool. I just found and fixed several bugs in that feature, and added some tests. Branch is now merged in and ready for people to find bugs in it.