Skip to content

Commit 6b3974c

Browse files
kaashyapanbaronfel
authored andcommitted
add inlineValue from LSP 3.17
1 parent 02adab3 commit 6b3974c

File tree

5 files changed

+101
-2
lines changed

5 files changed

+101
-2
lines changed

src/LanguageServerProtocol.fs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ module Server =
232232
"textDocument/semanticTokens/range", requestHandling (fun s p -> s.TextDocumentSemanticTokensRange(p))
233233
"textDocument/inlayHint", requestHandling (fun s p -> s.TextDocumentInlayHint(p))
234234
"inlayHint/resolve", requestHandling (fun s p -> s.InlayHintResolve(p))
235+
"textDocument/inlineValue", requestHandling (fun s p -> s.TextDocumentInlineValue(p))
235236
"workspace/didChangeWatchedFiles",
236237
requestHandling (fun s p -> s.WorkspaceDidChangeWatchedFiles(p) |> notificationSuccess)
237238
"workspace/didChangeWorkspaceFolders",

src/Server.fs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,10 @@ type ILspServer =
306306
/// reasons: in case of error, reloading a workspace etc.
307307
abstract member WorkDoneProgessCancel: ProgressToken -> Async<unit>
308308

309+
/// The inline value request is sent from the client to the server to compute inline values for a given text document
310+
/// that may be rendered in the editor at the end of lines.
311+
abstract member TextDocumentInlineValue: InlineValueParams -> AsyncLspResult<InlineValue [] option>
312+
309313
[<AbstractClass>]
310314
type LspServer() =
311315
abstract member Dispose: unit -> unit
@@ -660,6 +664,11 @@ type LspServer() =
660664

661665
default __.WorkDoneProgessCancel(_) = ignoreNotification
662666

667+
/// The inline value request is sent from the client to the server to compute inline values for a given text document
668+
/// that may be rendered in the editor at the end of lines.
669+
abstract member TextDocumentInlineValue: InlineValueParams -> AsyncLspResult<InlineValue [] option>
670+
default __.TextDocumentInlineValue(_) = notImplemented
671+
663672
interface ILspServer with
664673
member this.Dispose() = this.Dispose()
665674
member this.Initialize(p: InitializeParams) = this.Initialize(p)
@@ -721,4 +730,5 @@ type LspServer() =
721730
member this.TextDocumentSemanticTokensRange(p: SemanticTokensRangeParams) = this.TextDocumentSemanticTokensRange(p)
722731
member this.TextDocumentInlayHint(p: InlayHintParams) = this.TextDocumentInlayHint(p)
723732
member this.InlayHintResolve(p: InlayHint) = this.InlayHintResolve(p)
724-
member this.WorkDoneProgessCancel(token) = this.WorkDoneProgessCancel(token)
733+
member this.WorkDoneProgessCancel(token) = this.WorkDoneProgessCancel(token)
734+
member this.TextDocumentInlineValue(p: InlineValueParams) = this.TextDocumentInlineValue(p)

src/Types.fs

Lines changed: 72 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,17 @@ type InlayHintWorkspaceClientCapabilities =
333333
/// change that requires such a calculation.
334334
RefreshSupport: bool option }
335335

336+
/// Client workspace capabilities specific to inline values.
337+
type InlineValueWorkspaceClientCapabilities =
338+
{ /// Whether the client implementation supports a refresh request sent from
339+
/// the server to the client.
340+
///
341+
/// Note that this event is global and will force the client to refresh all
342+
/// inline values currently shown. It should be used with absolute care and
343+
/// is useful for situation where a server for example detects a project wide
344+
/// change that requires such a calculation.
345+
RefreshSupport: bool option }
346+
336347
type CodeLensWorkspaceClientCapabilities =
337348
{ /// Whether the client implementation supports a refresh request sent from the
338349
/// server to the client.
@@ -372,6 +383,12 @@ type WorkspaceClientCapabilities =
372383
/// @since 3.17.0
373384
InlayHint: InlayHintWorkspaceClientCapabilities option
374385

386+
387+
/// Client workspace capabilities specific to inline value.
388+
///
389+
/// @since 3.17.0
390+
InlineValue: InlineValueWorkspaceClientCapabilities option
391+
375392
/// Client workspace capabilities specific to code lenses.
376393
///
377394
/// @since 3.16.0
@@ -726,6 +743,19 @@ type InlayHintClientCapabilities =
726743
/// hint.
727744
ResolveSupport: InlayHintClientCapabilitiesResolveSupport option }
728745

