mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
Merge from vscode 2f984aad710215f4e4684a035bb02f55d1a9e2cc (#9819)
This commit is contained in:
617
src/vs/vscode.proposed.d.ts
vendored
617
src/vs/vscode.proposed.d.ts
vendored
@@ -247,222 +247,6 @@ declare module 'vscode' {
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region Semantic tokens: https://github.com/microsoft/vscode/issues/86415
|
||||
|
||||
export class SemanticTokensLegend {
|
||||
public readonly tokenTypes: string[];
|
||||
public readonly tokenModifiers: string[];
|
||||
|
||||
constructor(tokenTypes: string[], tokenModifiers: string[]);
|
||||
}
|
||||
|
||||
export class SemanticTokensBuilder {
|
||||
constructor();
|
||||
push(line: number, char: number, length: number, tokenType: number, tokenModifiers: number): void;
|
||||
build(): Uint32Array;
|
||||
}
|
||||
|
||||
export class SemanticTokens {
|
||||
/**
|
||||
* The result id of the tokens.
|
||||
*
|
||||
* This is the id that will be passed to `DocumentSemanticTokensProvider.provideDocumentSemanticTokensEdits` (if implemented).
|
||||
*/
|
||||
readonly resultId?: string;
|
||||
readonly data: Uint32Array;
|
||||
|
||||
constructor(data: Uint32Array, resultId?: string);
|
||||
}
|
||||
|
||||
export class SemanticTokensEdits {
|
||||
/**
|
||||
* The result id of the tokens.
|
||||
*
|
||||
* This is the id that will be passed to `DocumentSemanticTokensProvider.provideDocumentSemanticTokensEdits` (if implemented).
|
||||
*/
|
||||
readonly resultId?: string;
|
||||
readonly edits: SemanticTokensEdit[];
|
||||
|
||||
constructor(edits: SemanticTokensEdit[], resultId?: string);
|
||||
}
|
||||
|
||||
export class SemanticTokensEdit {
|
||||
readonly start: number;
|
||||
readonly deleteCount: number;
|
||||
readonly data?: Uint32Array;
|
||||
|
||||
constructor(start: number, deleteCount: number, data?: Uint32Array);
|
||||
}
|
||||
|
||||
/**
|
||||
* The document semantic tokens provider interface defines the contract between extensions and
|
||||
* semantic tokens.
|
||||
*/
|
||||
export interface DocumentSemanticTokensProvider {
|
||||
/**
|
||||
* An optional event to signal that the semantic tokens from this provider have changed.
|
||||
*/
|
||||
onDidChangeSemanticTokens?: Event<void>;
|
||||
|
||||
/**
|
||||
* A file can contain many tokens, perhaps even hundreds of thousands of tokens. Therefore, to improve
|
||||
* the memory consumption around describing semantic tokens, we have decided to avoid allocating an object
|
||||
* for each token and we represent tokens from a file as an array of integers. Furthermore, the position
|
||||
* of each token is expressed relative to the token before it because most tokens remain stable relative to
|
||||
* each other when edits are made in a file.
|
||||
*
|
||||
* ---
|
||||
* In short, each token takes 5 integers to represent, so a specific token `i` in the file consists of the following array indices:
|
||||
* - at index `5*i` - `deltaLine`: token line number, relative to the previous token
|
||||
* - at index `5*i+1` - `deltaStart`: token start character, relative to the previous token (relative to 0 or the previous token's start if they are on the same line)
|
||||
* - at index `5*i+2` - `length`: the length of the token. A token cannot be multiline.
|
||||
* - at index `5*i+3` - `tokenType`: will be looked up in `SemanticTokensLegend.tokenTypes`. We currently ask that `tokenType` < 65536.
|
||||
* - at index `5*i+4` - `tokenModifiers`: each set bit will be looked up in `SemanticTokensLegend.tokenModifiers`
|
||||
*
|
||||
* ---
|
||||
* ### How to encode tokens
|
||||
*
|
||||
* Here is an example for encoding a file with 3 tokens in a uint32 array:
|
||||
* ```
|
||||
* { line: 2, startChar: 5, length: 3, tokenType: "property", tokenModifiers: ["private", "static"] },
|
||||
* { line: 2, startChar: 10, length: 4, tokenType: "type", tokenModifiers: [] },
|
||||
* { line: 5, startChar: 2, length: 7, tokenType: "class", tokenModifiers: [] }
|
||||
* ```
|
||||
*
|
||||
* 1. First of all, a legend must be devised. This legend must be provided up-front and capture all possible token types.
|
||||
* For this example, we will choose the following legend which must be passed in when registering the provider:
|
||||
* ```
|
||||
* tokenTypes: ['property', 'type', 'class'],
|
||||
* tokenModifiers: ['private', 'static']
|
||||
* ```
|
||||
*
|
||||
* 2. The first transformation step is to encode `tokenType` and `tokenModifiers` as integers using the legend. Token types are looked
|
||||
* up by index, so a `tokenType` value of `1` means `tokenTypes[1]`. Multiple token modifiers can be set by using bit flags,
|
||||
* so a `tokenModifier` value of `3` is first viewed as binary `0b00000011`, which means `[tokenModifiers[0], tokenModifiers[1]]` because
|
||||
* bits 0 and 1 are set. Using this legend, the tokens now are:
|
||||
* ```
|
||||
* { line: 2, startChar: 5, length: 3, tokenType: 0, tokenModifiers: 3 },
|
||||
* { line: 2, startChar: 10, length: 4, tokenType: 1, tokenModifiers: 0 },
|
||||
* { line: 5, startChar: 2, length: 7, tokenType: 2, tokenModifiers: 0 }
|
||||
* ```
|
||||
*
|
||||
* 3. The next step is to represent each token relative to the previous token in the file. In this case, the second token
|
||||
* is on the same line as the first token, so the `startChar` of the second token is made relative to the `startChar`
|
||||
* of the first token, so it will be `10 - 5`. The third token is on a different line than the second token, so the
|
||||
* `startChar` of the third token will not be altered:
|
||||
* ```
|
||||
* { deltaLine: 2, deltaStartChar: 5, length: 3, tokenType: 0, tokenModifiers: 3 },
|
||||
* { deltaLine: 0, deltaStartChar: 5, length: 4, tokenType: 1, tokenModifiers: 0 },
|
||||
* { deltaLine: 3, deltaStartChar: 2, length: 7, tokenType: 2, tokenModifiers: 0 }
|
||||
* ```
|
||||
*
|
||||
* 4. Finally, the last step is to inline each of the 5 fields for a token in a single array, which is a memory friendly representation:
|
||||
* ```
|
||||
* // 1st token, 2nd token, 3rd token
|
||||
* [ 2,5,3,0,3, 0,5,4,1,0, 3,2,7,2,0 ]
|
||||
* ```
|
||||
*
|
||||
* *NOTE*: When doing edits, it is possible that multiple edits occur until VS Code decides to invoke the semantic tokens provider.
|
||||
* *NOTE*: If the provider cannot temporarily compute semantic tokens, it can indicate this by throwing an error with the message 'Busy'.
|
||||
*/
|
||||
provideDocumentSemanticTokens(document: TextDocument, token: CancellationToken): ProviderResult<SemanticTokens>;
|
||||
|
||||
/**
|
||||
* Instead of always returning all the tokens in a file, it is possible for a `DocumentSemanticTokensProvider` to implement
|
||||
* this method (`updateSemanticTokens`) and then return incremental updates to the previously provided semantic tokens.
|
||||
*
|
||||
* ---
|
||||
* ### How tokens change when the document changes
|
||||
*
|
||||
* Let's look at how tokens might change.
|
||||
*
|
||||
* Continuing with the above example, suppose a new line was inserted at the top of the file.
|
||||
* That would make all the tokens move down by one line (notice how the line has changed for each one):
|
||||
* ```
|
||||
* { line: 3, startChar: 5, length: 3, tokenType: "property", tokenModifiers: ["private", "static"] },
|
||||
* { line: 3, startChar: 10, length: 4, tokenType: "type", tokenModifiers: [] },
|
||||
* { line: 6, startChar: 2, length: 7, tokenType: "class", tokenModifiers: [] }
|
||||
* ```
|
||||
* The integer encoding of the tokens does not change substantially because of the delta-encoding of positions:
|
||||
* ```
|
||||
* // 1st token, 2nd token, 3rd token
|
||||
* [ 3,5,3,0,3, 0,5,4,1,0, 3,2,7,2,0 ]
|
||||
* ```
|
||||
* It is possible to express these new tokens in terms of an edit applied to the previous tokens:
|
||||
* ```
|
||||
* [ 2,5,3,0,3, 0,5,4,1,0, 3,2,7,2,0 ] // old tokens
|
||||
* [ 3,5,3,0,3, 0,5,4,1,0, 3,2,7,2,0 ] // new tokens
|
||||
*
|
||||
* edit: { start: 0, deleteCount: 1, data: [3] } // replace integer at offset 0 with 3
|
||||
* ```
|
||||
*
|
||||
* Furthermore, let's assume that a new token has appeared on line 4:
|
||||
* ```
|
||||
* { line: 3, startChar: 5, length: 3, tokenType: "property", tokenModifiers: ["private", "static"] },
|
||||
* { line: 3, startChar: 10, length: 4, tokenType: "type", tokenModifiers: [] },
|
||||
* { line: 4, startChar: 3, length: 5, tokenType: "property", tokenModifiers: ["static"] },
|
||||
* { line: 6, startChar: 2, length: 7, tokenType: "class", tokenModifiers: [] }
|
||||
* ```
|
||||
* The integer encoding of the tokens is:
|
||||
* ```
|
||||
* // 1st token, 2nd token, 3rd token, 4th token
|
||||
* [ 3,5,3,0,3, 0,5,4,1,0, 1,3,5,0,2, 2,2,7,2,0, ]
|
||||
* ```
|
||||
* Again, it is possible to express these new tokens in terms of an edit applied to the previous tokens:
|
||||
* ```
|
||||
* [ 3,5,3,0,3, 0,5,4,1,0, 3,2,7,2,0 ] // old tokens
|
||||
* [ 3,5,3,0,3, 0,5,4,1,0, 1,3,5,0,2, 2,2,7,2,0, ] // new tokens
|
||||
*
|
||||
* edit: { start: 10, deleteCount: 1, data: [1,3,5,0,2,2] } // replace integer at offset 10 with [1,3,5,0,2,2]
|
||||
* ```
|
||||
*
|
||||
* *NOTE*: If the provider cannot compute `SemanticTokensEdits`, it can "give up" and return all the tokens in the document again.
|
||||
* *NOTE*: All edits in `SemanticTokensEdits` contain indices in the old integers array, so they all refer to the previous result state.
|
||||
*/
|
||||
provideDocumentSemanticTokensEdits?(document: TextDocument, previousResultId: string, token: CancellationToken): ProviderResult<SemanticTokens | SemanticTokensEdits>;
|
||||
}
|
||||
|
||||
/**
|
||||
* The document range semantic tokens provider interface defines the contract between extensions and
|
||||
* semantic tokens.
|
||||
*/
|
||||
export interface DocumentRangeSemanticTokensProvider {
|
||||
/**
|
||||
* See [provideDocumentSemanticTokens](#DocumentSemanticTokensProvider.provideDocumentSemanticTokens).
|
||||
*/
|
||||
provideDocumentRangeSemanticTokens(document: TextDocument, range: Range, token: CancellationToken): ProviderResult<SemanticTokens>;
|
||||
}
|
||||
|
||||
export namespace languages {
|
||||
/**
|
||||
* Register a semantic tokens provider for a whole document.
|
||||
*
|
||||
* Multiple providers can be registered for a language. In that case providers are sorted
|
||||
* by their [score](#languages.match) and the best-matching provider is used. Failure
|
||||
* of the selected provider will cause a failure of the whole operation.
|
||||
*
|
||||
* @param selector A selector that defines the documents this provider is applicable to.
|
||||
* @param provider A document semantic tokens provider.
|
||||
* @return A [disposable](#Disposable) that unregisters this provider when being disposed.
|
||||
*/
|
||||
export function registerDocumentSemanticTokensProvider(selector: DocumentSelector, provider: DocumentSemanticTokensProvider, legend: SemanticTokensLegend): Disposable;
|
||||
|
||||
/**
|
||||
* Register a semantic tokens provider for a document range.
|
||||
*
|
||||
* Multiple providers can be registered for a language. In that case providers are sorted
|
||||
* by their [score](#languages.match) and the best-matching provider is used. Failure
|
||||
* of the selected provider will cause a failure of the whole operation.
|
||||
*
|
||||
* @param selector A selector that defines the documents this provider is applicable to.
|
||||
* @param provider A document range semantic tokens provider.
|
||||
* @return A [disposable](#Disposable) that unregisters this provider when being disposed.
|
||||
*/
|
||||
export function registerDocumentRangeSemanticTokensProvider(selector: DocumentSelector, provider: DocumentRangeSemanticTokensProvider, legend: SemanticTokensLegend): Disposable;
|
||||
}
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region editor insets: https://github.com/microsoft/vscode/issues/85682
|
||||
|
||||
export interface WebviewEditorInset {
|
||||
@@ -945,7 +729,7 @@ declare module 'vscode' {
|
||||
//#region LogLevel: https://github.com/microsoft/vscode/issues/85992
|
||||
|
||||
/**
|
||||
* The severity level of a log message
|
||||
* @deprecated DO NOT USE, will be removed
|
||||
*/
|
||||
export enum LogLevel {
|
||||
Trace = 1,
|
||||
@@ -959,12 +743,12 @@ declare module 'vscode' {
|
||||
|
||||
export namespace env {
|
||||
/**
|
||||
* Current logging level.
|
||||
* @deprecated DO NOT USE, will be removed
|
||||
*/
|
||||
export const logLevel: LogLevel;
|
||||
|
||||
/**
|
||||
* An [event](#Event) that fires when the log level has changed.
|
||||
* @deprecated DO NOT USE, will be removed
|
||||
*/
|
||||
export const onDidChangeLogLevel: Event<LogLevel>;
|
||||
}
|
||||
@@ -1125,7 +909,7 @@ declare module 'vscode' {
|
||||
/**
|
||||
* Handles a link that is activated within the terminal.
|
||||
*
|
||||
* @return Whether the link was handled, the link was handled this link will not be
|
||||
* @return Whether the link was handled, if the link was handled this link will not be
|
||||
* considered by any other extension or by the default built-in link handler.
|
||||
*/
|
||||
handleLink(terminal: Terminal, link: string): ProviderResult<boolean>;
|
||||
@@ -1398,288 +1182,14 @@ declare module 'vscode' {
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region Custom editors: https://github.com/microsoft/vscode/issues/77131
|
||||
//#region Custom editor move https://github.com/microsoft/vscode/issues/86146
|
||||
|
||||
/**
|
||||
* Defines the editing capability of a custom webview editor. This allows the webview editor to hook into standard
|
||||
* editor events such as `undo` or `save`.
|
||||
*
|
||||
* @param EditType Type of edits used for the documents this delegate handles.
|
||||
*/
|
||||
interface CustomEditorEditingDelegate<EditType = unknown> {
|
||||
/**
|
||||
* Save the resource.
|
||||
*
|
||||
* @param document Document to save.
|
||||
* @param cancellation Token that signals the save is no longer required (for example, if another save was triggered).
|
||||
*
|
||||
* @return Thenable signaling that the save has completed.
|
||||
*/
|
||||
save(document: CustomDocument<EditType>, cancellation: CancellationToken): Thenable<void>;
|
||||
// TODO: Also for custom editor
|
||||
|
||||
/**
|
||||
* Save the existing resource at a new path.
|
||||
*
|
||||
* @param document Document to save.
|
||||
* @param targetResource Location to save to.
|
||||
*
|
||||
* @return Thenable signaling that the save has completed.
|
||||
*/
|
||||
saveAs(document: CustomDocument<EditType>, targetResource: Uri): Thenable<void>;
|
||||
|
||||
/**
|
||||
* Event triggered by extensions to signal to VS Code that an edit has occurred.
|
||||
*/
|
||||
readonly onDidEdit: Event<CustomDocumentEditEvent<EditType>>;
|
||||
|
||||
/**
|
||||
* Apply a set of edits.
|
||||
*
|
||||
* Note that is not invoked when `onDidEdit` is called because `onDidEdit` implies also updating the view to reflect the edit.
|
||||
*
|
||||
* @param document Document to apply edits to.
|
||||
* @param edit Array of edits. Sorted from oldest to most recent.
|
||||
*
|
||||
* @return Thenable signaling that the change has completed.
|
||||
*/
|
||||
applyEdits(document: CustomDocument<EditType>, edits: readonly EditType[]): Thenable<void>;
|
||||
|
||||
/**
|
||||
* Undo a set of edits.
|
||||
*
|
||||
* This is triggered when a user undoes an edit.
|
||||
*
|
||||
* @param document Document to undo edits from.
|
||||
* @param edit Array of edits. Sorted from most recent to oldest.
|
||||
*
|
||||
* @return Thenable signaling that the change has completed.
|
||||
*/
|
||||
undoEdits(document: CustomDocument<EditType>, edits: readonly EditType[]): Thenable<void>;
|
||||
|
||||
/**
|
||||
* Revert the file to its last saved state.
|
||||
*
|
||||
* @param document Document to revert.
|
||||
* @param edits Added or applied edits.
|
||||
*
|
||||
* @return Thenable signaling that the change has completed.
|
||||
*/
|
||||
revert(document: CustomDocument<EditType>, edits: CustomDocumentRevert<EditType>): Thenable<void>;
|
||||
|
||||
/**
|
||||
* Back up the resource in its current state.
|
||||
*
|
||||
* Backups are used for hot exit and to prevent data loss. Your `backup` method should persist the resource in
|
||||
* its current state, i.e. with the edits applied. Most commonly this means saving the resource to disk in
|
||||
* the `ExtensionContext.storagePath`. When VS Code reloads and your custom editor is opened for a resource,
|
||||
* your extension should first check to see if any backups exist for the resource. If there is a backup, your
|
||||
* extension should load the file contents from there instead of from the resource in the workspace.
|
||||
*
|
||||
* `backup` is triggered whenever an edit it made. Calls to `backup` are debounced so that if multiple edits are
|
||||
* made in quick succession, `backup` is only triggered after the last one. `backup` is not invoked when
|
||||
* `auto save` is enabled (since auto save already persists resource ).
|
||||
*
|
||||
* @param document Document to revert.
|
||||
* @param cancellation Token that signals the current backup since a new backup is coming in. It is up to your
|
||||
* extension to decided how to respond to cancellation. If for example your extension is backing up a large file
|
||||
* in an operation that takes time to complete, your extension may decide to finish the ongoing backup rather
|
||||
* than cancelling it to ensure that VS Code has some valid backup.
|
||||
*/
|
||||
backup(document: CustomDocument<EditType>, cancellation: CancellationToken): Thenable<void>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Event triggered by extensions to signal to VS Code that an edit has occurred on a `CustomDocument`.
|
||||
*
|
||||
* @param EditType Type of edits used for the document.
|
||||
*/
|
||||
interface CustomDocumentEditEvent<EditType = unknown> {
|
||||
/**
|
||||
* Document the edit is for.
|
||||
*/
|
||||
readonly document: CustomDocument<EditType>;
|
||||
|
||||
/**
|
||||
* Object that describes the edit.
|
||||
*
|
||||
* Edit objects are passed back to your extension in `CustomEditorEditingDelegate.undoEdits`,
|
||||
* `CustomEditorEditingDelegate.applyEdits`, and `CustomEditorEditingDelegate.revert`.
|
||||
*/
|
||||
readonly edit: EditType;
|
||||
|
||||
/**
|
||||
* Display name describing the edit.
|
||||
*/
|
||||
readonly label?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Data about a revert for a `CustomDocument`.
|
||||
*/
|
||||
interface CustomDocumentRevert<EditType = unknown> {
|
||||
/**
|
||||
* List of edits that were undone to get the document back to its on disk state.
|
||||
*/
|
||||
readonly undoneEdits: readonly EditType[];
|
||||
|
||||
/**
|
||||
* List of edits that were reapplied to get the document back to its on disk state.
|
||||
*/
|
||||
readonly appliedEdits: readonly EditType[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a custom document used by a `CustomEditorProvider`.
|
||||
*
|
||||
* All custom documents must subclass `CustomDocument`. Custom documents are only used within a given
|
||||
* `CustomEditorProvider`. The lifecycle of a `CustomDocument` is managed by VS Code. When no more references
|
||||
* remain to a `CustomDocument`, it is disposed of.
|
||||
*
|
||||
* @param EditType Type of edits used in this document.
|
||||
*/
|
||||
class CustomDocument<EditType = unknown> {
|
||||
/**
|
||||
* @param viewType The associated uri for this document.
|
||||
* @param uri The associated viewType for this document.
|
||||
*/
|
||||
constructor(viewType: string, uri: Uri);
|
||||
|
||||
/**
|
||||
* The associated viewType for this document.
|
||||
*/
|
||||
readonly viewType: string;
|
||||
|
||||
/**
|
||||
* The associated uri for this document.
|
||||
*/
|
||||
readonly uri: Uri;
|
||||
|
||||
/**
|
||||
* Is this document representing an untitled file which has never been saved yet.
|
||||
*/
|
||||
readonly isUntitled: boolean;
|
||||
|
||||
/**
|
||||
* The version number of this document (it will strictly increase after each
|
||||
* change, including undo/redo).
|
||||
*/
|
||||
readonly version: number;
|
||||
|
||||
/**
|
||||
* `true` if there are unpersisted changes.
|
||||
*/
|
||||
readonly isDirty: boolean;
|
||||
|
||||
/**
|
||||
* List of edits from document open to the document's current state.
|
||||
*/
|
||||
readonly appliedEdits: ReadonlyArray<EditType>;
|
||||
|
||||
/**
|
||||
* List of edits from document open to the document's last saved point.
|
||||
*
|
||||
* The save point will be behind `appliedEdits` if the user saves and then continues editing,
|
||||
* or in front of the last entry in `appliedEdits` if the user saves and then hits undo.
|
||||
*/
|
||||
readonly savedEdits: ReadonlyArray<EditType>;
|
||||
|
||||
/**
|
||||
* `true` if the document has been closed. A closed document isn't synchronized anymore
|
||||
* and won't be re-used when the same resource is opened again.
|
||||
*/
|
||||
readonly isClosed: boolean;
|
||||
|
||||
/**
|
||||
* Event fired when there are no more references to the `CustomDocument`.
|
||||
*/
|
||||
readonly onDidDispose: Event<void>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provider for webview editors that use a custom data model.
|
||||
*
|
||||
* Custom webview editors use [`CustomDocument`](#CustomDocument) as their data model.
|
||||
* This gives extensions full control over actions such as edit, save, and backup.
|
||||
*
|
||||
* You should use custom text based editors when dealing with binary files or more complex scenarios. For simple text
|
||||
* based documents, use [`WebviewTextEditorProvider`](#WebviewTextEditorProvider) instead.
|
||||
*/
|
||||
export interface CustomEditorProvider<EditType = unknown> {
|
||||
|
||||
/**
|
||||
* Resolve the model for a given resource.
|
||||
*
|
||||
* `resolveCustomDocument` is called when the first editor for a given resource is opened, and the resolve document
|
||||
* is passed to `resolveCustomEditor`. The resolved `CustomDocument` is re-used for subsequent editor opens.
|
||||
* If all editors for a given resource are closed, the `CustomDocument` is disposed of. Opening an editor at
|
||||
* this point will trigger another call to `resolveCustomDocument`.
|
||||
*
|
||||
* @param uri Uri of the document to open.
|
||||
* @param token A cancellation token that indicates the result is no longer needed.
|
||||
*
|
||||
* @return The custom document.
|
||||
*/
|
||||
openCustomDocument(uri: Uri, token: CancellationToken): Thenable<CustomDocument<EditType>>;
|
||||
|
||||
/**
|
||||
* Resolve a webview editor for a given resource.
|
||||
*
|
||||
* This is called when a user first opens a resource for a `CustomEditorProvider`, or if they reopen an
|
||||
* existing editor using this `CustomEditorProvider`.
|
||||
*
|
||||
* To resolve a webview editor, the provider must fill in its initial html content and hook up all
|
||||
* the event listeners it is interested it. The provider can also hold onto the `WebviewPanel` to use later,
|
||||
* for example in a command. See [`WebviewPanel`](#WebviewPanel) for additional details
|
||||
*
|
||||
* @param document Document for the resource being resolved.
|
||||
* @param webviewPanel Webview to resolve.
|
||||
* @param token A cancellation token that indicates the result is no longer needed.
|
||||
*
|
||||
* @return Thenable indicating that the webview editor has been resolved.
|
||||
*/
|
||||
resolveCustomEditor(document: CustomDocument<EditType>, webviewPanel: WebviewPanel, token: CancellationToken): Thenable<void>;
|
||||
|
||||
/**
|
||||
* Defines the editing capability of a custom webview document.
|
||||
*
|
||||
* When not provided, the document is considered readonly.
|
||||
*/
|
||||
readonly editingDelegate?: CustomEditorEditingDelegate<EditType>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provider for text based webview editors.
|
||||
*
|
||||
* Text based webview editors use a [`TextDocument`](#TextDocument) as their data model. This considerably simplifies
|
||||
* implementing a webview editor as it allows VS Code to handle many common operations such as
|
||||
* undo and backup. The provider is responsible for synchronizing text changes between the webview and the `TextDocument`.
|
||||
*
|
||||
* You should use text based webview editors when dealing with text based file formats, such as `xml` or `json`.
|
||||
* For binary files or more specialized use cases, see [CustomEditorProvider](#CustomEditorProvider).
|
||||
*/
|
||||
export interface CustomTextEditorProvider {
|
||||
|
||||
/**
|
||||
* Resolve a webview editor for a given text resource.
|
||||
*
|
||||
* This is called when a user first opens a resource for a `CustomTextEditorProvider`, or if they reopen an
|
||||
* existing editor using this `CustomTextEditorProvider`.
|
||||
*
|
||||
* To resolve a webview editor, the provider must fill in its initial html content and hook up all
|
||||
* the event listeners it is interested it. The provider can also hold onto the `WebviewPanel` to use later,
|
||||
* for example in a command. See [`WebviewPanel`](#WebviewPanel) for additional details.
|
||||
*
|
||||
* @param document Document for the resource to resolve.
|
||||
* @param webviewPanel Webview to resolve.
|
||||
* @param token A cancellation token that indicates the result is no longer needed.
|
||||
*
|
||||
* @return Thenable indicating that the webview editor has been resolved.
|
||||
*/
|
||||
resolveCustomTextEditor(document: TextDocument, webviewPanel: WebviewPanel, token: CancellationToken): Thenable<void>;
|
||||
|
||||
/**
|
||||
* TODO: discuss this at api sync.
|
||||
*
|
||||
* Handle when the underlying resource for a custom editor is renamed.
|
||||
*
|
||||
* This allows the webview for the editor be preserved throughout the rename. If this method is not implemented,
|
||||
@@ -1694,26 +1204,6 @@ declare module 'vscode' {
|
||||
moveCustomTextEditor?(newDocument: TextDocument, existingWebviewPanel: WebviewPanel, token: CancellationToken): Thenable<void>;
|
||||
}
|
||||
|
||||
namespace window {
|
||||
/**
|
||||
* Register a new provider for a custom editor.
|
||||
*
|
||||
* @param viewType Type of the webview editor provider. This should match the `viewType` from the
|
||||
* `package.json` contributions.
|
||||
* @param provider Provider that resolves editors.
|
||||
* @param options Options for the provider
|
||||
*
|
||||
* @return Disposable that unregisters the provider.
|
||||
*/
|
||||
export function registerCustomEditorProvider(
|
||||
viewType: string,
|
||||
provider: CustomEditorProvider | CustomTextEditorProvider,
|
||||
options?: {
|
||||
readonly webviewOptions?: WebviewPanelOptions;
|
||||
}
|
||||
): Disposable;
|
||||
}
|
||||
|
||||
//#endregion
|
||||
|
||||
|
||||
@@ -1811,7 +1301,7 @@ declare module 'vscode' {
|
||||
runnable?: boolean;
|
||||
|
||||
/**
|
||||
* Execution order information of the cell
|
||||
* The order in which this cell was executed.
|
||||
*/
|
||||
executionOrder?: number;
|
||||
}
|
||||
@@ -1828,22 +1318,27 @@ declare module 'vscode' {
|
||||
export interface NotebookDocumentMetadata {
|
||||
/**
|
||||
* Controls if users can add or delete cells
|
||||
* Default to true
|
||||
* Defaults to true
|
||||
*/
|
||||
editable: boolean;
|
||||
editable?: boolean;
|
||||
|
||||
/**
|
||||
* Default value for [cell editable metadata](#NotebookCellMetadata.editable).
|
||||
* Default to true.
|
||||
* Defaults to true.
|
||||
*/
|
||||
cellEditable: boolean;
|
||||
cellEditable?: boolean;
|
||||
|
||||
/**
|
||||
* Default value for [cell runnable metadata](#NotebookCellMetadata.runnable).
|
||||
* Default to true.
|
||||
* Defaults to true.
|
||||
*/
|
||||
cellRunnable: boolean;
|
||||
cellRunnable?: boolean;
|
||||
|
||||
/**
|
||||
* Whether the [execution order](#NotebookCellMetadata.executionOrder) indicator will be displayed.
|
||||
* Defaults to true.
|
||||
*/
|
||||
hasExecutionOrder?: boolean;
|
||||
}
|
||||
|
||||
export interface NotebookDocument {
|
||||
@@ -1853,7 +1348,7 @@ declare module 'vscode' {
|
||||
readonly cells: NotebookCell[];
|
||||
languages: string[];
|
||||
displayOrder?: GlobPattern[];
|
||||
metadata?: NotebookDocumentMetadata;
|
||||
metadata: NotebookDocumentMetadata;
|
||||
}
|
||||
|
||||
export interface NotebookEditorCellEdit {
|
||||
@@ -1882,7 +1377,7 @@ declare module 'vscode' {
|
||||
|
||||
export interface NotebookProvider {
|
||||
resolveNotebook(editor: NotebookEditor): Promise<void>;
|
||||
executeCell(document: NotebookDocument, cell: NotebookCell | undefined): Promise<void>;
|
||||
executeCell(document: NotebookDocument, cell: NotebookCell | undefined, token: CancellationToken): Promise<void>;
|
||||
save(document: NotebookDocument): Promise<boolean>;
|
||||
}
|
||||
|
||||
@@ -2155,41 +1650,6 @@ declare module 'vscode' {
|
||||
|
||||
//#endregion
|
||||
|
||||
|
||||
//#region https://github.com/microsoft/vscode/issues/90208
|
||||
|
||||
export interface ExtensionContext {
|
||||
/**
|
||||
* Get the uri of a resource contained in the extension.
|
||||
*
|
||||
* @param relativePath A relative path to a resource contained in the extension.
|
||||
* @return The uri of the resource.
|
||||
*/
|
||||
asExtensionUri(relativePath: string): Uri;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
readonly extensionUri: Uri;
|
||||
}
|
||||
|
||||
export interface Extension<T> {
|
||||
/**
|
||||
* Get the uri of a resource contained in the extension.
|
||||
*
|
||||
* @param relativePath A relative path to a resource contained in the extension.
|
||||
* @return The uri of the resource.
|
||||
*/
|
||||
asExtensionUri(relativePath: string): Uri;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
readonly extensionUri: Uri;
|
||||
}
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region https://github.com/microsoft/vscode/issues/86788
|
||||
|
||||
export interface CodeActionProviderMetadata {
|
||||
@@ -2247,13 +1707,44 @@ declare module 'vscode' {
|
||||
|
||||
//#region https://github.com/microsoft/vscode/issues/90208
|
||||
|
||||
export interface ExtensionContext {
|
||||
/**
|
||||
* @deprecated THIS API PROPOSAL WILL BE DROPPED
|
||||
*/
|
||||
asExtensionUri(relativePath: string): Uri;
|
||||
|
||||
/**
|
||||
* The uri of the directory containing the extension.
|
||||
*/
|
||||
readonly extensionUri: Uri;
|
||||
}
|
||||
|
||||
export interface Extension<T> {
|
||||
/**
|
||||
* @deprecated THIS API PROPOSAL WILL BE DROPPED
|
||||
*/
|
||||
asExtensionUri(relativePath: string): Uri;
|
||||
|
||||
/**
|
||||
* The uri of the directory containing the extension.
|
||||
*/
|
||||
readonly extensionUri: Uri;
|
||||
}
|
||||
|
||||
export namespace Uri {
|
||||
|
||||
/**
|
||||
* Create a new uri which path is the result of joining
|
||||
* the path of the base uri with the provided path fragments.
|
||||
*
|
||||
* @param base
|
||||
* @param pathFragments
|
||||
* @returns A new uri
|
||||
* * Note that `joinPath` only affects the path component
|
||||
* and all other components (scheme, authority, query, and fragment) are
|
||||
* left as they are.
|
||||
* * Note that the base uri must have a path; an error is thrown otherwise.
|
||||
*
|
||||
* @param base An uri. Must have a path.
|
||||
* @param pathFragments One more more path fragments
|
||||
* @returns A new uri which path is joined with the given fragments
|
||||
*/
|
||||
export function joinPath(base: Uri, ...pathFragments: string[]): Uri;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user