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

Go to position where a symbol entered the namespace #1255

Open
lassepe opened this issue Oct 29, 2023 · 7 comments
Open

Go to position where a symbol entered the namespace #1255

lassepe opened this issue Oct 29, 2023 · 7 comments

Comments

@lassepe
Copy link

lassepe commented Oct 29, 2023

When using the go-to-definition feature, the current behavior jumps to the method definition that potentially resides in another module; potentially even in another package. Instead, what I usually want is to know "where did this symbol enter my namespace"? To answer this question, it would be convenient if "go-to-definition" jumped to the associated using or import statement that brought the symbol into scope.

Example:

using Dictionaries: sortkeys # invoking "go-to-definition" on `sortkeys` here should ideally still jump to the definition in `Dictionaries.jl`

...

function foo()
     ...
     sortkeys(d) # invoking "go-to-definition" on `sortkeys` here would jump to the `using` statement above
end
@fredrikekre
Copy link
Member

Wouldn't the hover action tell you this? Doesn't seem like a job for "go to definition" at least.

@pfitzseb
Copy link
Member

Yeah, I agree. "Go to references" already handles this case:
image

@lassepe
Copy link
Author

lassepe commented Oct 30, 2023

I guess my expectation just came from the fact that my python LS had the described behavior.

But I tested in rust and there it seems to behave as in LS.jl. In view of that and the fact that many others are probably already used to the current behavior, I'll close this issue. "Go to references" does the job for me.

@lassepe lassepe closed this as completed Oct 30, 2023
@pfitzseb
Copy link
Member

FWIW, the LSP also defines the textDocument/declaration request, which could maybe do this?

@pfitzseb pfitzseb reopened this Oct 30, 2023
@lassepe
Copy link
Author

lassepe commented Oct 30, 2023

Yes, at least my python language server jumps to the associated import statement upon "textDocument/declaration". In rust, however, it jumps to the definition in another crate.

@pfitzseb
Copy link
Member

I'm also not sure how e.g. VS Code shows "Go to definition" and "Go to declaration" or how the user would interact with them, FWIW.

@lassepe
Copy link
Author

lassepe commented Oct 30, 2023

It seems to be exposed in the right-click menu in vscode and the Go menu in the top bar. The user can also bind a key to it:

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants