rescript-vscode
rescript-vscode copied to clipboard
Signature help
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.
https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_signatureHelp
It's ready for a general review, although I have a couple of more cases to handle here in larger functions.
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.
Sounds like a good thing to try.
@cristianoc ready for your eyes.
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.
Will pick up this again and finish it soon.
@cristianoc ready for your eyes again.
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.
@cristianoc would you mind having another look?