From 566d90606cafb232333a0f35d78d3bc02f2f6521 Mon Sep 17 00:00:00 2001 From: Danny Tuppeny Date: Tue, 20 Jul 2021 11:15:02 +0100 Subject: [PATCH 1/4] Add textDocument/inlineValues This intends to mirror the equivalent VS Code feature: https://github.com/microsoft/vscode/blob/c980ea2307905fd1efeee38915bf1e5ccdff1754/src/vs/vscode.d.ts#L2677-L2852 --- _specifications/specification-3-17.md | 164 ++++++++++++++++++++++++++ 1 file changed, 164 insertions(+) diff --git a/_specifications/specification-3-17.md b/_specifications/specification-3-17.md index 27f724f94..51ab9dbcf 100644 --- a/_specifications/specification-3-17.md +++ b/_specifications/specification-3-17.md @@ -2044,6 +2044,11 @@ export interface TextDocumentClientCapabilities { * @since 3.16.0 */ moniker?: MonikerClientCapabilities; + + /** + * Capabilities specific to the `textDocument/inlineValues` request. + */ + inlineValues?: InlineValuesClientCapabilities; } ``` @@ -2486,6 +2491,11 @@ interface ServerCapabilities { */ monikerProvider?: boolean | MonikerOptions | MonikerRegistrationOptions; + /** + * The server provides inline values. + */ + inlineValuesProvider?: InlineValuesOptions; + /** * The server provides workspace symbol support. */ @@ -8891,6 +8901,159 @@ export interface Moniker { } ``` +#### Inline Values Request (:leftwards_arrow_with_hook:) + +> *Since version 3.17.0* + +The inline values request is sent from the client to the server to compute inline values for a given text document that may be rendered in the editor at the end of lines. + +_Client Capability_: +* property name (optional): `textDocument.inlineValues` +* property type: `InlineValuesClientCapabilities` defined as follows: + +
+ +```typescript +export interface InlineValuesClientCapabilities { + /** + * Whether inline values supports dynamic registration. + */ + dynamicRegistration?: boolean; +} +``` + +_Server Capability_: +* property name (optional): `inlineValuesProvider` +* property type: `InlineValuesOptions` defined as follows: + +
+ +```typescript +export interface InlineValuesOptions extends WorkDoneProgressOptions { +} +``` + +_Registration Options_: `InlineValuesRegistrationOptions` defined as follows: + +
+ +```typescript +export interface InlineValuesRegistrationOptions extends + TextDocumentRegistrationOptions, InlineValuesOptions { +} +``` + +_Request_: +* method: `textDocument/inlineValues` +* params: `InlineValuesParams` defined as follows: + +
+ +```typescript +interface InlineValuesParams extends WorkDoneProgressParams { + /** + * The document to request inline values for. + */ + readonly textDocument: TextDocumentIdentifier; + + /** + * The visible document range for which inline values should be computed. + */ + readonly viewPort: Range; + + /** + * Additional information about the context in which inline values were + * requested. + */ + readonly context: InlineValuesContext; +} +``` + +
+ +```typescript +interface InlineValuesContext { + /** + * The document range where execution has stopped. + * Typically the end position of the range denotes the line where the inline values are shown. + */ + readonly stoppedLocation: Range; +} +``` + +_Response_: +* result: `InlineValue[]` \| `null` defined as follows: + +
+ +```typescript +/** + * Inline value information can be provided by different means: + * - directly as a text value (class InlineValueText). + * - as a name to use for a variable lookup (class InlineValueVariableLookup) + * - as an evaluatable expression (class InlineValueEvaluatableExpression) + * The InlineValue types combines all inline value types into one type. + */ +export type InlineValue = InlineValueText | InlineValueVariableLookup | InlineValueEvaluatableExpression; + +/** + * Provide inline value as text. + */ +export class InlineValueText { + /** + * The document range for which the inline value applies. + */ + readonly range: Range; + + /** + * The text of the inline value. + */ + readonly text: string; +} + +/** + * Provide inline value through a variable lookup. + * If only a range is specified, the variable name will be extracted from the underlying document. + * An optional variable name can be used to override the extracted name. + */ +export class InlineValueVariableLookup { + /** + * The document range for which the inline value applies. + * The range is used to extract the variable name from the underlying document. + */ + readonly range: Range; + + /** + * If specified the name of the variable to look up. + */ + readonly variableName?: string; + + /** + * How to perform the lookup. + */ + readonly caseSensitiveLookup: boolean; +} + +/** + * Provide an inline value through an expression evaluation. + * If only a range is specified, the expression will be extracted from the underlying document. + * An optional expression can be used to override the extracted expression. + */ +export class InlineValueEvaluatableExpression { + /** + * The document range for which the inline value applies. + * The range is used to extract the evaluatable expression from the underlying document. + */ + readonly range: Range; + + /** + * If specified the expression overrides the extracted expression. + */ + readonly expression?: string; +} +``` +* error: code and message set in case an exception happens during the inline values request. + ##### Notes Server implementations of this method should ensure that the moniker calculation matches to those used in the corresponding LSIF implementation to ensure symbols can be associated correctly across IDE sessions and LSIF indexes. @@ -8918,6 +9081,7 @@ Servers usually support different communication channels (e.g. stdio, pipes, ... #### 3.17.0 (xx/xx/xxxx) * Add support for a completion item label details. +* Add support for `textDocument/inlineValues` request. #### 3.16.0 (12/14/2020) From 7ac75ff815324a6fb9e94b6f107cb35858fc885d Mon Sep 17 00:00:00 2001 From: Danny Tuppeny Date: Tue, 20 Jul 2021 15:47:28 +0100 Subject: [PATCH 2/4] Add inlineValues/refresh --- _specifications/specification-3-17.md | 52 +++++++++++++++++++++++++-- 1 file changed, 50 insertions(+), 2 deletions(-) diff --git a/_specifications/specification-3-17.md b/_specifications/specification-3-17.md index 51ab9dbcf..5c8a3b75e 100644 --- a/_specifications/specification-3-17.md +++ b/_specifications/specification-3-17.md @@ -2047,6 +2047,8 @@ export interface TextDocumentClientCapabilities { /** * Capabilities specific to the `textDocument/inlineValues` request. + * + * @since 3.17.0 */ inlineValues?: InlineValuesClientCapabilities; } @@ -2128,6 +2130,14 @@ interface ClientCapabilities { */ codeLens?: CodeLensWorkspaceClientCapabilities; + /** + * Capabilities specific to the inline values requests scoped to the + * workspace. + * + * @since 3.17.0 + */ + inlineValues?: InlineValuesWorkspaceClientCapabilities; + /** * The client has support for file requests/notifications. * @@ -8901,6 +8911,10 @@ export interface Moniker { } ``` +##### Notes + +Server implementations of this method should ensure that the moniker calculation matches to those used in the corresponding LSIF implementation to ensure symbols can be associated correctly across IDE sessions and LSIF indexes. + #### Inline Values Request (:leftwards_arrow_with_hook:) > *Since version 3.17.0* @@ -9054,9 +9068,43 @@ export class InlineValueEvaluatableExpression { ``` * error: code and message set in case an exception happens during the inline values request. -##### Notes +#### Inline Values Refresh Request (:arrow_right_hook:) -Server implementations of this method should ensure that the moniker calculation matches to those used in the corresponding LSIF implementation to ensure symbols can be associated correctly across IDE sessions and LSIF indexes. +> *Since version 3.17.0* + +The `workspace/inlineValues/refresh` request is sent from the server to the client. Servers can use it to ask clients to refresh the inline values currently shown in editors. As a result the client should ask the server to recompute the inline values for these editors. This is useful if a server detects a change which requires a re-calculation of all inline values. Note that the client still has the freedom to delay the re-calculation of the inline values if for example an editor is currently not visible. + +_Client Capability_: + +* property name (optional): `workspace.inlineValues` +* property type: `InlineValuesWorkspaceClientCapabilities` defined as follows: + +
+ +```typescript +export interface InlineValuesWorkspaceClientCapabilities { + /** + * Whether the client implementation supports a refresh request sent from the + * server to the client. + * + * Note that this event is global and will force the client to refresh all + * inline values currently shown. It should be used with absolute care and is + * useful for situation where a server for example detect a project wide + * change that requires such a calculation. + */ + refreshSupport?: boolean; +} +``` + +_Request_: + +* method: `workspace/inlineValues/refresh` +* params: none + +_Response_: + +* result: void +* error: code and message set in case an exception happens during the 'workspace/inlineValues/refresh' request ### Implementation Considerations From e22acef11daca049b0417540d1e08330592cfc10 Mon Sep 17 00:00:00 2001 From: Danny Tuppeny Date: Mon, 6 Sep 2021 15:09:59 +0100 Subject: [PATCH 3/4] Remove inlineValues/refresh --- _specifications/specification-3-17.md | 46 --------------------------- 1 file changed, 46 deletions(-) diff --git a/_specifications/specification-3-17.md b/_specifications/specification-3-17.md index 5c8a3b75e..0518cc764 100644 --- a/_specifications/specification-3-17.md +++ b/_specifications/specification-3-17.md @@ -2130,14 +2130,6 @@ interface ClientCapabilities { */ codeLens?: CodeLensWorkspaceClientCapabilities; - /** - * Capabilities specific to the inline values requests scoped to the - * workspace. - * - * @since 3.17.0 - */ - inlineValues?: InlineValuesWorkspaceClientCapabilities; - /** * The client has support for file requests/notifications. * @@ -9068,44 +9060,6 @@ export class InlineValueEvaluatableExpression { ``` * error: code and message set in case an exception happens during the inline values request. -#### Inline Values Refresh Request (:arrow_right_hook:) - -> *Since version 3.17.0* - -The `workspace/inlineValues/refresh` request is sent from the server to the client. Servers can use it to ask clients to refresh the inline values currently shown in editors. As a result the client should ask the server to recompute the inline values for these editors. This is useful if a server detects a change which requires a re-calculation of all inline values. Note that the client still has the freedom to delay the re-calculation of the inline values if for example an editor is currently not visible. - -_Client Capability_: - -* property name (optional): `workspace.inlineValues` -* property type: `InlineValuesWorkspaceClientCapabilities` defined as follows: - -
- -```typescript -export interface InlineValuesWorkspaceClientCapabilities { - /** - * Whether the client implementation supports a refresh request sent from the - * server to the client. - * - * Note that this event is global and will force the client to refresh all - * inline values currently shown. It should be used with absolute care and is - * useful for situation where a server for example detect a project wide - * change that requires such a calculation. - */ - refreshSupport?: boolean; -} -``` - -_Request_: - -* method: `workspace/inlineValues/refresh` -* params: none - -_Response_: - -* result: void -* error: code and message set in case an exception happens during the 'workspace/inlineValues/refresh' request - ### Implementation Considerations Language servers usually run in a separate process and client communicate with them in an asynchronous fashion. Additionally clients usually allow users to interact with the source code even if request results are pending. We recommend the following implementation pattern to avoid that clients apply outdated response results: From b8f5a033d0061623f0f703b5f231b1311d37395a Mon Sep 17 00:00:00 2001 From: Danny Tuppeny Date: Tue, 7 Sep 2021 11:05:23 +0100 Subject: [PATCH 4/4] Mark inline values as proposed --- _specifications/specification-3-17.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/_specifications/specification-3-17.md b/_specifications/specification-3-17.md index bbbcbdecf..e6a92eb39 100644 --- a/_specifications/specification-3-17.md +++ b/_specifications/specification-3-17.md @@ -2054,7 +2054,7 @@ export interface TextDocumentClientCapabilities { /** * Capabilities specific to the `textDocument/inlineValues` request. * - * @since 3.17.0 + * @since 3.17.0 - proposed state */ inlineValues?: InlineValuesClientCapabilities; } @@ -2501,6 +2501,8 @@ interface ServerCapabilities { /** * The server provides inline values. + * + * @since 3.17.0 - proposed state */ inlineValuesProvider?: InlineValuesOptions; @@ -8926,6 +8928,9 @@ _Client Capability_:
```typescript +/** + * Client capabilities specific to inline values. + */ export interface InlineValuesClientCapabilities { /** * Whether inline values supports dynamic registration. @@ -9091,7 +9096,7 @@ To support the case that the editor starting a server crashes an editor should a #### 3.17.0 (xx/xx/xxxx) * Add support for a completion item label details. -* Add support for `textDocument/inlineValues` request. +* Add support for `textDocument/inlineValues` request (proposed). #### 3.16.0 (12/14/2020)