facebook / starlark-rust

A Rust implementation of the Starlark language
Apache License 2.0
672 stars 53 forks source link

lsp jump to definition bad behavior #90

Closed cjhopman closed 10 months ago

cjhopman commented 11 months ago

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.

MaartenStaa commented 11 months ago

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

stagnation commented 11 months ago

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.

MaartenStaa commented 10 months ago

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