-
Notifications
You must be signed in to change notification settings - Fork 60
Signature help #547
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
Merged
Merged
Signature help #547
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
779e12a
wire up server capability + command for signature help
zth 6a51a0d
set up analysis bin command, and needed things from the LS protocol
zth b311369
set up empty signature help test
zth 6f19fbb
another test to help distinguish
zth 9c26acd
implement signature help for function applications
zth 7a5769c
changelog + readme
zth 037831f
Merge branch 'master' of github.com:rescript-lang/rescript-vscode int…
zth 07e2807
leverage the parser to figure out the parameter offsets
zth d970290
include docs for signature if available
zth ac24e93
if a function has only one (unlabelled) argument, we can always highl…
zth f1a02ed
Merge branch 'master' into signature-help
zth 03cd58c
add debug utilities
zth f5ab1eb
Merge branch 'debug-utils' into signature-help
zth 2f7c06e
get rid of hasPosInclusive
zth fc6afe3
move extractExpApplyArgs to SharedTypes for real
zth 8c237f2
shared function
zth d2190f8
add way to parse via raw source string in parser, and replace current…
zth 4df6121
refactor logic some
zth 7ebf877
Merge branch 'master' into signature-help
zth 093ebef
refactor hover so type expansion can be shared, and integrate into si…
zth 4fdf6ff
Merge branch 'master' into signature-help
zth f02ebef
gate new experimental signature help behind configuration option
zth c9fe034
comment
zth 0368f1d
changelog
zth File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,23 @@ type inlayHint = { | |
paddingRight: bool; | ||
} | ||
|
||
(* https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#parameterInformation *) | ||
type parameterInformation = {label: int * int; documentation: markupContent} | ||
|
||
(* https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#signatureInformation *) | ||
type signatureInformation = { | ||
label: string; | ||
parameters: parameterInformation list; | ||
documentation: markupContent option; | ||
} | ||
|
||
(* https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#signatureHelp *) | ||
type signatureHelp = { | ||
signatures: signatureInformation list; | ||
activeSignature: int option; | ||
activeParameter: int option; | ||
} | ||
|
||
type completionItem = { | ||
label: string; | ||
kind: int; | ||
|
@@ -170,6 +187,45 @@ let stringifyCodeLens (codeLens : codeLens) = | |
| None -> "" | ||
| Some command -> stringifyCommand command) | ||
|
||
let stringifyParameterInformation (parameterInformation : parameterInformation) | ||
= | ||
Printf.sprintf {|{"label": %s, "documentation": %s}|} | ||
(let line, chr = parameterInformation.label in | ||
"[" ^ string_of_int line ^ ", " ^ string_of_int chr ^ "]") | ||
(stringifyMarkupContent parameterInformation.documentation) | ||
|
||
let stringifySignatureInformation (signatureInformation : signatureInformation) | ||
= | ||
Printf.sprintf | ||
{|{ | ||
"label": "%s", | ||
"parameters": %s%s | ||
}|} | ||
(Json.escape signatureInformation.label) | ||
(signatureInformation.parameters | ||
|> List.map stringifyParameterInformation | ||
|> array) | ||
(match signatureInformation.documentation with | ||
| None -> "" | ||
| Some docs -> | ||
Printf.sprintf ",\n \"documentation\": %s" | ||
(stringifyMarkupContent docs)) | ||
Comment on lines
+211
to
+212
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Poor mans optional prop stringification. |
||
|
||
let stringifySignatureHelp (signatureHelp : signatureHelp) = | ||
Printf.sprintf | ||
{|{ | ||
"signatures": %s, | ||
"activeSignature": %s, | ||
"activeParameter": %s | ||
}|} | ||
(signatureHelp.signatures |> List.map stringifySignatureInformation |> array) | ||
(match signatureHelp.activeSignature with | ||
| None -> null | ||
| Some activeSignature -> activeSignature |> string_of_int) | ||
(match signatureHelp.activeParameter with | ||
| None -> null | ||
| Some activeParameter -> activeParameter |> string_of_int) | ||
|
||
(* https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#diagnostic *) | ||
let stringifyDiagnostic d = | ||
Printf.sprintf | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.