-
Notifications
You must be signed in to change notification settings - Fork 862
Add support for textDocument/inlineValues #1318
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2050,6 +2050,13 @@ export interface TextDocumentClientCapabilities { | |
* @since 3.16.0 | ||
*/ | ||
moniker?: MonikerClientCapabilities; | ||
|
||
/** | ||
* Capabilities specific to the `textDocument/inlineValues` request. | ||
* | ||
* @since 3.17.0 - proposed state | ||
*/ | ||
inlineValues?: InlineValuesClientCapabilities; | ||
} | ||
``` | ||
|
||
|
@@ -2492,6 +2499,13 @@ interface ServerCapabilities { | |
*/ | ||
monikerProvider?: boolean | MonikerOptions | MonikerRegistrationOptions; | ||
|
||
/** | ||
* The server provides inline values. | ||
* | ||
* @since 3.17.0 - proposed state | ||
*/ | ||
inlineValuesProvider?: InlineValuesOptions; | ||
|
||
/** | ||
* The server provides workspace symbol support. | ||
*/ | ||
|
@@ -8901,6 +8915,162 @@ export interface Moniker { | |
|
||
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. | ||
|
||
#### <a href="#textDocument_inlineValues" name="textDocument_inlineValues" class="anchor">Inline Values Request (:leftwards_arrow_with_hook:)</a> | ||
|
||
> *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: | ||
|
||
<div class="anchorHolder"><a href="#inlineValuesClientCapabilities" name="inlineValuesClientCapabilities" class="linkableAnchor"></a></div> | ||
|
||
```typescript | ||
/** | ||
* Client capabilities specific to inline values. | ||
*/ | ||
export interface InlineValuesClientCapabilities { | ||
/** | ||
* Whether inline values supports dynamic registration. | ||
*/ | ||
dynamicRegistration?: boolean; | ||
} | ||
``` | ||
|
||
_Server Capability_: | ||
* property name (optional): `inlineValuesProvider` | ||
* property type: `InlineValuesOptions` defined as follows: | ||
|
||
<div class="anchorHolder"><a href="#inlineValuesOptions" name="inlineValuesOptions" class="linkableAnchor"></a></div> | ||
|
||
```typescript | ||
export interface InlineValuesOptions extends WorkDoneProgressOptions { | ||
} | ||
``` | ||
|
||
_Registration Options_: `InlineValuesRegistrationOptions` defined as follows: | ||
|
||
<div class="anchorHolder"><a href="#inlineValuesRegistrationOptions" name="inlineValuesRegistrationOptions" class="linkableAnchor"></a></div> | ||
|
||
```typescript | ||
export interface InlineValuesRegistrationOptions extends | ||
TextDocumentRegistrationOptions, InlineValuesOptions { | ||
} | ||
``` | ||
|
||
_Request_: | ||
* method: `textDocument/inlineValues` | ||
* params: `InlineValuesParams` defined as follows: | ||
|
||
<div class="anchorHolder"><a href="#inlineValuesParams" name="inlineValuesParams" class="linkableAnchor"></a></div> | ||
|
||
```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; | ||
} | ||
``` | ||
|
||
<div class="anchorHolder"><a href="#inlineValuesContext" name="inlineValuesContext" class="linkableAnchor"></a></div> | ||
|
||
```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: | ||
|
||
<div class="anchorHolder"><a href="#inlineValue" name="inlineValue" class="linkableAnchor"></a></div> | ||
|
||
```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) | ||
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. How would the expression be evaluated? It seems like a lot of this api relies on an execution context like a debugger? I could see this working with DAP but seems out of place in LSP |
||
* 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. | ||
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. What does ‘look up’ mean? Look up where? |
||
*/ | ||
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. | ||
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. What is 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. | ||
|
||
### <a href="#implementationConsiderations" name="implementationConsiderations" class="anchor">Implementation Considerations</a> | ||
|
||
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: | ||
|
@@ -8926,6 +9096,7 @@ To support the case that the editor starting a server crashes an editor should a | |
#### <a href="#version_3_17_0" name="version_3_17_0" class="anchor">3.17.0 (xx/xx/xxxx)</a> | ||
|
||
* Add support for a completion item label details. | ||
* Add support for `textDocument/inlineValues` request (proposed). | ||
|
||
#### <a href="#version_3_16_0" name="version_3_16_0" class="anchor">3.16.0 (12/14/2020)</a> | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did not understand this at all. What ‘execution’ is happening here?