facebook / starlark-rust

A Rust implementation of the Starlark language

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

lsp jump to definition bad behavior

cjhopman opened this issue · comments

often when doing jump-to-definition on a field, it just jumps me to the top of the current file. this is worse than doing nothing.

@cjhopman this one sounds odd to me, it's not really behaviour I've seen. Can you provide some more context? What kind of field are you triggering the jump-to-definition on? And does it just jump to the start of the file (0:0), or to the argument for that symbol in a load statement?

I've seen the latter behaviour mainly before I implemented correct resolve_load and render_as_load for Bazel, so if that's what you're seeing, I'm wonder if the internal version of this project fully implements the things from LspContext.

I see this too with the bazel mode:

def aspect_impl(target, ctx):
     name = ctx.rule.attr.name
     ...

Jumping from the name member of ctx.rule.attr goes to the top for me,
and some builtin methods/functions. <list variable>.append(<x>) jumps to the top from append.
Also ctx.actions.write from write.

@stagnation Ah, interesting, thanks for the insight! In general I would say anything that uses dotted definitions (foo.bar) have very poor support at the moment in the LSP. Most functionality in such cases defers to the first segment (i.e. foo in this example), but maybe that leads to some weird edge cases with go to definition.