Merge from vscode 6fded8a497cd0142de3a1c607649a5423a091a25

This commit is contained in:
ADS Merger
2020-04-04 04:30:52 +00:00
parent 00cc0074f7
commit 35f1a014d5
184 changed files with 3043 additions and 2285 deletions

343
src/vs/vscode.d.ts vendored
View File

@@ -3164,7 +3164,7 @@ declare module 'vscode' {
*/
public readonly tokenModifiers: string[];
constructor(tokenTypes: string[], tokenModifiers: string[]);
constructor(tokenTypes: string[], tokenModifiers?: string[]);
}
/**
@@ -3184,7 +3184,7 @@ declare module 'vscode' {
* @param tokenType The encoded token type.
* @param tokenModifiers The encoded token modifiers.
*/
push(line: number, char: number, length: number, tokenType: number, tokenModifiers: number): void;
push(line: number, char: number, length: number, tokenType: number, tokenModifiers?: number): void;
/**
* Add another token. Use only when providing a legend.
@@ -3203,8 +3203,8 @@ declare module 'vscode' {
/**
* Represents semantic tokens, either in a range or in an entire document.
* See [provideDocumentSemanticTokens](#DocumentSemanticTokensProvider.provideDocumentSemanticTokens) for an explanation of the format.
* See `SemanticTokensBuilder` for a helper to create an instance.
* @see [provideDocumentSemanticTokens](#DocumentSemanticTokensProvider.provideDocumentSemanticTokens) for an explanation of the format.
* @see [SemanticTokensBuilder](#SemanticTokensBuilder) for a helper to create an instance.
*/
export class SemanticTokens {
/**
@@ -3215,7 +3215,7 @@ declare module 'vscode' {
readonly resultId?: string;
/**
* The actual tokens data.
* See [provideDocumentSemanticTokens](#DocumentSemanticTokensProvider.provideDocumentSemanticTokens) for an explanation of the format.
* @see [provideDocumentSemanticTokens](#DocumentSemanticTokensProvider.provideDocumentSemanticTokens) for an explanation of the format.
*/
readonly data: Uint32Array;
@@ -3224,7 +3224,7 @@ declare module 'vscode' {
/**
* Represents edits to semantic tokens.
* See [provideDocumentSemanticTokensEdits](#DocumentSemanticTokensProvider.provideDocumentSemanticTokensEdits) for an explanation of the format.
* @see [provideDocumentSemanticTokensEdits](#DocumentSemanticTokensProvider.provideDocumentSemanticTokensEdits) for an explanation of the format.
*/
export class SemanticTokensEdits {
/**
@@ -3244,7 +3244,7 @@ declare module 'vscode' {
/**
* Represents an edit to semantic tokens.
* See [provideDocumentSemanticTokensEdits](#DocumentSemanticTokensProvider.provideDocumentSemanticTokensEdits) for an explanation of the format.
* @see [provideDocumentSemanticTokensEdits](#DocumentSemanticTokensProvider.provideDocumentSemanticTokensEdits) for an explanation of the format.
*/
export class SemanticTokensEdit {
/**
@@ -3274,11 +3274,8 @@ declare module 'vscode' {
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.
* Tokens in a file are represented as an array of integers. 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:
@@ -3331,6 +3328,7 @@ declare module 'vscode' {
* [ 2,5,3,0,3, 0,5,4,1,0, 3,2,7,2,0 ]
* ```
*
* @see [SemanticTokensBuilder](#SemanticTokensBuilder) for a helper to encode tokens as integers.
* *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'.
*/
@@ -3338,21 +3336,18 @@ declare module 'vscode' {
/**
* 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.
* this method (`provideDocumentSemanticTokensEdits`) 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.
* Suppose that `provideDocumentSemanticTokens` has previously returned the following semantic tokens:
* ```
* // 1st token, 2nd token, 3rd token
* [ 2,5,3,0,3, 0,5,4,1,0, 3,2,7,2,0 ]
* ```
*
* 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:
* Also suppose that after some edits, the new semantic tokens in a file are:
* ```
* // 1st token, 2nd token, 3rd token
* [ 3,5,3,0,3, 0,5,4,1,0, 3,2,7,2,0 ]
@@ -3365,26 +3360,6 @@ declare module 'vscode' {
* 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.
*/
@@ -3397,7 +3372,7 @@ declare module 'vscode' {
*/
export interface DocumentRangeSemanticTokensProvider {
/**
* See [provideDocumentSemanticTokens](#DocumentSemanticTokensProvider.provideDocumentSemanticTokens).
* @see [provideDocumentSemanticTokens](#DocumentSemanticTokensProvider.provideDocumentSemanticTokens).
*/
provideDocumentRangeSemanticTokens(document: TextDocument, range: Range, token: CancellationToken): ProviderResult<SemanticTokens>;
}
@@ -5233,6 +5208,9 @@ declare module 'vscode' {
* [`Command`](#Command) or identifier of a command to run on click.
*
* The command must be [known](#commands.getCommands).
*
* Note that if this is a [`Command`](#Command) object, only the [`command`](#Command.command) and [`arguments`](#Command.arguments)
* are used by VS Code.
*/
command: string | Command | undefined;
@@ -6840,9 +6818,6 @@ declare module 'vscode' {
* Text based custom editors use a [`TextDocument`](#TextDocument) as their data model. This considerably simplifies
* implementing a custom 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 custom 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 {
@@ -6865,259 +6840,6 @@ declare module 'vscode' {
resolveCustomTextEditor(document: TextDocument, webviewPanel: WebviewPanel, token: CancellationToken): Thenable<void> | void;
}
/**
* Defines the editing capability of a custom editor. This allows the custom 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>;
/**
* 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: ReadonlyArray<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: ReadonlyArray<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 backup.
* @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;
}
/**
* Delta for edits undone/redone while reverting for a `CustomDocument`.
*
* @param EditType Type of edits used for the document being reverted.
*/
interface CustomDocumentRevert<EditType = unknown> {
/**
* List of edits that were undone to get the document back to its on disk state.
*/
readonly undoneEdits: ReadonlyArray<EditType>;
/**
* List of edits that were reapplied to get the document back to its on disk state.
*/
readonly appliedEdits: ReadonlyArray<EditType>;
}
/**
* Represents a custom document used by a [`CustomEditorProvider`](#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 uri The associated resource for this document.
*/
constructor(uri: Uri);
/**
* 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.
*
* `appliedEdits` returns a copy of the edit stack at the current point in time. Your extension should always
* use `CustomDocument.appliedEdits` to check the edit stack instead of holding onto a reference to `appliedEdits`.
*/
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.
*
* `savedEdits` returns a copy of the edit stack at the current point in time. Your extension should always
* use `CustomDocument.savedEdits` to check the edit stack instead of holding onto a reference to `savedEdits`.
*/
readonly savedEdits: ReadonlyArray<EditType>;
/**
* `true` if the document has been closed. A closed document isn't synchronized anymore
* and won't be reused when the same resource is opened again.
*/
readonly isClosed: boolean;
/**
* Event fired when there are no more references to the `CustomDocument`.
*
* This happens when all custom editors for the document have been closed. Once a `CustomDocument` is disposed,
* it will not be reused when the same resource is opened again.
*/
readonly onDidDispose: Event<void>;
}
/**
* Provider for custom editors that use a custom document model.
*
* Custom editors use [`CustomDocument`](#CustomDocument) as their document model instead of a [`TextDocument`](#TextDocument).
* This gives extensions full control over actions such as edit, save, and backup.
*
* You should use this type of custom editor when dealing with binary files or more complex scenarios. For simple
* text based documents, use [`CustomTextEditorProvider`](#CustomTextEditorProvider) instead.
*
* @param EditType Type of edits used by the editors of this provider.
*/
export interface CustomEditorProvider<EditType = unknown> {
/**
* Create a new document for a given resource.
*
* `openCustomDocument` 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 `openCustomDocument`.
*
* @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>> | CustomDocument<EditType>;
/**
* Resolve a custom editor for a given resource.
*
* This is called whenever the user opens a new editor for this `CustomEditorProvider`.
*
* To resolve a custom 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 Optional thenable indicating that the custom editor has been resolved.
*/
resolveCustomEditor(document: CustomDocument<EditType>, webviewPanel: WebviewPanel, token: CancellationToken): Thenable<void> | void;
/**
* Defines the editing capability of the provider.
*
* When not provided, editors for this provider are considered readonly.
*/
readonly editingDelegate?: CustomEditorEditingDelegate<EditType>;
}
/**
* The clipboard provides read and write access to the system's clipboard.
*/
@@ -7956,22 +7678,19 @@ declare module 'vscode' {
export function registerWebviewPanelSerializer(viewType: string, serializer: WebviewPanelSerializer): Disposable;
/**
* Register a new provider for a custom editor.
* Register a provider for custom editors for the `viewType` contributed by the `customEditors` extension point.
*
* @param viewType Type of the custom editor provider. This should match the `viewType` from the
* `package.json` contributions.
* When a custom editor is opened, VS Code fires an `onCustomEditor:viewType` activation event. Your extension
* must register a [`CustomTextEditorProvider`](#CustomTextEditorProvider) for `viewType` as part of activation.
*
* @param viewType Unique identifier for the custom editor provider. This should match the `viewType` from the
* `customEditors` contribution point.
* @param provider Provider that resolves custom 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;
export function registerCustomEditorProvider(viewType: string, provider: CustomTextEditorProvider, options?: { readonly webviewOptions?: WebviewPanelOptions; }): Disposable;
}
/**
@@ -9861,6 +9580,12 @@ declare module 'vscode' {
/**
* Register a semantic tokens provider for a document range.
*
* *Note:* If a document has both a `DocumentSemanticTokensProvider` and a `DocumentRangeSemanticTokensProvider`,
* the range provider will be invoked only initially, for the time in which the full document provider takes
* to resolve the first request. Once the full document provider resolves the first request, the semantic tokens
* provided via the range provider will be discarded and from that point forward, only the document provider
* will be used.
*
* 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.