LanguageServer.jl icon indicating copy to clipboard operation
LanguageServer.jl copied to clipboard

How to make code-jump working within the developing package ?

Open touchft opened this issue 3 years ago • 6 comments

Example:

A package named as 'testjl' was initialized by PkgTemplates with part of contents:

file testjl/src/testjl.jl:

module testjl
export ff
# Write your package code here.

function ff()
    return 1
end

end

file testjl/test/runtests.jl:

using testjl
using Test

ff()

Question: How can I get code-jump working for the function ff within the file testjl/test/runtests.jl ?

touchft avatar Sep 23 '22 05:09 touchft

+1. This is really needed! @davidanthoff @ZacLN do you know why this is not currently possible, even though https://github.com/julia-vscode/LanguageServer.jl/pull/871 was merged?

Related: https://github.com/julia-vscode/julia-vscode/issues/1740, https://github.com/julia-vscode/julia-vscode/issues/2904.

For example, if you look at the codebase of SymbolicRegression.jl, every single file defines its own module - e.g., the file src/AdaptiveParsimony.jl defines the AdaptiveParsimonyModule which can be imported by other files. This is to make the codebase easier to navigate for potential contributors, since all dependencies are explicit[1]. However, the downside is that Julia VSCode doesn't seem to know where the functions are actually defined.


[1] Aside: I think this should be done by every Julia package, rather than the overpowered namespace mixing include("...") which requires me to search manually for where a function is defined, or to rely on an IDE.

MilesCranmer avatar Oct 05 '22 21:10 MilesCranmer

That's a completely unrelated issue.

pfitzseb avatar Oct 05 '22 21:10 pfitzseb

Wait, do you mean the PR is unrelated, or the other GH issues julia-vscode/julia-vscode#1740 julia-vscode/julia-vscode#2904?

MilesCranmer avatar Oct 05 '22 21:10 MilesCranmer

Your case is unrelated to this issue, which is about missing functionality in the test dir. Unless I misunderstood you and symbol resolution works fine in package files even with the one-module-per-file structure and only breaks in the test dir.

pfitzseb avatar Oct 05 '22 22:10 pfitzseb

Oh, I see what you mean, thanks. Let me open a new issue then.

MilesCranmer avatar Oct 05 '22 22:10 MilesCranmer

Hi, @touchft . I don't think it is a bug, since it is unrepeatable in my machine. Maybe you miss the Project.toml file? Can you provide more detail of the repo? Feel free to correct me if I miss something.

  1. generate package by PkgTemplates as mentioned in your comment.
    # using Pkg; Pkg.add("PkgTemplates")
    using PkgTemplates
    Template(dir=".")("testjl")
    
    File-tree of the repo:
    # tree
    ├── LICENSE
    ├── Manifest.toml
    ├── Project.toml
    ├── README.md
    ├── src
    │   └── testjl.jl
    └── test
        └── runtests.jl
    
  2. rewrite runtests.jl and testjl.jl as above, then image

RexWzh avatar Dec 06 '22 14:12 RexWzh