rescript-vscode icon indicating copy to clipboard operation
rescript-vscode copied to clipboard

Signature help

Open zth opened this issue 3 years ago • 5 comments

Closes https://github.com/rescript-lang/rescript-vscode/issues/252

This implements signature help for function applications. Signature help is an "interactive" help hint you get when calling a function, that tells you what parameters the function has, as well as what parameter you're currently filling in, if any. Essentially a hover, but with the current parameter you're working on highlighted.

image

https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_signatureHelp

zth avatar Aug 06 '22 18:08 zth

It's ready for a general review, although I have a couple of more cases to handle here in larger functions.

zth avatar Aug 06 '22 18:08 zth

After some testing, this has some ways to go for larger function bodies. I had another idea - instead of printing a dummy function, extracting types, and calculating offsets that way, what if I simply take the label (type string) that will be the signature help, parse that type definition with the parser again, and let the parser tell me all of the offsets.

I think that should work, and also future proof/vastly simplify things.

zth avatar Aug 07 '22 04:08 zth

Sounds like a good thing to try.

cristianoc avatar Aug 07 '22 04:08 cristianoc

@cristianoc ready for your eyes.

zth avatar Aug 07 '22 19:08 zth

Compared to other features, this is a little more elaborate i.e. maintenance cost for the future. I'd say the ratio value / cost is OKish.

cristianoc avatar Aug 08 '22 06:08 cristianoc

Will pick up this again and finish it soon.

zth avatar Sep 15 '22 10:09 zth

@cristianoc ready for your eyes again.

zth avatar Sep 19 '22 17:09 zth

Got some philosophical question.

Also how about when named and unnamed arguments are mixed in the same call: does that work at the moment?

It should, there are a few tests for it. Although I haven't tested it extensively.

zth avatar Sep 22 '22 08:09 zth

@cristianoc would you mind having another look?

zth avatar Sep 22 '22 10:09 zth