746+
747+
type InlineValueClientCapabilitiesResolveSupport =
748+
{ /// The properties that a client can resolve lazily.
749+
Properties: string [] }
750+
751+
/// Inline value client capabilities.
752+
type InlineValueClientCapabilities =
753+
{ /// Whether inline value support dynamic registration.
754+
DynamicRegistration: bool option
755+
/// Indicates which properties a client can resolve lazily on a inline
756+
/// value.
757+
ResolveSupport: InlineValueClientCapabilitiesResolveSupport option }
758+
729759
type RenameClientCapabilities =
730760
{ /// Whether rename supports dynamic registration.
731761
DynamicRegistration: bool option
@@ -1005,6 +1035,10 @@ type InlayHintOptions =
10051035
{ /// The server provides support to resolve additional information for an inlay hint item.
10061036
ResolveProvider: bool option }
10071037

1038+
type InlineValueOptions =
1039+
{ /// The server provides support to resolve additional information for aniline lay hint item.
1040+
ResolveProvider: bool option }
1041+
10081042
type WorkspaceFoldersServerCapabilities =
10091043
{ /// The server has support for workspace folders.
10101044
Supported: bool option
@@ -1143,6 +1177,8 @@ type ServerCapabilities =
11431177

11441178
InlayHintProvider: InlayHintOptions option
11451179

1180+
InlineValueProvider: InlineValueOptions option
1181+
11461182
/// Workspace specific server capabilities.
11471183
Workspace: WorkspaceServerCapabilities option
11481184

@@ -1171,7 +1207,8 @@ type ServerCapabilities =
11711207
FoldingRangeProvider = None
11721208
SelectionRangeProvider = None
11731209
SemanticTokensProvider = None
1174-
InlayHintProvider = None
1210+
InlayHintProvider = None
1211+
InlineValueProvider = None
11751212
Workspace = None }
11761213

11771214
type InitializeResult =
@@ -2330,6 +2367,40 @@ type InlayHint =
23302367
/// a `textDocument/inlayHint` and a `inlayHint/resolve` request.
23312368
Data: LSPAny option }
23322369

2370+
/// InlineValue Context
2371+
type InlineValueContext =
2372+
{
2373+
/// The stack frame (as a DAP Id) where the execution has stopped.
2374+
FrameId: int
2375+
2376+
/// The document range where execution has stopped.
2377+
/// Typically the end position of the range denotes the line where the inline values are shown.
2378+
StoppedLocation: Range }
2379+
2380+
/// A parameter literal used in inline value requests.
2381+
type InlineValueParams = (*WorkDoneProgressParams &*)
2382+
{ /// The text document.
2383+
TextDocument: TextDocumentIdentifier
2384+
/// The visible document range for which inline values should be computed.
2385+
Range: Range
2386+
/// Additional information about the context in which inline values were requested
2387+
Context: InlineValueContext }
2388+
2389+
/// Provide inline value as text.
2390+
type InlineValueText =
2391+
{
2392+
/// The document range for which the inline value applies.
2393+
Range: Range
2394+
/// The text of the inline value.
2395+
Text: String
2396+
}
2397+
2398+
[<ErasedUnion>]
2399+
[<RequireQualifiedAccess>]
2400+
type InlineValue =
2401+
| InlineValueText of InlineValueText
2402+
2403+
23332404
type ProgressToken = U2<int, string>
23342405

23352406
type WorkDoneProgressCreateParams =

tests/Benchmarks.fs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,7 @@ type MultipleTypesBenchmarks() =
402402
SymbolKind = Some { ValueSet = Some SymbolKindCapabilities.DefaultValueSet } }
403403
SemanticTokens = Some { RefreshSupport = Some true }
404404
InlayHint = Some { RefreshSupport = Some false }
405+
InlineValue = Some { RefreshSupport = Some false }
405406
CodeLens = Some { RefreshSupport = Some true } }
406407
TextDocument =
407408
Some

tests/Tests.fs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -843,6 +843,22 @@ let private serializationTests =
843843

844844
testThereAndBackAgain theInlayHint ]
845845

846+
testList
847+
(nameof InlineValue)
848+
[
849+
// Life of InlineValue:
850+
// * output of `textDocument/inlineValue` (`InlineValue[]`)
851+
// -> must be serializable as well as deserializable
852+
testCase "can roundtrip InlineValue with all fields (simple)"
853+
<| fun _ ->
854+
let theInlineValue: InlineValue =
855+
{ InlineValueText.Range = { Start = { Line = 5; Character = 7 }; End = { Line = 5; Character = 10 } }
856+
Text = "test" }
857+
|> InlineValue.InlineValueText
858+
859+
testThereAndBackAgain theInlineValue ]
860+
861+
846862
Shotgun.tests ]
847863

848864
[<Tests>]

0 commit comments

Comments
 (0)