julia-vscode / LanguageServer.jl

An implementation of the Microsoft Language Server Protocol for the Julia language.
Other
371 stars 81 forks source link

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

Open touchft opened 2 years ago

touchft commented 2 years ago

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 ?

MilesCranmer commented 2 years ago

+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.

pfitzseb commented 2 years ago

That's a completely unrelated issue.

MilesCranmer commented 2 years ago

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

pfitzseb commented 2 years ago

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.

MilesCranmer commented 2 years ago

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

RexWzh commented 1 year ago

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