@difizen/libro-language-client 0.1.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +0 -0
- package/es/common/api.d.ts +38 -0
- package/es/common/api.d.ts.map +1 -0
- package/es/common/api.js +9 -0
- package/es/common/callHierarchy.d.ts +39 -0
- package/es/common/callHierarchy.d.ts.map +1 -0
- package/es/common/callHierarchy.js +139 -0
- package/es/common/client.d.ts +482 -0
- package/es/common/client.d.ts.map +1 -0
- package/es/common/client.js +2731 -0
- package/es/common/codeAction.d.ts +22 -0
- package/es/common/codeAction.d.ts.map +1 -0
- package/es/common/codeAction.js +149 -0
- package/es/common/codeConverter.d.ts +81 -0
- package/es/common/codeConverter.d.ts.map +1 -0
- package/es/common/codeConverter.js +1040 -0
- package/es/common/codeLens.d.ts +26 -0
- package/es/common/codeLens.d.ts.map +1 -0
- package/es/common/codeLens.js +125 -0
- package/es/common/colorProvider.d.ts +27 -0
- package/es/common/colorProvider.d.ts.map +1 -0
- package/es/common/colorProvider.js +104 -0
- package/es/common/completion.d.ts +22 -0
- package/es/common/completion.d.ts.map +1 -0
- package/es/common/completion.js +130 -0
- package/es/common/configuration.d.ts +71 -0
- package/es/common/configuration.d.ts.map +1 -0
- package/es/common/configuration.js +292 -0
- package/es/common/declaration.d.ts +18 -0
- package/es/common/declaration.d.ts.map +1 -0
- package/es/common/declaration.js +88 -0
- package/es/common/definition.d.ts +18 -0
- package/es/common/definition.d.ts.map +1 -0
- package/es/common/definition.js +80 -0
- package/es/common/diagnostic.d.ts +125 -0
- package/es/common/diagnostic.d.ts.map +1 -0
- package/es/common/diagnostic.js +1442 -0
- package/es/common/documentHighlight.d.ts +17 -0
- package/es/common/documentHighlight.d.ts.map +1 -0
- package/es/common/documentHighlight.js +73 -0
- package/es/common/documentLink.d.ts +21 -0
- package/es/common/documentLink.d.ts.map +1 -0
- package/es/common/documentLink.js +90 -0
- package/es/common/documentSymbol.d.ts +20 -0
- package/es/common/documentSymbol.d.ts.map +1 -0
- package/es/common/documentSymbol.js +134 -0
- package/es/common/executeCommand.d.ts +22 -0
- package/es/common/executeCommand.d.ts.map +1 -0
- package/es/common/executeCommand.js +117 -0
- package/es/common/features.d.ts +421 -0
- package/es/common/features.d.ts.map +1 -0
- package/es/common/features.js +576 -0
- package/es/common/fileOperations.d.ts +118 -0
- package/es/common/fileOperations.d.ts.map +1 -0
- package/es/common/fileOperations.js +705 -0
- package/es/common/fileSystemWatcher.d.ts +19 -0
- package/es/common/fileSystemWatcher.d.ts.map +1 -0
- package/es/common/fileSystemWatcher.js +173 -0
- package/es/common/foldingRange.d.ts +22 -0
- package/es/common/foldingRange.d.ts.map +1 -0
- package/es/common/foldingRange.js +127 -0
- package/es/common/formatting.d.ts +41 -0
- package/es/common/formatting.d.ts.map +1 -0
- package/es/common/formatting.js +233 -0
- package/es/common/hover.d.ts +18 -0
- package/es/common/hover.d.ts.map +1 -0
- package/es/common/hover.js +80 -0
- package/es/common/implementation.d.ts +18 -0
- package/es/common/implementation.d.ts.map +1 -0
- package/es/common/implementation.js +88 -0
- package/es/common/inlayHint.d.ts +23 -0
- package/es/common/inlayHint.d.ts.map +1 -0
- package/es/common/inlayHint.js +187 -0
- package/es/common/inlineCompletion.d.ts +20 -0
- package/es/common/inlineCompletion.d.ts.map +1 -0
- package/es/common/inlineCompletion.js +74 -0
- package/es/common/inlineValue.d.ts +21 -0
- package/es/common/inlineValue.d.ts.map +1 -0
- package/es/common/inlineValue.js +124 -0
- package/es/common/linkedEditingRange.d.ts +23 -0
- package/es/common/linkedEditingRange.d.ts.map +1 -0
- package/es/common/linkedEditingRange.js +94 -0
- package/es/common/notebook.d.ts +97 -0
- package/es/common/notebook.d.ts.map +1 -0
- package/es/common/notebook.js +1444 -0
- package/es/common/progress.d.ts +12 -0
- package/es/common/progress.d.ts.map +1 -0
- package/es/common/progress.js +75 -0
- package/es/common/progressPart.d.ts +25 -0
- package/es/common/progressPart.d.ts.map +1 -0
- package/es/common/progressPart.js +147 -0
- package/es/common/protocolCallHierarchyItem.d.ts +9 -0
- package/es/common/protocolCallHierarchyItem.d.ts.map +1 -0
- package/es/common/protocolCallHierarchyItem.js +34 -0
- package/es/common/protocolCodeAction.d.ts +7 -0
- package/es/common/protocolCodeAction.d.ts.map +1 -0
- package/es/common/protocolCodeAction.js +32 -0
- package/es/common/protocolCodeLens.d.ts +7 -0
- package/es/common/protocolCodeLens.d.ts.map +1 -0
- package/es/common/protocolCodeLens.js +29 -0
- package/es/common/protocolCompletionItem.d.ts +13 -0
- package/es/common/protocolCompletionItem.d.ts.map +1 -0
- package/es/common/protocolCompletionItem.js +29 -0
- package/es/common/protocolConverter.d.ts +174 -0
- package/es/common/protocolConverter.d.ts.map +1 -0
- package/es/common/protocolConverter.js +1982 -0
- package/es/common/protocolDiagnostic.d.ts +20 -0
- package/es/common/protocolDiagnostic.d.ts.map +1 -0
- package/es/common/protocolDiagnostic.js +46 -0
- package/es/common/protocolDocumentLink.d.ts +8 -0
- package/es/common/protocolDocumentLink.d.ts.map +1 -0
- package/es/common/protocolDocumentLink.js +29 -0
- package/es/common/protocolInlayHint.d.ts +8 -0
- package/es/common/protocolInlayHint.d.ts.map +1 -0
- package/es/common/protocolInlayHint.js +29 -0
- package/es/common/protocolTypeHierarchyItem.d.ts +9 -0
- package/es/common/protocolTypeHierarchyItem.d.ts.map +1 -0
- package/es/common/protocolTypeHierarchyItem.js +34 -0
- package/es/common/protocolWorkspaceSymbol.d.ts +9 -0
- package/es/common/protocolWorkspaceSymbol.d.ts.map +1 -0
- package/es/common/protocolWorkspaceSymbol.js +36 -0
- package/es/common/reference.d.ts +22 -0
- package/es/common/reference.d.ts.map +1 -0
- package/es/common/reference.js +78 -0
- package/es/common/rename.d.ts +29 -0
- package/es/common/rename.d.ts.map +1 -0
- package/es/common/rename.js +132 -0
- package/es/common/selectionRange.d.ts +18 -0
- package/es/common/selectionRange.d.ts.map +1 -0
- package/es/common/selectionRange.js +108 -0
- package/es/common/semanticTokens.d.ts +36 -0
- package/es/common/semanticTokens.d.ts.map +1 -0
- package/es/common/semanticTokens.js +226 -0
- package/es/common/signatureHelp.d.ts +18 -0
- package/es/common/signatureHelp.d.ts.map +1 -0
- package/es/common/signatureHelp.js +103 -0
- package/es/common/textSynchronization.d.ts +104 -0
- package/es/common/textSynchronization.d.ts.map +1 -0
- package/es/common/textSynchronization.js +771 -0
- package/es/common/typeDefinition.d.ts +18 -0
- package/es/common/typeDefinition.d.ts.map +1 -0
- package/es/common/typeDefinition.js +89 -0
- package/es/common/typeHierarchy.d.ts +33 -0
- package/es/common/typeHierarchy.d.ts.map +1 -0
- package/es/common/typeHierarchy.js +138 -0
- package/es/common/utils/async.d.ts +42 -0
- package/es/common/utils/async.d.ts.map +1 -0
- package/es/common/utils/async.js +441 -0
- package/es/common/utils/is.d.ts +13 -0
- package/es/common/utils/is.d.ts.map +1 -0
- package/es/common/utils/is.js +52 -0
- package/es/common/utils/uuid.d.ts +23 -0
- package/es/common/utils/uuid.d.ts.map +1 -0
- package/es/common/utils/uuid.js +85 -0
- package/es/common/vscodeAdaptor/convertor.d.ts +7 -0
- package/es/common/vscodeAdaptor/convertor.d.ts.map +1 -0
- package/es/common/vscodeAdaptor/convertor.js +66 -0
- package/es/common/vscodeAdaptor/diagnosticCollection.d.ts +33 -0
- package/es/common/vscodeAdaptor/diagnosticCollection.d.ts.map +1 -0
- package/es/common/vscodeAdaptor/diagnosticCollection.js +310 -0
- package/es/common/vscodeAdaptor/extHostTypes.d.ts +1496 -0
- package/es/common/vscodeAdaptor/extHostTypes.d.ts.map +1 -0
- package/es/common/vscodeAdaptor/extHostTypes.js +3825 -0
- package/es/common/vscodeAdaptor/fileWatcher.d.ts +19 -0
- package/es/common/vscodeAdaptor/fileWatcher.d.ts.map +1 -0
- package/es/common/vscodeAdaptor/fileWatcher.js +45 -0
- package/es/common/vscodeAdaptor/hostTypeUtil.d.ts +192 -0
- package/es/common/vscodeAdaptor/hostTypeUtil.d.ts.map +1 -0
- package/es/common/vscodeAdaptor/hostTypeUtil.js +566 -0
- package/es/common/vscodeAdaptor/libro-fs.d.ts +21 -0
- package/es/common/vscodeAdaptor/libro-fs.d.ts.map +1 -0
- package/es/common/vscodeAdaptor/libro-fs.js +64 -0
- package/es/common/vscodeAdaptor/libroWindow.d.ts +21 -0
- package/es/common/vscodeAdaptor/libroWindow.d.ts.map +1 -0
- package/es/common/vscodeAdaptor/libroWindow.js +75 -0
- package/es/common/vscodeAdaptor/libroWorkspace.d.ts +33 -0
- package/es/common/vscodeAdaptor/libroWorkspace.d.ts.map +1 -0
- package/es/common/vscodeAdaptor/libroWorkspace.js +250 -0
- package/es/common/vscodeAdaptor/lspEnv.d.ts +8 -0
- package/es/common/vscodeAdaptor/lspEnv.d.ts.map +1 -0
- package/es/common/vscodeAdaptor/lspEnv.js +31 -0
- package/es/common/vscodeAdaptor/monaco-converter.d.ts +229 -0
- package/es/common/vscodeAdaptor/monaco-converter.d.ts.map +1 -0
- package/es/common/vscodeAdaptor/monaco-converter.js +1613 -0
- package/es/common/vscodeAdaptor/monacoLanguages.d.ts +48 -0
- package/es/common/vscodeAdaptor/monacoLanguages.d.ts.map +1 -0
- package/es/common/vscodeAdaptor/monacoLanguages.js +484 -0
- package/es/common/vscodeAdaptor/services.d.ts +85 -0
- package/es/common/vscodeAdaptor/services.d.ts.map +1 -0
- package/es/common/vscodeAdaptor/services.js +3 -0
- package/es/common/vscodeAdaptor/typings.d.ts +10 -0
- package/es/common/vscodeAdaptor/util.d.ts +3 -0
- package/es/common/vscodeAdaptor/util.d.ts.map +1 -0
- package/es/common/vscodeAdaptor/util.js +6 -0
- package/es/common/vscodeAdaptor/vscodeAdaptor.d.ts +77 -0
- package/es/common/vscodeAdaptor/vscodeAdaptor.d.ts.map +1 -0
- package/es/common/vscodeAdaptor/vscodeAdaptor.js +124 -0
- package/es/common/workspaceFolder.d.ts +32 -0
- package/es/common/workspaceFolder.d.ts.map +1 -0
- package/es/common/workspaceFolder.js +204 -0
- package/es/common/workspaceSymbol.d.ts +21 -0
- package/es/common/workspaceSymbol.d.ts.map +1 -0
- package/es/common/workspaceSymbol.js +101 -0
- package/es/constants.d.ts +2 -0
- package/es/constants.d.ts.map +1 -0
- package/es/constants.js +1 -0
- package/es/index.d.ts +6 -0
- package/es/index.d.ts.map +1 -0
- package/es/index.js +5 -0
- package/es/libro-language-client-contribution.d.ts +10 -0
- package/es/libro-language-client-contribution.d.ts.map +1 -0
- package/es/libro-language-client-contribution.js +143 -0
- package/es/libro-language-client-manager.d.ts +34 -0
- package/es/libro-language-client-manager.d.ts.map +1 -0
- package/es/libro-language-client-manager.js +277 -0
- package/es/libro-language-client.d.ts +27 -0
- package/es/libro-language-client.d.ts.map +1 -0
- package/es/libro-language-client.js +141 -0
- package/es/module.d.ts +3 -0
- package/es/module.d.ts.map +1 -0
- package/es/module.js +13 -0
- package/package.json +69 -0
- package/src/common/api.ts +155 -0
- package/src/common/callHierarchy.ts +269 -0
- package/src/common/client.ts +3192 -0
- package/src/common/codeAction.ts +237 -0
- package/src/common/codeConverter.ts +1409 -0
- package/src/common/codeLens.ts +188 -0
- package/src/common/colorProvider.ts +192 -0
- package/src/common/completion.ts +281 -0
- package/src/common/configuration.ts +338 -0
- package/src/common/declaration.ts +140 -0
- package/src/common/definition.ts +138 -0
- package/src/common/diagnostic.ts +1408 -0
- package/src/common/documentHighlight.ts +140 -0
- package/src/common/documentLink.ts +180 -0
- package/src/common/documentSymbol.ts +186 -0
- package/src/common/executeCommand.ts +129 -0
- package/src/common/features.ts +1157 -0
- package/src/common/fileOperations.ts +635 -0
- package/src/common/fileSystemWatcher.ts +184 -0
- package/src/common/foldingRange.ts +160 -0
- package/src/common/formatting.ts +465 -0
- package/src/common/hover.ts +133 -0
- package/src/common/implementation.ts +142 -0
- package/src/common/inlayHint.ts +201 -0
- package/src/common/inlineCompletion.ts +160 -0
- package/src/common/inlineValue.ts +158 -0
- package/src/common/linkedEditingRange.ts +141 -0
- package/src/common/notebook.ts +1443 -0
- package/src/common/progress.ts +61 -0
- package/src/common/progressPart.ts +151 -0
- package/src/common/protocolCallHierarchyItem.ts +29 -0
- package/src/common/protocolCodeAction.ts +17 -0
- package/src/common/protocolCodeLens.ts +15 -0
- package/src/common/protocolCompletionItem.ts +22 -0
- package/src/common/protocolConverter.ts +2627 -0
- package/src/common/protocolDiagnostic.ts +47 -0
- package/src/common/protocolDocumentLink.ts +17 -0
- package/src/common/protocolInlayHint.ts +21 -0
- package/src/common/protocolTypeHierarchyItem.ts +29 -0
- package/src/common/protocolWorkspaceSymbol.ts +39 -0
- package/src/common/reference.ts +144 -0
- package/src/common/rename.ts +230 -0
- package/src/common/selectionRange.ts +136 -0
- package/src/common/semanticTokens.ts +383 -0
- package/src/common/signatureHelp.ts +170 -0
- package/src/common/textSynchronization.ts +819 -0
- package/src/common/typeDefinition.ts +146 -0
- package/src/common/typeHierarchy.ts +248 -0
- package/src/common/utils/async.ts +354 -0
- package/src/common/utils/is.ts +63 -0
- package/src/common/utils/uuid.ts +136 -0
- package/src/common/vscodeAdaptor/convertor.ts +73 -0
- package/src/common/vscodeAdaptor/diagnosticCollection.ts +238 -0
- package/src/common/vscodeAdaptor/extHostTypes.ts +4498 -0
- package/src/common/vscodeAdaptor/fileWatcher.ts +36 -0
- package/src/common/vscodeAdaptor/hostTypeUtil.ts +539 -0
- package/src/common/vscodeAdaptor/libro-fs.ts +51 -0
- package/src/common/vscodeAdaptor/libroWindow.ts +85 -0
- package/src/common/vscodeAdaptor/libroWorkspace.ts +261 -0
- package/src/common/vscodeAdaptor/lspEnv.ts +16 -0
- package/src/common/vscodeAdaptor/monaco-converter.ts +1800 -0
- package/src/common/vscodeAdaptor/monacoLanguages.ts +511 -0
- package/src/common/vscodeAdaptor/services.ts +278 -0
- package/src/common/vscodeAdaptor/typings.d.ts +10 -0
- package/src/common/vscodeAdaptor/util.ts +7 -0
- package/src/common/vscodeAdaptor/vscodeAdaptor.ts +122 -0
- package/src/common/workspaceFolder.ts +236 -0
- package/src/common/workspaceSymbol.ts +166 -0
- package/src/constants.ts +1 -0
- package/src/index.spec.ts +7 -0
- package/src/index.ts +5 -0
- package/src/libro-language-client-contribution.ts +49 -0
- package/src/libro-language-client-manager.ts +131 -0
- package/src/libro-language-client.ts +100 -0
- package/src/module.ts +19 -0
|
@@ -0,0 +1,4498 @@
|
|
|
1
|
+
/* eslint-disable no-useless-escape */
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-empty-function */
|
|
3
|
+
/* eslint-disable @typescript-eslint/ban-types */
|
|
4
|
+
/* eslint-disable no-console */
|
|
5
|
+
/*---------------------------------------------------------------------------------------------
|
|
6
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
7
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
8
|
+
*--------------------------------------------------------------------------------------------*/
|
|
9
|
+
|
|
10
|
+
// src/vs/workbench/api/common/extHostTypes.ts
|
|
11
|
+
|
|
12
|
+
import { v4 as generateUuid } from 'uuid';
|
|
13
|
+
import type * as vscode from 'vscode';
|
|
14
|
+
import { URI } from 'vscode-uri';
|
|
15
|
+
|
|
16
|
+
import type { IRelativePatternDto } from './hostTypeUtil.js';
|
|
17
|
+
import type { ICellMetadataEdit, IDocumentMetadataEdit } from './hostTypeUtil.js';
|
|
18
|
+
import type { MarkdownStringTrustedOptions } from './hostTypeUtil.js';
|
|
19
|
+
import type { IRelativePattern } from './hostTypeUtil.js';
|
|
20
|
+
import {
|
|
21
|
+
FileSystemProviderErrorCode,
|
|
22
|
+
markAsFileSystemProviderError,
|
|
23
|
+
} from './hostTypeUtil.js';
|
|
24
|
+
import { CellEditType, isTextStreamMime } from './hostTypeUtil.js';
|
|
25
|
+
import { isNumber, isObject, isString, isStringArray } from './hostTypeUtil.js';
|
|
26
|
+
import { Mimes, normalizeMimeType } from './hostTypeUtil.js';
|
|
27
|
+
import { ResourceMap } from './hostTypeUtil.js';
|
|
28
|
+
import { MarkdownString as BaseMarkdownString } from './hostTypeUtil.js';
|
|
29
|
+
import { illegalArgument } from './hostTypeUtil.js';
|
|
30
|
+
import { asArray, coalesceInPlace, equals } from './hostTypeUtil.js';
|
|
31
|
+
|
|
32
|
+
export enum TerminalOutputAnchor {
|
|
33
|
+
Top = 0,
|
|
34
|
+
Bottom = 1,
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export enum TerminalQuickFixType {
|
|
38
|
+
TerminalCommand = 0,
|
|
39
|
+
Opener = 1,
|
|
40
|
+
Command = 3,
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export class Disposable {
|
|
44
|
+
static from(...inDisposables: { dispose(): any }[]): Disposable {
|
|
45
|
+
let disposables: ReadonlyArray<{ dispose(): any }> | undefined = inDisposables;
|
|
46
|
+
return new Disposable(function () {
|
|
47
|
+
if (disposables) {
|
|
48
|
+
for (const disposable of disposables) {
|
|
49
|
+
if (disposable && typeof disposable.dispose === 'function') {
|
|
50
|
+
disposable.dispose();
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
disposables = undefined;
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
#callOnDispose?: () => any;
|
|
59
|
+
|
|
60
|
+
constructor(callOnDispose: () => any) {
|
|
61
|
+
this.#callOnDispose = callOnDispose;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
dispose(): any {
|
|
65
|
+
if (typeof this.#callOnDispose === 'function') {
|
|
66
|
+
this.#callOnDispose();
|
|
67
|
+
this.#callOnDispose = undefined;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export class Position {
|
|
73
|
+
static Min(...positions: Position[]): Position {
|
|
74
|
+
if (positions.length === 0) {
|
|
75
|
+
throw new TypeError();
|
|
76
|
+
}
|
|
77
|
+
let result = positions[0];
|
|
78
|
+
for (let i = 1; i < positions.length; i++) {
|
|
79
|
+
const p = positions[i];
|
|
80
|
+
if (p.isBefore(result!)) {
|
|
81
|
+
result = p;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return result;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
static Max(...positions: Position[]): Position {
|
|
88
|
+
if (positions.length === 0) {
|
|
89
|
+
throw new TypeError();
|
|
90
|
+
}
|
|
91
|
+
let result = positions[0];
|
|
92
|
+
for (let i = 1; i < positions.length; i++) {
|
|
93
|
+
const p = positions[i];
|
|
94
|
+
if (p.isAfter(result!)) {
|
|
95
|
+
result = p;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return result;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
static isPosition(other: any): other is Position {
|
|
102
|
+
if (!other) {
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
if (other instanceof Position) {
|
|
106
|
+
return true;
|
|
107
|
+
}
|
|
108
|
+
const { line, character } = <Position>other;
|
|
109
|
+
if (typeof line === 'number' && typeof character === 'number') {
|
|
110
|
+
return true;
|
|
111
|
+
}
|
|
112
|
+
return false;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
static of(obj: vscode.Position): Position {
|
|
116
|
+
if (obj instanceof Position) {
|
|
117
|
+
return obj;
|
|
118
|
+
} else if (this.isPosition(obj)) {
|
|
119
|
+
return new Position(obj.line, obj.character);
|
|
120
|
+
}
|
|
121
|
+
throw new Error('Invalid argument, is NOT a position-like object');
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
private _line: number;
|
|
125
|
+
private _character: number;
|
|
126
|
+
|
|
127
|
+
get line(): number {
|
|
128
|
+
return this._line;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
get character(): number {
|
|
132
|
+
return this._character;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
constructor(line: number, character: number) {
|
|
136
|
+
if (line < 0) {
|
|
137
|
+
throw illegalArgument('line must be non-negative');
|
|
138
|
+
}
|
|
139
|
+
if (character < 0) {
|
|
140
|
+
throw illegalArgument('character must be non-negative');
|
|
141
|
+
}
|
|
142
|
+
this._line = line;
|
|
143
|
+
this._character = character;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
isBefore(other: Position): boolean {
|
|
147
|
+
if (this._line < other._line) {
|
|
148
|
+
return true;
|
|
149
|
+
}
|
|
150
|
+
if (other._line < this._line) {
|
|
151
|
+
return false;
|
|
152
|
+
}
|
|
153
|
+
return this._character < other._character;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
isBeforeOrEqual(other: Position): boolean {
|
|
157
|
+
if (this._line < other._line) {
|
|
158
|
+
return true;
|
|
159
|
+
}
|
|
160
|
+
if (other._line < this._line) {
|
|
161
|
+
return false;
|
|
162
|
+
}
|
|
163
|
+
return this._character <= other._character;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
isAfter(other: Position): boolean {
|
|
167
|
+
return !this.isBeforeOrEqual(other);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
isAfterOrEqual(other: Position): boolean {
|
|
171
|
+
return !this.isBefore(other);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
isEqual(other: Position): boolean {
|
|
175
|
+
return this._line === other._line && this._character === other._character;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
compareTo(other: Position): number {
|
|
179
|
+
if (this._line < other._line) {
|
|
180
|
+
return -1;
|
|
181
|
+
} else if (this._line > other.line) {
|
|
182
|
+
return 1;
|
|
183
|
+
} else {
|
|
184
|
+
// equal line
|
|
185
|
+
if (this._character < other._character) {
|
|
186
|
+
return -1;
|
|
187
|
+
} else if (this._character > other._character) {
|
|
188
|
+
return 1;
|
|
189
|
+
} else {
|
|
190
|
+
// equal line and character
|
|
191
|
+
return 0;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
translate(change: { lineDelta?: number; characterDelta?: number }): Position;
|
|
197
|
+
translate(lineDelta?: number, characterDelta?: number): Position;
|
|
198
|
+
translate(
|
|
199
|
+
lineDeltaOrChange:
|
|
200
|
+
| number
|
|
201
|
+
| undefined
|
|
202
|
+
| { lineDelta?: number; characterDelta?: number },
|
|
203
|
+
characterDelta = 0,
|
|
204
|
+
): Position {
|
|
205
|
+
if (lineDeltaOrChange === null || characterDelta === null) {
|
|
206
|
+
throw illegalArgument();
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
let lineDelta: number;
|
|
210
|
+
if (typeof lineDeltaOrChange === 'undefined') {
|
|
211
|
+
lineDelta = 0;
|
|
212
|
+
} else if (typeof lineDeltaOrChange === 'number') {
|
|
213
|
+
lineDelta = lineDeltaOrChange;
|
|
214
|
+
} else {
|
|
215
|
+
lineDelta =
|
|
216
|
+
typeof lineDeltaOrChange.lineDelta === 'number'
|
|
217
|
+
? lineDeltaOrChange.lineDelta
|
|
218
|
+
: 0;
|
|
219
|
+
characterDelta =
|
|
220
|
+
typeof lineDeltaOrChange.characterDelta === 'number'
|
|
221
|
+
? lineDeltaOrChange.characterDelta
|
|
222
|
+
: 0;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
if (lineDelta === 0 && characterDelta === 0) {
|
|
226
|
+
return this;
|
|
227
|
+
}
|
|
228
|
+
return new Position(this.line + lineDelta, this.character + characterDelta);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
with(change: { line?: number; character?: number }): Position;
|
|
232
|
+
with(line?: number, character?: number): Position;
|
|
233
|
+
with(
|
|
234
|
+
lineOrChange: number | undefined | { line?: number; character?: number },
|
|
235
|
+
character: number = this.character,
|
|
236
|
+
): Position {
|
|
237
|
+
if (lineOrChange === null || character === null) {
|
|
238
|
+
throw illegalArgument();
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
let line: number;
|
|
242
|
+
if (typeof lineOrChange === 'undefined') {
|
|
243
|
+
line = this.line;
|
|
244
|
+
} else if (typeof lineOrChange === 'number') {
|
|
245
|
+
line = lineOrChange;
|
|
246
|
+
} else {
|
|
247
|
+
line = typeof lineOrChange.line === 'number' ? lineOrChange.line : this.line;
|
|
248
|
+
character =
|
|
249
|
+
typeof lineOrChange.character === 'number'
|
|
250
|
+
? lineOrChange.character
|
|
251
|
+
: this.character;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
if (line === this.line && character === this.character) {
|
|
255
|
+
return this;
|
|
256
|
+
}
|
|
257
|
+
return new Position(line, character);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
toJSON(): any {
|
|
261
|
+
return { line: this.line, character: this.character };
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
export class Range {
|
|
266
|
+
static isRange(thing: any): thing is vscode.Range {
|
|
267
|
+
if (thing instanceof Range) {
|
|
268
|
+
return true;
|
|
269
|
+
}
|
|
270
|
+
if (!thing) {
|
|
271
|
+
return false;
|
|
272
|
+
}
|
|
273
|
+
return (
|
|
274
|
+
Position.isPosition((<Range>thing).start) && Position.isPosition(<Range>thing.end)
|
|
275
|
+
);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
static of(obj: vscode.Range): Range {
|
|
279
|
+
if (obj instanceof Range) {
|
|
280
|
+
return obj;
|
|
281
|
+
}
|
|
282
|
+
if (this.isRange(obj)) {
|
|
283
|
+
return new Range(obj.start, obj.end);
|
|
284
|
+
}
|
|
285
|
+
throw new Error('Invalid argument, is NOT a range-like object');
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
protected _start: Position;
|
|
289
|
+
protected _end: Position;
|
|
290
|
+
|
|
291
|
+
get start(): Position {
|
|
292
|
+
return this._start;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
get end(): Position {
|
|
296
|
+
return this._end;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
constructor(start: vscode.Position, end: vscode.Position);
|
|
300
|
+
constructor(start: Position, end: Position);
|
|
301
|
+
constructor(
|
|
302
|
+
startLine: number,
|
|
303
|
+
startColumn: number,
|
|
304
|
+
endLine: number,
|
|
305
|
+
endColumn: number,
|
|
306
|
+
);
|
|
307
|
+
constructor(
|
|
308
|
+
startLineOrStart: number | Position | vscode.Position,
|
|
309
|
+
startColumnOrEnd: number | Position | vscode.Position,
|
|
310
|
+
endLine?: number,
|
|
311
|
+
endColumn?: number,
|
|
312
|
+
) {
|
|
313
|
+
let start: Position | undefined;
|
|
314
|
+
let end: Position | undefined;
|
|
315
|
+
|
|
316
|
+
if (
|
|
317
|
+
typeof startLineOrStart === 'number' &&
|
|
318
|
+
typeof startColumnOrEnd === 'number' &&
|
|
319
|
+
typeof endLine === 'number' &&
|
|
320
|
+
typeof endColumn === 'number'
|
|
321
|
+
) {
|
|
322
|
+
start = new Position(startLineOrStart, startColumnOrEnd);
|
|
323
|
+
end = new Position(endLine, endColumn);
|
|
324
|
+
} else if (
|
|
325
|
+
Position.isPosition(startLineOrStart) &&
|
|
326
|
+
Position.isPosition(startColumnOrEnd)
|
|
327
|
+
) {
|
|
328
|
+
start = Position.of(startLineOrStart);
|
|
329
|
+
end = Position.of(startColumnOrEnd);
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
if (!start || !end) {
|
|
333
|
+
throw new Error('Invalid arguments');
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
if (start.isBefore(end)) {
|
|
337
|
+
this._start = start;
|
|
338
|
+
this._end = end;
|
|
339
|
+
} else {
|
|
340
|
+
this._start = end;
|
|
341
|
+
this._end = start;
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
contains(positionOrRange: Position | Range): boolean {
|
|
346
|
+
if (Range.isRange(positionOrRange)) {
|
|
347
|
+
return this.contains(positionOrRange.start) && this.contains(positionOrRange.end);
|
|
348
|
+
} else if (Position.isPosition(positionOrRange)) {
|
|
349
|
+
if (Position.of(positionOrRange).isBefore(this._start)) {
|
|
350
|
+
return false;
|
|
351
|
+
}
|
|
352
|
+
if (this._end.isBefore(positionOrRange)) {
|
|
353
|
+
return false;
|
|
354
|
+
}
|
|
355
|
+
return true;
|
|
356
|
+
}
|
|
357
|
+
return false;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
isEqual(other: Range): boolean {
|
|
361
|
+
return this._start.isEqual(other._start) && this._end.isEqual(other._end);
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
intersection(other: Range): Range | undefined {
|
|
365
|
+
const start = Position.Max(other.start, this._start);
|
|
366
|
+
const end = Position.Min(other.end, this._end);
|
|
367
|
+
if (start.isAfter(end)) {
|
|
368
|
+
// this happens when there is no overlap:
|
|
369
|
+
// |-----|
|
|
370
|
+
// |----|
|
|
371
|
+
return undefined;
|
|
372
|
+
}
|
|
373
|
+
return new Range(start, end);
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
union(other: Range): Range {
|
|
377
|
+
if (this.contains(other)) {
|
|
378
|
+
return this;
|
|
379
|
+
} else if (other.contains(this)) {
|
|
380
|
+
return other;
|
|
381
|
+
}
|
|
382
|
+
const start = Position.Min(other.start, this._start);
|
|
383
|
+
const end = Position.Max(other.end, this.end);
|
|
384
|
+
return new Range(start, end);
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
get isEmpty(): boolean {
|
|
388
|
+
return this._start.isEqual(this._end);
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
get isSingleLine(): boolean {
|
|
392
|
+
return this._start.line === this._end.line;
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
with(change: { start?: Position; end?: Position }): Range;
|
|
396
|
+
with(start?: Position, end?: Position): Range;
|
|
397
|
+
with(
|
|
398
|
+
startOrChange: Position | undefined | { start?: Position; end?: Position },
|
|
399
|
+
end: Position = this.end,
|
|
400
|
+
): Range {
|
|
401
|
+
if (startOrChange === null || end === null) {
|
|
402
|
+
throw illegalArgument();
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
let start: Position;
|
|
406
|
+
if (!startOrChange) {
|
|
407
|
+
start = this.start;
|
|
408
|
+
} else if (Position.isPosition(startOrChange)) {
|
|
409
|
+
start = startOrChange;
|
|
410
|
+
} else {
|
|
411
|
+
start = startOrChange.start || this.start;
|
|
412
|
+
end = startOrChange.end || this.end;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
if (start.isEqual(this._start) && end.isEqual(this.end)) {
|
|
416
|
+
return this;
|
|
417
|
+
}
|
|
418
|
+
return new Range(start, end);
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
toJSON(): any {
|
|
422
|
+
return [this.start, this.end];
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
export class Selection extends Range {
|
|
427
|
+
static isSelection(thing: any): thing is Selection {
|
|
428
|
+
if (thing instanceof Selection) {
|
|
429
|
+
return true;
|
|
430
|
+
}
|
|
431
|
+
if (!thing) {
|
|
432
|
+
return false;
|
|
433
|
+
}
|
|
434
|
+
return (
|
|
435
|
+
Range.isRange(thing) &&
|
|
436
|
+
Position.isPosition((<Selection>thing).anchor) &&
|
|
437
|
+
Position.isPosition((<Selection>thing).active) &&
|
|
438
|
+
typeof (<Selection>thing).isReversed === 'boolean'
|
|
439
|
+
);
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
private _anchor: Position;
|
|
443
|
+
|
|
444
|
+
public get anchor(): Position {
|
|
445
|
+
return this._anchor;
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
private _active: Position;
|
|
449
|
+
|
|
450
|
+
public get active(): Position {
|
|
451
|
+
return this._active;
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
constructor(anchor: Position, active: Position);
|
|
455
|
+
constructor(
|
|
456
|
+
anchorLine: number,
|
|
457
|
+
anchorColumn: number,
|
|
458
|
+
activeLine: number,
|
|
459
|
+
activeColumn: number,
|
|
460
|
+
);
|
|
461
|
+
constructor(
|
|
462
|
+
anchorLineOrAnchor: number | Position,
|
|
463
|
+
anchorColumnOrActive: number | Position,
|
|
464
|
+
activeLine?: number,
|
|
465
|
+
activeColumn?: number,
|
|
466
|
+
) {
|
|
467
|
+
let anchor: Position | undefined;
|
|
468
|
+
let active: Position | undefined;
|
|
469
|
+
|
|
470
|
+
if (
|
|
471
|
+
typeof anchorLineOrAnchor === 'number' &&
|
|
472
|
+
typeof anchorColumnOrActive === 'number' &&
|
|
473
|
+
typeof activeLine === 'number' &&
|
|
474
|
+
typeof activeColumn === 'number'
|
|
475
|
+
) {
|
|
476
|
+
anchor = new Position(anchorLineOrAnchor, anchorColumnOrActive);
|
|
477
|
+
active = new Position(activeLine, activeColumn);
|
|
478
|
+
} else if (
|
|
479
|
+
Position.isPosition(anchorLineOrAnchor) &&
|
|
480
|
+
Position.isPosition(anchorColumnOrActive)
|
|
481
|
+
) {
|
|
482
|
+
anchor = Position.of(anchorLineOrAnchor);
|
|
483
|
+
active = Position.of(anchorColumnOrActive);
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
if (!anchor || !active) {
|
|
487
|
+
throw new Error('Invalid arguments');
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
super(anchor, active);
|
|
491
|
+
|
|
492
|
+
this._anchor = anchor;
|
|
493
|
+
this._active = active;
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
get isReversed(): boolean {
|
|
497
|
+
return this._anchor === this._end;
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
override toJSON() {
|
|
501
|
+
return {
|
|
502
|
+
start: this.start,
|
|
503
|
+
end: this.end,
|
|
504
|
+
active: this.active,
|
|
505
|
+
anchor: this.anchor,
|
|
506
|
+
};
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
const validateConnectionToken = (connectionToken: string) => {
|
|
511
|
+
if (
|
|
512
|
+
typeof connectionToken !== 'string' ||
|
|
513
|
+
connectionToken.length === 0 ||
|
|
514
|
+
!/^[0-9A-Za-z_\-]+$/.test(connectionToken)
|
|
515
|
+
) {
|
|
516
|
+
throw illegalArgument('connectionToken');
|
|
517
|
+
}
|
|
518
|
+
};
|
|
519
|
+
|
|
520
|
+
export class ResolvedAuthority {
|
|
521
|
+
public static isResolvedAuthority(
|
|
522
|
+
resolvedAuthority: any,
|
|
523
|
+
): resolvedAuthority is ResolvedAuthority {
|
|
524
|
+
return (
|
|
525
|
+
resolvedAuthority &&
|
|
526
|
+
typeof resolvedAuthority === 'object' &&
|
|
527
|
+
typeof resolvedAuthority.host === 'string' &&
|
|
528
|
+
typeof resolvedAuthority.port === 'number' &&
|
|
529
|
+
(resolvedAuthority.connectionToken === undefined ||
|
|
530
|
+
typeof resolvedAuthority.connectionToken === 'string')
|
|
531
|
+
);
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
readonly host: string;
|
|
535
|
+
readonly port: number;
|
|
536
|
+
readonly connectionToken: string | undefined;
|
|
537
|
+
|
|
538
|
+
constructor(host: string, port: number, connectionToken?: string) {
|
|
539
|
+
if (typeof host !== 'string' || host.length === 0) {
|
|
540
|
+
throw illegalArgument('host');
|
|
541
|
+
}
|
|
542
|
+
if (typeof port !== 'number' || port === 0 || Math.round(port) !== port) {
|
|
543
|
+
throw illegalArgument('port');
|
|
544
|
+
}
|
|
545
|
+
if (typeof connectionToken !== 'undefined') {
|
|
546
|
+
validateConnectionToken(connectionToken);
|
|
547
|
+
}
|
|
548
|
+
this.host = host;
|
|
549
|
+
this.port = Math.round(port);
|
|
550
|
+
this.connectionToken = connectionToken;
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
export enum EndOfLine {
|
|
555
|
+
LF = 1,
|
|
556
|
+
CRLF = 2,
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
export enum EnvironmentVariableMutatorType {
|
|
560
|
+
Replace = 1,
|
|
561
|
+
Append = 2,
|
|
562
|
+
Prepend = 3,
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
export class TextEdit {
|
|
566
|
+
static isTextEdit(thing: any): thing is TextEdit {
|
|
567
|
+
if (thing instanceof TextEdit) {
|
|
568
|
+
return true;
|
|
569
|
+
}
|
|
570
|
+
if (!thing) {
|
|
571
|
+
return false;
|
|
572
|
+
}
|
|
573
|
+
return (
|
|
574
|
+
Range.isRange(<TextEdit>thing) && typeof (<TextEdit>thing).newText === 'string'
|
|
575
|
+
);
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
static replace(range: Range, newText: string): TextEdit {
|
|
579
|
+
return new TextEdit(range, newText);
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
static insert(position: Position, newText: string): TextEdit {
|
|
583
|
+
return TextEdit.replace(new Range(position, position), newText);
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
static delete(range: Range): TextEdit {
|
|
587
|
+
return TextEdit.replace(range, '');
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
static setEndOfLine(eol: EndOfLine): TextEdit {
|
|
591
|
+
const ret = new TextEdit(new Range(new Position(0, 0), new Position(0, 0)), '');
|
|
592
|
+
ret.newEol = eol;
|
|
593
|
+
return ret;
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
protected _range: Range;
|
|
597
|
+
protected _newText: string | null;
|
|
598
|
+
protected _newEol?: EndOfLine;
|
|
599
|
+
|
|
600
|
+
get range(): Range {
|
|
601
|
+
return this._range;
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
set range(value: Range) {
|
|
605
|
+
if (value && !Range.isRange(value)) {
|
|
606
|
+
throw illegalArgument('range');
|
|
607
|
+
}
|
|
608
|
+
this._range = value;
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
get newText(): string {
|
|
612
|
+
return this._newText || '';
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
set newText(value: string) {
|
|
616
|
+
if (value && typeof value !== 'string') {
|
|
617
|
+
throw illegalArgument('newText');
|
|
618
|
+
}
|
|
619
|
+
this._newText = value;
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
get newEol(): EndOfLine | undefined {
|
|
623
|
+
return this._newEol;
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
set newEol(value: EndOfLine | undefined) {
|
|
627
|
+
if (value && typeof value !== 'number') {
|
|
628
|
+
throw illegalArgument('newEol');
|
|
629
|
+
}
|
|
630
|
+
this._newEol = value;
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
constructor(range: Range, newText: string | null) {
|
|
634
|
+
this._range = range;
|
|
635
|
+
this._newText = newText;
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
toJSON(): any {
|
|
639
|
+
return {
|
|
640
|
+
range: this.range,
|
|
641
|
+
newText: this.newText,
|
|
642
|
+
newEol: this._newEol,
|
|
643
|
+
};
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
export class NotebookEdit implements vscode.NotebookEdit {
|
|
648
|
+
static isNotebookCellEdit(thing: any): thing is NotebookEdit {
|
|
649
|
+
if (thing instanceof NotebookEdit) {
|
|
650
|
+
return true;
|
|
651
|
+
}
|
|
652
|
+
if (!thing) {
|
|
653
|
+
return false;
|
|
654
|
+
}
|
|
655
|
+
return (
|
|
656
|
+
NotebookRange.isNotebookRange(<NotebookEdit>thing) &&
|
|
657
|
+
Array.isArray((<NotebookEdit>thing).newCells)
|
|
658
|
+
);
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
static replaceCells(
|
|
662
|
+
range: NotebookRange,
|
|
663
|
+
newCells: NotebookCellData[],
|
|
664
|
+
): NotebookEdit {
|
|
665
|
+
return new NotebookEdit(range, newCells);
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
static insertCells(
|
|
669
|
+
index: number,
|
|
670
|
+
newCells: vscode.NotebookCellData[],
|
|
671
|
+
): vscode.NotebookEdit {
|
|
672
|
+
return new NotebookEdit(new NotebookRange(index, index), newCells);
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
static deleteCells(range: NotebookRange): NotebookEdit {
|
|
676
|
+
return new NotebookEdit(range, []);
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
static updateCellMetadata(
|
|
680
|
+
index: number,
|
|
681
|
+
newMetadata: { [key: string]: any },
|
|
682
|
+
): NotebookEdit {
|
|
683
|
+
const edit = new NotebookEdit(new NotebookRange(index, index), []);
|
|
684
|
+
edit.newCellMetadata = newMetadata;
|
|
685
|
+
return edit;
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
static updateNotebookMetadata(newMetadata: { [key: string]: any }): NotebookEdit {
|
|
689
|
+
const edit = new NotebookEdit(new NotebookRange(0, 0), []);
|
|
690
|
+
edit.newNotebookMetadata = newMetadata;
|
|
691
|
+
return edit;
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
range: NotebookRange;
|
|
695
|
+
newCells: NotebookCellData[];
|
|
696
|
+
newCellMetadata?: { [key: string]: any };
|
|
697
|
+
newNotebookMetadata?: { [key: string]: any };
|
|
698
|
+
|
|
699
|
+
constructor(range: NotebookRange, newCells: NotebookCellData[]) {
|
|
700
|
+
this.range = range;
|
|
701
|
+
this.newCells = newCells;
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
export class SnippetTextEdit implements vscode.SnippetTextEdit {
|
|
706
|
+
static isSnippetTextEdit(thing: any): thing is SnippetTextEdit {
|
|
707
|
+
if (thing instanceof SnippetTextEdit) {
|
|
708
|
+
return true;
|
|
709
|
+
}
|
|
710
|
+
if (!thing) {
|
|
711
|
+
return false;
|
|
712
|
+
}
|
|
713
|
+
return (
|
|
714
|
+
Range.isRange((<SnippetTextEdit>thing).range) &&
|
|
715
|
+
SnippetString.isSnippetString((<SnippetTextEdit>thing).snippet)
|
|
716
|
+
);
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
static replace(range: Range, snippet: SnippetString): SnippetTextEdit {
|
|
720
|
+
return new SnippetTextEdit(range, snippet);
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
static insert(position: Position, snippet: SnippetString): SnippetTextEdit {
|
|
724
|
+
return SnippetTextEdit.replace(new Range(position, position), snippet);
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
range: Range;
|
|
728
|
+
|
|
729
|
+
snippet: SnippetString;
|
|
730
|
+
|
|
731
|
+
constructor(range: Range, snippet: SnippetString) {
|
|
732
|
+
this.range = range;
|
|
733
|
+
this.snippet = snippet;
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
export interface IFileOperationOptions {
|
|
738
|
+
readonly overwrite?: boolean;
|
|
739
|
+
readonly ignoreIfExists?: boolean;
|
|
740
|
+
readonly ignoreIfNotExists?: boolean;
|
|
741
|
+
readonly recursive?: boolean;
|
|
742
|
+
readonly contents?: Uint8Array | vscode.DataTransferFile;
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
export const enum FileEditType {
|
|
746
|
+
File = 1,
|
|
747
|
+
Text = 2,
|
|
748
|
+
Cell = 3,
|
|
749
|
+
CellReplace = 5,
|
|
750
|
+
Snippet = 6,
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
export interface IFileOperation {
|
|
754
|
+
readonly _type: FileEditType.File;
|
|
755
|
+
readonly from?: URI;
|
|
756
|
+
readonly to?: URI;
|
|
757
|
+
readonly options?: IFileOperationOptions;
|
|
758
|
+
readonly metadata?: vscode.WorkspaceEditEntryMetadata;
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
export interface IFileTextEdit {
|
|
762
|
+
readonly _type: FileEditType.Text;
|
|
763
|
+
readonly uri: URI;
|
|
764
|
+
readonly edit: TextEdit;
|
|
765
|
+
readonly metadata?: vscode.WorkspaceEditEntryMetadata;
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
export interface IFileSnippetTextEdit {
|
|
769
|
+
readonly _type: FileEditType.Snippet;
|
|
770
|
+
readonly uri: URI;
|
|
771
|
+
readonly range: vscode.Range;
|
|
772
|
+
readonly edit: vscode.SnippetString;
|
|
773
|
+
readonly metadata?: vscode.WorkspaceEditEntryMetadata;
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
export interface IFileCellEdit {
|
|
777
|
+
readonly _type: FileEditType.Cell;
|
|
778
|
+
readonly uri: URI;
|
|
779
|
+
readonly edit?: ICellMetadataEdit | IDocumentMetadataEdit;
|
|
780
|
+
readonly notebookMetadata?: Record<string, any>;
|
|
781
|
+
readonly metadata?: vscode.WorkspaceEditEntryMetadata;
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
export interface ICellEdit {
|
|
785
|
+
readonly _type: FileEditType.CellReplace;
|
|
786
|
+
readonly metadata?: vscode.WorkspaceEditEntryMetadata;
|
|
787
|
+
readonly uri: URI;
|
|
788
|
+
readonly index: number;
|
|
789
|
+
readonly count: number;
|
|
790
|
+
readonly cells: vscode.NotebookCellData[];
|
|
791
|
+
}
|
|
792
|
+
|
|
793
|
+
type WorkspaceEditEntry =
|
|
794
|
+
| IFileOperation
|
|
795
|
+
| IFileTextEdit
|
|
796
|
+
| IFileSnippetTextEdit
|
|
797
|
+
| IFileCellEdit
|
|
798
|
+
| ICellEdit;
|
|
799
|
+
|
|
800
|
+
export class WorkspaceEdit implements vscode.WorkspaceEdit {
|
|
801
|
+
private readonly _edits: WorkspaceEditEntry[] = [];
|
|
802
|
+
|
|
803
|
+
_allEntries(): ReadonlyArray<WorkspaceEditEntry> {
|
|
804
|
+
return this._edits;
|
|
805
|
+
}
|
|
806
|
+
|
|
807
|
+
// --- file
|
|
808
|
+
|
|
809
|
+
renameFile(
|
|
810
|
+
from: vscode.Uri,
|
|
811
|
+
to: vscode.Uri,
|
|
812
|
+
options?: { readonly overwrite?: boolean; readonly ignoreIfExists?: boolean },
|
|
813
|
+
metadata?: vscode.WorkspaceEditEntryMetadata,
|
|
814
|
+
): void {
|
|
815
|
+
this._edits.push({ _type: FileEditType.File, from, to, options, metadata });
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
createFile(
|
|
819
|
+
uri: vscode.Uri,
|
|
820
|
+
options?: {
|
|
821
|
+
readonly overwrite?: boolean;
|
|
822
|
+
readonly ignoreIfExists?: boolean;
|
|
823
|
+
readonly contents?: Uint8Array | vscode.DataTransferFile;
|
|
824
|
+
},
|
|
825
|
+
metadata?: vscode.WorkspaceEditEntryMetadata,
|
|
826
|
+
): void {
|
|
827
|
+
this._edits.push({
|
|
828
|
+
_type: FileEditType.File,
|
|
829
|
+
from: undefined,
|
|
830
|
+
to: uri,
|
|
831
|
+
options,
|
|
832
|
+
metadata,
|
|
833
|
+
});
|
|
834
|
+
}
|
|
835
|
+
|
|
836
|
+
deleteFile(
|
|
837
|
+
uri: vscode.Uri,
|
|
838
|
+
options?: { readonly recursive?: boolean; readonly ignoreIfNotExists?: boolean },
|
|
839
|
+
metadata?: vscode.WorkspaceEditEntryMetadata,
|
|
840
|
+
): void {
|
|
841
|
+
this._edits.push({
|
|
842
|
+
_type: FileEditType.File,
|
|
843
|
+
from: uri,
|
|
844
|
+
to: undefined,
|
|
845
|
+
options,
|
|
846
|
+
metadata,
|
|
847
|
+
});
|
|
848
|
+
}
|
|
849
|
+
|
|
850
|
+
// --- notebook
|
|
851
|
+
|
|
852
|
+
private replaceNotebookMetadata(
|
|
853
|
+
uri: URI,
|
|
854
|
+
value: Record<string, any>,
|
|
855
|
+
metadata?: vscode.WorkspaceEditEntryMetadata,
|
|
856
|
+
): void {
|
|
857
|
+
this._edits.push({
|
|
858
|
+
_type: FileEditType.Cell,
|
|
859
|
+
metadata,
|
|
860
|
+
uri,
|
|
861
|
+
edit: { editType: CellEditType.DocumentMetadata, metadata: value },
|
|
862
|
+
notebookMetadata: value,
|
|
863
|
+
});
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
private replaceNotebookCells(
|
|
867
|
+
uri: URI,
|
|
868
|
+
startOrRange: vscode.NotebookRange,
|
|
869
|
+
cellData: vscode.NotebookCellData[],
|
|
870
|
+
metadata?: vscode.WorkspaceEditEntryMetadata,
|
|
871
|
+
): void {
|
|
872
|
+
const start = startOrRange.start;
|
|
873
|
+
const end = startOrRange.end;
|
|
874
|
+
|
|
875
|
+
if (start !== end || cellData.length > 0) {
|
|
876
|
+
this._edits.push({
|
|
877
|
+
_type: FileEditType.CellReplace,
|
|
878
|
+
uri,
|
|
879
|
+
index: start,
|
|
880
|
+
count: end - start,
|
|
881
|
+
cells: cellData,
|
|
882
|
+
metadata,
|
|
883
|
+
});
|
|
884
|
+
}
|
|
885
|
+
}
|
|
886
|
+
|
|
887
|
+
private replaceNotebookCellMetadata(
|
|
888
|
+
uri: URI,
|
|
889
|
+
index: number,
|
|
890
|
+
cellMetadata: Record<string, any>,
|
|
891
|
+
metadata?: vscode.WorkspaceEditEntryMetadata,
|
|
892
|
+
): void {
|
|
893
|
+
this._edits.push({
|
|
894
|
+
_type: FileEditType.Cell,
|
|
895
|
+
metadata,
|
|
896
|
+
uri,
|
|
897
|
+
edit: { editType: CellEditType.Metadata, index, metadata: cellMetadata },
|
|
898
|
+
});
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
// --- text
|
|
902
|
+
|
|
903
|
+
replace(
|
|
904
|
+
uri: URI,
|
|
905
|
+
range: Range,
|
|
906
|
+
newText: string,
|
|
907
|
+
metadata?: vscode.WorkspaceEditEntryMetadata,
|
|
908
|
+
): void {
|
|
909
|
+
this._edits.push({
|
|
910
|
+
_type: FileEditType.Text,
|
|
911
|
+
uri,
|
|
912
|
+
edit: new TextEdit(range, newText),
|
|
913
|
+
metadata,
|
|
914
|
+
});
|
|
915
|
+
}
|
|
916
|
+
|
|
917
|
+
insert(
|
|
918
|
+
resource: URI,
|
|
919
|
+
position: Position,
|
|
920
|
+
newText: string,
|
|
921
|
+
metadata?: vscode.WorkspaceEditEntryMetadata,
|
|
922
|
+
): void {
|
|
923
|
+
this.replace(resource, new Range(position, position), newText, metadata);
|
|
924
|
+
}
|
|
925
|
+
|
|
926
|
+
delete(
|
|
927
|
+
resource: URI,
|
|
928
|
+
range: Range,
|
|
929
|
+
metadata?: vscode.WorkspaceEditEntryMetadata,
|
|
930
|
+
): void {
|
|
931
|
+
this.replace(resource, range, '', metadata);
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
// --- text (Maplike)
|
|
935
|
+
|
|
936
|
+
has(uri: URI): boolean {
|
|
937
|
+
return this._edits.some(
|
|
938
|
+
(edit) =>
|
|
939
|
+
edit._type === FileEditType.Text && edit.uri.toString() === uri.toString(),
|
|
940
|
+
);
|
|
941
|
+
}
|
|
942
|
+
|
|
943
|
+
set(uri: URI, edits: ReadonlyArray<TextEdit | SnippetTextEdit>): void;
|
|
944
|
+
set(
|
|
945
|
+
uri: URI,
|
|
946
|
+
edits: ReadonlyArray<
|
|
947
|
+
[TextEdit | SnippetTextEdit, vscode.WorkspaceEditEntryMetadata]
|
|
948
|
+
>,
|
|
949
|
+
): void;
|
|
950
|
+
set(uri: URI, edits: readonly NotebookEdit[]): void;
|
|
951
|
+
set(
|
|
952
|
+
uri: URI,
|
|
953
|
+
edits: ReadonlyArray<[NotebookEdit, vscode.WorkspaceEditEntryMetadata]>,
|
|
954
|
+
): void;
|
|
955
|
+
|
|
956
|
+
set(
|
|
957
|
+
uri: URI,
|
|
958
|
+
edits:
|
|
959
|
+
| null
|
|
960
|
+
| undefined
|
|
961
|
+
| ReadonlyArray<
|
|
962
|
+
| TextEdit
|
|
963
|
+
| SnippetTextEdit
|
|
964
|
+
| NotebookEdit
|
|
965
|
+
| [NotebookEdit, vscode.WorkspaceEditEntryMetadata]
|
|
966
|
+
| [TextEdit | SnippetTextEdit, vscode.WorkspaceEditEntryMetadata]
|
|
967
|
+
>,
|
|
968
|
+
): void {
|
|
969
|
+
if (!edits) {
|
|
970
|
+
// remove all text, snippet, or notebook edits for `uri`
|
|
971
|
+
for (let i = 0; i < this._edits.length; i++) {
|
|
972
|
+
const element = this._edits[i];
|
|
973
|
+
switch (element._type) {
|
|
974
|
+
case FileEditType.Text:
|
|
975
|
+
case FileEditType.Snippet:
|
|
976
|
+
case FileEditType.Cell:
|
|
977
|
+
case FileEditType.CellReplace:
|
|
978
|
+
if (element.uri.toString() === uri.toString()) {
|
|
979
|
+
this._edits[i] = undefined!; // will be coalesced down below
|
|
980
|
+
}
|
|
981
|
+
break;
|
|
982
|
+
}
|
|
983
|
+
}
|
|
984
|
+
coalesceInPlace(this._edits);
|
|
985
|
+
} else {
|
|
986
|
+
// append edit to the end
|
|
987
|
+
for (const editOrTuple of edits) {
|
|
988
|
+
if (!editOrTuple) {
|
|
989
|
+
continue;
|
|
990
|
+
}
|
|
991
|
+
let edit: TextEdit | SnippetTextEdit | NotebookEdit;
|
|
992
|
+
let metadata: vscode.WorkspaceEditEntryMetadata | undefined;
|
|
993
|
+
if (Array.isArray(editOrTuple)) {
|
|
994
|
+
edit = editOrTuple[0];
|
|
995
|
+
metadata = editOrTuple[1];
|
|
996
|
+
} else {
|
|
997
|
+
edit = editOrTuple;
|
|
998
|
+
}
|
|
999
|
+
if (NotebookEdit.isNotebookCellEdit(edit)) {
|
|
1000
|
+
if (edit.newCellMetadata) {
|
|
1001
|
+
this.replaceNotebookCellMetadata(
|
|
1002
|
+
uri,
|
|
1003
|
+
edit.range.start,
|
|
1004
|
+
edit.newCellMetadata,
|
|
1005
|
+
metadata,
|
|
1006
|
+
);
|
|
1007
|
+
} else if (edit.newNotebookMetadata) {
|
|
1008
|
+
this.replaceNotebookMetadata(uri, edit.newNotebookMetadata, metadata);
|
|
1009
|
+
} else {
|
|
1010
|
+
this.replaceNotebookCells(uri, edit.range, edit.newCells, metadata);
|
|
1011
|
+
}
|
|
1012
|
+
} else if (SnippetTextEdit.isSnippetTextEdit(edit)) {
|
|
1013
|
+
this._edits.push({
|
|
1014
|
+
_type: FileEditType.Snippet,
|
|
1015
|
+
uri,
|
|
1016
|
+
range: edit.range,
|
|
1017
|
+
edit: edit.snippet,
|
|
1018
|
+
metadata,
|
|
1019
|
+
});
|
|
1020
|
+
} else {
|
|
1021
|
+
this._edits.push({ _type: FileEditType.Text, uri, edit, metadata });
|
|
1022
|
+
}
|
|
1023
|
+
}
|
|
1024
|
+
}
|
|
1025
|
+
}
|
|
1026
|
+
|
|
1027
|
+
get(uri: URI): TextEdit[] {
|
|
1028
|
+
const res: TextEdit[] = [];
|
|
1029
|
+
for (const candidate of this._edits) {
|
|
1030
|
+
if (
|
|
1031
|
+
candidate._type === FileEditType.Text &&
|
|
1032
|
+
candidate.uri.toString() === uri.toString()
|
|
1033
|
+
) {
|
|
1034
|
+
res.push(candidate.edit);
|
|
1035
|
+
}
|
|
1036
|
+
}
|
|
1037
|
+
return res;
|
|
1038
|
+
}
|
|
1039
|
+
|
|
1040
|
+
entries(): [URI, TextEdit[]][] {
|
|
1041
|
+
const textEdits = new ResourceMap<[URI, TextEdit[]]>();
|
|
1042
|
+
for (const candidate of this._edits) {
|
|
1043
|
+
if (candidate._type === FileEditType.Text) {
|
|
1044
|
+
let textEdit = textEdits.get(candidate.uri);
|
|
1045
|
+
if (!textEdit) {
|
|
1046
|
+
textEdit = [candidate.uri, []];
|
|
1047
|
+
textEdits.set(candidate.uri, textEdit);
|
|
1048
|
+
}
|
|
1049
|
+
textEdit[1].push(candidate.edit);
|
|
1050
|
+
}
|
|
1051
|
+
}
|
|
1052
|
+
return [...textEdits.values()];
|
|
1053
|
+
}
|
|
1054
|
+
|
|
1055
|
+
get size(): number {
|
|
1056
|
+
return this.entries().length;
|
|
1057
|
+
}
|
|
1058
|
+
|
|
1059
|
+
toJSON(): any {
|
|
1060
|
+
return this.entries();
|
|
1061
|
+
}
|
|
1062
|
+
}
|
|
1063
|
+
|
|
1064
|
+
export class SnippetString {
|
|
1065
|
+
static isSnippetString(thing: any): thing is SnippetString {
|
|
1066
|
+
if (thing instanceof SnippetString) {
|
|
1067
|
+
return true;
|
|
1068
|
+
}
|
|
1069
|
+
if (!thing) {
|
|
1070
|
+
return false;
|
|
1071
|
+
}
|
|
1072
|
+
return typeof (<SnippetString>thing).value === 'string';
|
|
1073
|
+
}
|
|
1074
|
+
|
|
1075
|
+
private static _escape(value: string): string {
|
|
1076
|
+
return value.replace(/\$|}|\\/g, '\\$&');
|
|
1077
|
+
}
|
|
1078
|
+
|
|
1079
|
+
private _tabstop = 1;
|
|
1080
|
+
|
|
1081
|
+
value: string;
|
|
1082
|
+
|
|
1083
|
+
constructor(value?: string) {
|
|
1084
|
+
this.value = value || '';
|
|
1085
|
+
}
|
|
1086
|
+
|
|
1087
|
+
appendText(string: string): SnippetString {
|
|
1088
|
+
this.value += SnippetString._escape(string);
|
|
1089
|
+
return this;
|
|
1090
|
+
}
|
|
1091
|
+
|
|
1092
|
+
appendTabstop(number: number = this._tabstop++): SnippetString {
|
|
1093
|
+
this.value += '$';
|
|
1094
|
+
this.value += number;
|
|
1095
|
+
return this;
|
|
1096
|
+
}
|
|
1097
|
+
|
|
1098
|
+
appendPlaceholder(
|
|
1099
|
+
value: string | ((snippet: SnippetString) => any),
|
|
1100
|
+
number: number = this._tabstop++,
|
|
1101
|
+
): SnippetString {
|
|
1102
|
+
if (typeof value === 'function') {
|
|
1103
|
+
const nested = new SnippetString();
|
|
1104
|
+
nested._tabstop = this._tabstop;
|
|
1105
|
+
value(nested);
|
|
1106
|
+
this._tabstop = nested._tabstop;
|
|
1107
|
+
value = nested.value;
|
|
1108
|
+
} else {
|
|
1109
|
+
value = SnippetString._escape(value);
|
|
1110
|
+
}
|
|
1111
|
+
|
|
1112
|
+
this.value += '${';
|
|
1113
|
+
this.value += number;
|
|
1114
|
+
this.value += ':';
|
|
1115
|
+
this.value += value;
|
|
1116
|
+
this.value += '}';
|
|
1117
|
+
|
|
1118
|
+
return this;
|
|
1119
|
+
}
|
|
1120
|
+
|
|
1121
|
+
appendChoice(values: string[], number: number = this._tabstop++): SnippetString {
|
|
1122
|
+
const value = values.map((s) => s.replaceAll(/[|\\,]/g, '\\$&')).join(',');
|
|
1123
|
+
|
|
1124
|
+
this.value += '${';
|
|
1125
|
+
this.value += number;
|
|
1126
|
+
this.value += '|';
|
|
1127
|
+
this.value += value;
|
|
1128
|
+
this.value += '|}';
|
|
1129
|
+
|
|
1130
|
+
return this;
|
|
1131
|
+
}
|
|
1132
|
+
|
|
1133
|
+
appendVariable(
|
|
1134
|
+
name: string,
|
|
1135
|
+
defaultValue?: string | ((snippet: SnippetString) => any),
|
|
1136
|
+
): SnippetString {
|
|
1137
|
+
if (typeof defaultValue === 'function') {
|
|
1138
|
+
const nested = new SnippetString();
|
|
1139
|
+
nested._tabstop = this._tabstop;
|
|
1140
|
+
defaultValue(nested);
|
|
1141
|
+
this._tabstop = nested._tabstop;
|
|
1142
|
+
defaultValue = nested.value;
|
|
1143
|
+
} else if (typeof defaultValue === 'string') {
|
|
1144
|
+
defaultValue = defaultValue.replace(/\$|}/g, '\\$&'); // CodeQL [SM02383] I do not want to escape backslashes here
|
|
1145
|
+
}
|
|
1146
|
+
|
|
1147
|
+
this.value += '${';
|
|
1148
|
+
this.value += name;
|
|
1149
|
+
if (defaultValue) {
|
|
1150
|
+
this.value += ':';
|
|
1151
|
+
this.value += defaultValue;
|
|
1152
|
+
}
|
|
1153
|
+
this.value += '}';
|
|
1154
|
+
|
|
1155
|
+
return this;
|
|
1156
|
+
}
|
|
1157
|
+
}
|
|
1158
|
+
|
|
1159
|
+
export enum DiagnosticTag {
|
|
1160
|
+
Unnecessary = 1,
|
|
1161
|
+
Deprecated = 2,
|
|
1162
|
+
}
|
|
1163
|
+
|
|
1164
|
+
export enum DiagnosticSeverity {
|
|
1165
|
+
Hint = 3,
|
|
1166
|
+
Information = 2,
|
|
1167
|
+
Warning = 1,
|
|
1168
|
+
Error = 0,
|
|
1169
|
+
}
|
|
1170
|
+
|
|
1171
|
+
export class Location {
|
|
1172
|
+
static isLocation(thing: any): thing is vscode.Location {
|
|
1173
|
+
if (thing instanceof Location) {
|
|
1174
|
+
return true;
|
|
1175
|
+
}
|
|
1176
|
+
if (!thing) {
|
|
1177
|
+
return false;
|
|
1178
|
+
}
|
|
1179
|
+
return Range.isRange((<Location>thing).range) && URI.isUri((<Location>thing).uri);
|
|
1180
|
+
}
|
|
1181
|
+
|
|
1182
|
+
uri: URI;
|
|
1183
|
+
range!: Range;
|
|
1184
|
+
|
|
1185
|
+
constructor(uri: URI, rangeOrPosition: Range | Position) {
|
|
1186
|
+
this.uri = uri;
|
|
1187
|
+
|
|
1188
|
+
if (!rangeOrPosition) {
|
|
1189
|
+
//that's OK
|
|
1190
|
+
} else if (Range.isRange(rangeOrPosition)) {
|
|
1191
|
+
this.range = Range.of(rangeOrPosition);
|
|
1192
|
+
} else if (Position.isPosition(rangeOrPosition)) {
|
|
1193
|
+
this.range = new Range(rangeOrPosition, rangeOrPosition);
|
|
1194
|
+
} else {
|
|
1195
|
+
throw new Error('Illegal argument');
|
|
1196
|
+
}
|
|
1197
|
+
}
|
|
1198
|
+
|
|
1199
|
+
toJSON(): any {
|
|
1200
|
+
return {
|
|
1201
|
+
uri: this.uri,
|
|
1202
|
+
range: this.range,
|
|
1203
|
+
};
|
|
1204
|
+
}
|
|
1205
|
+
}
|
|
1206
|
+
|
|
1207
|
+
export class DiagnosticRelatedInformation {
|
|
1208
|
+
static is(thing: any): thing is DiagnosticRelatedInformation {
|
|
1209
|
+
if (!thing) {
|
|
1210
|
+
return false;
|
|
1211
|
+
}
|
|
1212
|
+
return (
|
|
1213
|
+
typeof (<DiagnosticRelatedInformation>thing).message === 'string' &&
|
|
1214
|
+
(<DiagnosticRelatedInformation>thing).location &&
|
|
1215
|
+
Range.isRange((<DiagnosticRelatedInformation>thing).location.range) &&
|
|
1216
|
+
URI.isUri((<DiagnosticRelatedInformation>thing).location.uri)
|
|
1217
|
+
);
|
|
1218
|
+
}
|
|
1219
|
+
|
|
1220
|
+
location: Location;
|
|
1221
|
+
message: string;
|
|
1222
|
+
|
|
1223
|
+
constructor(location: Location, message: string) {
|
|
1224
|
+
this.location = location;
|
|
1225
|
+
this.message = message;
|
|
1226
|
+
}
|
|
1227
|
+
|
|
1228
|
+
static isEqual(
|
|
1229
|
+
a: DiagnosticRelatedInformation,
|
|
1230
|
+
b: DiagnosticRelatedInformation,
|
|
1231
|
+
): boolean {
|
|
1232
|
+
if (a === b) {
|
|
1233
|
+
return true;
|
|
1234
|
+
}
|
|
1235
|
+
if (!a || !b) {
|
|
1236
|
+
return false;
|
|
1237
|
+
}
|
|
1238
|
+
return (
|
|
1239
|
+
a.message === b.message &&
|
|
1240
|
+
a.location.range.isEqual(b.location.range) &&
|
|
1241
|
+
a.location.uri.toString() === b.location.uri.toString()
|
|
1242
|
+
);
|
|
1243
|
+
}
|
|
1244
|
+
}
|
|
1245
|
+
|
|
1246
|
+
export class Diagnostic {
|
|
1247
|
+
range: Range;
|
|
1248
|
+
message: string;
|
|
1249
|
+
severity: DiagnosticSeverity;
|
|
1250
|
+
source?: string;
|
|
1251
|
+
code?: string | number | { value: string | number; target: URI };
|
|
1252
|
+
relatedInformation?: DiagnosticRelatedInformation[];
|
|
1253
|
+
tags?: DiagnosticTag[];
|
|
1254
|
+
|
|
1255
|
+
constructor(
|
|
1256
|
+
range: Range,
|
|
1257
|
+
message: string,
|
|
1258
|
+
severity: DiagnosticSeverity = DiagnosticSeverity.Error,
|
|
1259
|
+
) {
|
|
1260
|
+
if (!Range.isRange(range)) {
|
|
1261
|
+
throw new TypeError('range must be set');
|
|
1262
|
+
}
|
|
1263
|
+
if (!message) {
|
|
1264
|
+
throw new TypeError('message must be set');
|
|
1265
|
+
}
|
|
1266
|
+
this.range = range;
|
|
1267
|
+
this.message = message;
|
|
1268
|
+
this.severity = severity;
|
|
1269
|
+
}
|
|
1270
|
+
|
|
1271
|
+
toJSON(): any {
|
|
1272
|
+
return {
|
|
1273
|
+
severity: DiagnosticSeverity[this.severity],
|
|
1274
|
+
message: this.message,
|
|
1275
|
+
range: this.range,
|
|
1276
|
+
source: this.source,
|
|
1277
|
+
code: this.code,
|
|
1278
|
+
};
|
|
1279
|
+
}
|
|
1280
|
+
|
|
1281
|
+
static isEqual(a: Diagnostic | undefined, b: Diagnostic | undefined): boolean {
|
|
1282
|
+
if (a === b) {
|
|
1283
|
+
return true;
|
|
1284
|
+
}
|
|
1285
|
+
if (!a || !b) {
|
|
1286
|
+
return false;
|
|
1287
|
+
}
|
|
1288
|
+
return (
|
|
1289
|
+
a.message === b.message &&
|
|
1290
|
+
a.severity === b.severity &&
|
|
1291
|
+
a.code === b.code &&
|
|
1292
|
+
a.severity === b.severity &&
|
|
1293
|
+
a.source === b.source &&
|
|
1294
|
+
a.range.isEqual(b.range) &&
|
|
1295
|
+
equals(a.tags, b.tags) &&
|
|
1296
|
+
equals(
|
|
1297
|
+
a.relatedInformation,
|
|
1298
|
+
b.relatedInformation,
|
|
1299
|
+
DiagnosticRelatedInformation.isEqual,
|
|
1300
|
+
)
|
|
1301
|
+
);
|
|
1302
|
+
}
|
|
1303
|
+
}
|
|
1304
|
+
|
|
1305
|
+
export class Hover {
|
|
1306
|
+
public contents: (vscode.MarkdownString | vscode.MarkedString)[];
|
|
1307
|
+
public range: Range | undefined;
|
|
1308
|
+
|
|
1309
|
+
constructor(
|
|
1310
|
+
contents:
|
|
1311
|
+
| vscode.MarkdownString
|
|
1312
|
+
| vscode.MarkedString
|
|
1313
|
+
| (vscode.MarkdownString | vscode.MarkedString)[],
|
|
1314
|
+
range?: Range,
|
|
1315
|
+
) {
|
|
1316
|
+
if (!contents) {
|
|
1317
|
+
throw new Error('Illegal argument, contents must be defined');
|
|
1318
|
+
}
|
|
1319
|
+
if (Array.isArray(contents)) {
|
|
1320
|
+
this.contents = contents;
|
|
1321
|
+
} else {
|
|
1322
|
+
this.contents = [contents];
|
|
1323
|
+
}
|
|
1324
|
+
this.range = range;
|
|
1325
|
+
}
|
|
1326
|
+
}
|
|
1327
|
+
|
|
1328
|
+
export enum DocumentHighlightKind {
|
|
1329
|
+
Text = 0,
|
|
1330
|
+
Read = 1,
|
|
1331
|
+
Write = 2,
|
|
1332
|
+
}
|
|
1333
|
+
|
|
1334
|
+
export class DocumentHighlight {
|
|
1335
|
+
range: Range;
|
|
1336
|
+
kind: DocumentHighlightKind;
|
|
1337
|
+
|
|
1338
|
+
constructor(range: Range, kind: DocumentHighlightKind = DocumentHighlightKind.Text) {
|
|
1339
|
+
this.range = range;
|
|
1340
|
+
this.kind = kind;
|
|
1341
|
+
}
|
|
1342
|
+
|
|
1343
|
+
toJSON(): any {
|
|
1344
|
+
return {
|
|
1345
|
+
range: this.range,
|
|
1346
|
+
kind: DocumentHighlightKind[this.kind],
|
|
1347
|
+
};
|
|
1348
|
+
}
|
|
1349
|
+
}
|
|
1350
|
+
|
|
1351
|
+
export class MultiDocumentHighlight {
|
|
1352
|
+
uri: URI;
|
|
1353
|
+
highlights: DocumentHighlight[];
|
|
1354
|
+
|
|
1355
|
+
constructor(uri: URI, highlights: DocumentHighlight[]) {
|
|
1356
|
+
this.uri = uri;
|
|
1357
|
+
this.highlights = highlights;
|
|
1358
|
+
}
|
|
1359
|
+
|
|
1360
|
+
toJSON(): any {
|
|
1361
|
+
return {
|
|
1362
|
+
uri: this.uri,
|
|
1363
|
+
highlights: this.highlights.map((h) => h.toJSON()),
|
|
1364
|
+
};
|
|
1365
|
+
}
|
|
1366
|
+
}
|
|
1367
|
+
|
|
1368
|
+
export enum SymbolKind {
|
|
1369
|
+
File = 0,
|
|
1370
|
+
Module = 1,
|
|
1371
|
+
Namespace = 2,
|
|
1372
|
+
Package = 3,
|
|
1373
|
+
Class = 4,
|
|
1374
|
+
Method = 5,
|
|
1375
|
+
Property = 6,
|
|
1376
|
+
Field = 7,
|
|
1377
|
+
Constructor = 8,
|
|
1378
|
+
Enum = 9,
|
|
1379
|
+
Interface = 10,
|
|
1380
|
+
Function = 11,
|
|
1381
|
+
Variable = 12,
|
|
1382
|
+
Constant = 13,
|
|
1383
|
+
String = 14,
|
|
1384
|
+
Number = 15,
|
|
1385
|
+
Boolean = 16,
|
|
1386
|
+
Array = 17,
|
|
1387
|
+
Object = 18,
|
|
1388
|
+
Key = 19,
|
|
1389
|
+
Null = 20,
|
|
1390
|
+
EnumMember = 21,
|
|
1391
|
+
Struct = 22,
|
|
1392
|
+
Event = 23,
|
|
1393
|
+
Operator = 24,
|
|
1394
|
+
TypeParameter = 25,
|
|
1395
|
+
}
|
|
1396
|
+
|
|
1397
|
+
export enum SymbolTag {
|
|
1398
|
+
Deprecated = 1,
|
|
1399
|
+
}
|
|
1400
|
+
|
|
1401
|
+
export class SymbolInformation {
|
|
1402
|
+
static validate(candidate: SymbolInformation): void {
|
|
1403
|
+
if (!candidate.name) {
|
|
1404
|
+
throw new Error('name must not be falsy');
|
|
1405
|
+
}
|
|
1406
|
+
}
|
|
1407
|
+
|
|
1408
|
+
name: string;
|
|
1409
|
+
location!: Location;
|
|
1410
|
+
kind: SymbolKind;
|
|
1411
|
+
tags?: SymbolTag[];
|
|
1412
|
+
containerName: string;
|
|
1413
|
+
|
|
1414
|
+
constructor(
|
|
1415
|
+
name: string,
|
|
1416
|
+
kind: SymbolKind,
|
|
1417
|
+
containerName: string | undefined,
|
|
1418
|
+
location: Location,
|
|
1419
|
+
);
|
|
1420
|
+
constructor(
|
|
1421
|
+
name: string,
|
|
1422
|
+
kind: SymbolKind,
|
|
1423
|
+
range: Range,
|
|
1424
|
+
uri?: URI,
|
|
1425
|
+
containerName?: string,
|
|
1426
|
+
);
|
|
1427
|
+
constructor(
|
|
1428
|
+
name: string,
|
|
1429
|
+
kind: SymbolKind,
|
|
1430
|
+
rangeOrContainer: string | undefined | Range,
|
|
1431
|
+
locationOrUri?: Location | URI,
|
|
1432
|
+
containerName?: string,
|
|
1433
|
+
) {
|
|
1434
|
+
this.name = name;
|
|
1435
|
+
this.kind = kind;
|
|
1436
|
+
this.containerName = containerName ?? '';
|
|
1437
|
+
|
|
1438
|
+
if (typeof rangeOrContainer === 'string') {
|
|
1439
|
+
this.containerName = rangeOrContainer;
|
|
1440
|
+
}
|
|
1441
|
+
|
|
1442
|
+
if (locationOrUri instanceof Location) {
|
|
1443
|
+
this.location = locationOrUri;
|
|
1444
|
+
} else if (rangeOrContainer instanceof Range) {
|
|
1445
|
+
this.location = new Location(locationOrUri!, rangeOrContainer);
|
|
1446
|
+
}
|
|
1447
|
+
|
|
1448
|
+
SymbolInformation.validate(this);
|
|
1449
|
+
}
|
|
1450
|
+
|
|
1451
|
+
toJSON(): any {
|
|
1452
|
+
return {
|
|
1453
|
+
name: this.name,
|
|
1454
|
+
kind: SymbolKind[this.kind],
|
|
1455
|
+
location: this.location,
|
|
1456
|
+
containerName: this.containerName,
|
|
1457
|
+
};
|
|
1458
|
+
}
|
|
1459
|
+
}
|
|
1460
|
+
|
|
1461
|
+
export class DocumentSymbol {
|
|
1462
|
+
static validate(candidate: DocumentSymbol): void {
|
|
1463
|
+
if (!candidate.name) {
|
|
1464
|
+
throw new Error('name must not be falsy');
|
|
1465
|
+
}
|
|
1466
|
+
if (!candidate.range.contains(candidate.selectionRange)) {
|
|
1467
|
+
throw new Error('selectionRange must be contained in fullRange');
|
|
1468
|
+
}
|
|
1469
|
+
candidate.children?.forEach(DocumentSymbol.validate);
|
|
1470
|
+
}
|
|
1471
|
+
|
|
1472
|
+
name: string;
|
|
1473
|
+
detail: string;
|
|
1474
|
+
kind: SymbolKind;
|
|
1475
|
+
tags?: SymbolTag[];
|
|
1476
|
+
range: Range;
|
|
1477
|
+
selectionRange: Range;
|
|
1478
|
+
children: DocumentSymbol[];
|
|
1479
|
+
|
|
1480
|
+
constructor(
|
|
1481
|
+
name: string,
|
|
1482
|
+
detail: string,
|
|
1483
|
+
kind: SymbolKind,
|
|
1484
|
+
range: Range,
|
|
1485
|
+
selectionRange: Range,
|
|
1486
|
+
) {
|
|
1487
|
+
this.name = name;
|
|
1488
|
+
this.detail = detail;
|
|
1489
|
+
this.kind = kind;
|
|
1490
|
+
this.range = range;
|
|
1491
|
+
this.selectionRange = selectionRange;
|
|
1492
|
+
this.children = [];
|
|
1493
|
+
|
|
1494
|
+
DocumentSymbol.validate(this);
|
|
1495
|
+
}
|
|
1496
|
+
}
|
|
1497
|
+
|
|
1498
|
+
export enum CodeActionTriggerKind {
|
|
1499
|
+
Invoke = 1,
|
|
1500
|
+
Automatic = 2,
|
|
1501
|
+
}
|
|
1502
|
+
|
|
1503
|
+
export class CodeAction {
|
|
1504
|
+
title: string;
|
|
1505
|
+
|
|
1506
|
+
command?: vscode.Command;
|
|
1507
|
+
|
|
1508
|
+
edit?: WorkspaceEdit;
|
|
1509
|
+
|
|
1510
|
+
diagnostics?: vscode.Diagnostic[];
|
|
1511
|
+
|
|
1512
|
+
kind?: CodeActionKind;
|
|
1513
|
+
|
|
1514
|
+
isPreferred?: boolean;
|
|
1515
|
+
|
|
1516
|
+
disabled?: { reason: string };
|
|
1517
|
+
|
|
1518
|
+
constructor(title: string, kind?: CodeActionKind) {
|
|
1519
|
+
this.title = title;
|
|
1520
|
+
this.kind = kind;
|
|
1521
|
+
}
|
|
1522
|
+
}
|
|
1523
|
+
|
|
1524
|
+
export class CodeActionKind {
|
|
1525
|
+
private static readonly sep = '.';
|
|
1526
|
+
|
|
1527
|
+
public static Empty: CodeActionKind;
|
|
1528
|
+
public static QuickFix: CodeActionKind;
|
|
1529
|
+
public static Refactor: CodeActionKind;
|
|
1530
|
+
public static RefactorExtract: CodeActionKind;
|
|
1531
|
+
public static RefactorInline: CodeActionKind;
|
|
1532
|
+
public static RefactorMove: CodeActionKind;
|
|
1533
|
+
public static RefactorRewrite: CodeActionKind;
|
|
1534
|
+
public static Source: CodeActionKind;
|
|
1535
|
+
public static SourceOrganizeImports: CodeActionKind;
|
|
1536
|
+
public static SourceFixAll: CodeActionKind;
|
|
1537
|
+
public static Notebook: CodeActionKind;
|
|
1538
|
+
|
|
1539
|
+
constructor(public readonly value: string) {}
|
|
1540
|
+
|
|
1541
|
+
public append(parts: string): CodeActionKind {
|
|
1542
|
+
return new CodeActionKind(
|
|
1543
|
+
this.value ? this.value + CodeActionKind.sep + parts : parts,
|
|
1544
|
+
);
|
|
1545
|
+
}
|
|
1546
|
+
|
|
1547
|
+
public intersects(other: CodeActionKind): boolean {
|
|
1548
|
+
return this.contains(other) || other.contains(this);
|
|
1549
|
+
}
|
|
1550
|
+
|
|
1551
|
+
public contains(other: CodeActionKind): boolean {
|
|
1552
|
+
return (
|
|
1553
|
+
this.value === other.value ||
|
|
1554
|
+
other.value.startsWith(this.value + CodeActionKind.sep)
|
|
1555
|
+
);
|
|
1556
|
+
}
|
|
1557
|
+
}
|
|
1558
|
+
|
|
1559
|
+
CodeActionKind.Empty = new CodeActionKind('');
|
|
1560
|
+
CodeActionKind.QuickFix = CodeActionKind.Empty.append('quickfix');
|
|
1561
|
+
CodeActionKind.Refactor = CodeActionKind.Empty.append('refactor');
|
|
1562
|
+
CodeActionKind.RefactorExtract = CodeActionKind.Refactor.append('extract');
|
|
1563
|
+
CodeActionKind.RefactorInline = CodeActionKind.Refactor.append('inline');
|
|
1564
|
+
CodeActionKind.RefactorMove = CodeActionKind.Refactor.append('move');
|
|
1565
|
+
CodeActionKind.RefactorRewrite = CodeActionKind.Refactor.append('rewrite');
|
|
1566
|
+
CodeActionKind.Source = CodeActionKind.Empty.append('source');
|
|
1567
|
+
CodeActionKind.SourceOrganizeImports = CodeActionKind.Source.append('organizeImports');
|
|
1568
|
+
CodeActionKind.SourceFixAll = CodeActionKind.Source.append('fixAll');
|
|
1569
|
+
CodeActionKind.Notebook = CodeActionKind.Empty.append('notebook');
|
|
1570
|
+
|
|
1571
|
+
export class SelectionRange {
|
|
1572
|
+
range: Range;
|
|
1573
|
+
parent?: SelectionRange;
|
|
1574
|
+
|
|
1575
|
+
constructor(range: Range, parent?: SelectionRange) {
|
|
1576
|
+
this.range = range;
|
|
1577
|
+
this.parent = parent;
|
|
1578
|
+
|
|
1579
|
+
if (parent && !parent.range.contains(this.range)) {
|
|
1580
|
+
throw new Error('Invalid argument: parent must contain this range');
|
|
1581
|
+
}
|
|
1582
|
+
}
|
|
1583
|
+
}
|
|
1584
|
+
|
|
1585
|
+
export class CallHierarchyItem {
|
|
1586
|
+
_sessionId?: string;
|
|
1587
|
+
_itemId?: string;
|
|
1588
|
+
|
|
1589
|
+
kind: SymbolKind;
|
|
1590
|
+
tags?: SymbolTag[];
|
|
1591
|
+
name: string;
|
|
1592
|
+
detail?: string;
|
|
1593
|
+
uri: URI;
|
|
1594
|
+
range: Range;
|
|
1595
|
+
selectionRange: Range;
|
|
1596
|
+
|
|
1597
|
+
constructor(
|
|
1598
|
+
kind: SymbolKind,
|
|
1599
|
+
name: string,
|
|
1600
|
+
detail: string,
|
|
1601
|
+
uri: URI,
|
|
1602
|
+
range: Range,
|
|
1603
|
+
selectionRange: Range,
|
|
1604
|
+
) {
|
|
1605
|
+
this.kind = kind;
|
|
1606
|
+
this.name = name;
|
|
1607
|
+
this.detail = detail;
|
|
1608
|
+
this.uri = uri;
|
|
1609
|
+
this.range = range;
|
|
1610
|
+
this.selectionRange = selectionRange;
|
|
1611
|
+
}
|
|
1612
|
+
}
|
|
1613
|
+
|
|
1614
|
+
export class CallHierarchyIncomingCall {
|
|
1615
|
+
from: vscode.CallHierarchyItem;
|
|
1616
|
+
fromRanges: vscode.Range[];
|
|
1617
|
+
|
|
1618
|
+
constructor(item: vscode.CallHierarchyItem, fromRanges: vscode.Range[]) {
|
|
1619
|
+
this.fromRanges = fromRanges;
|
|
1620
|
+
this.from = item;
|
|
1621
|
+
}
|
|
1622
|
+
}
|
|
1623
|
+
export class CallHierarchyOutgoingCall {
|
|
1624
|
+
to: vscode.CallHierarchyItem;
|
|
1625
|
+
fromRanges: vscode.Range[];
|
|
1626
|
+
|
|
1627
|
+
constructor(item: vscode.CallHierarchyItem, fromRanges: vscode.Range[]) {
|
|
1628
|
+
this.fromRanges = fromRanges;
|
|
1629
|
+
this.to = item;
|
|
1630
|
+
}
|
|
1631
|
+
}
|
|
1632
|
+
|
|
1633
|
+
export enum LanguageStatusSeverity {
|
|
1634
|
+
Information = 0,
|
|
1635
|
+
Warning = 1,
|
|
1636
|
+
Error = 2,
|
|
1637
|
+
}
|
|
1638
|
+
|
|
1639
|
+
export class CodeLens {
|
|
1640
|
+
range: Range;
|
|
1641
|
+
|
|
1642
|
+
command: vscode.Command | undefined;
|
|
1643
|
+
|
|
1644
|
+
constructor(range: Range, command?: vscode.Command) {
|
|
1645
|
+
this.range = range;
|
|
1646
|
+
this.command = command;
|
|
1647
|
+
}
|
|
1648
|
+
|
|
1649
|
+
get isResolved(): boolean {
|
|
1650
|
+
return !!this.command;
|
|
1651
|
+
}
|
|
1652
|
+
}
|
|
1653
|
+
|
|
1654
|
+
export class MarkdownString implements vscode.MarkdownString {
|
|
1655
|
+
readonly #delegate: BaseMarkdownString;
|
|
1656
|
+
|
|
1657
|
+
static isMarkdownString(thing: any): thing is vscode.MarkdownString {
|
|
1658
|
+
if (thing instanceof MarkdownString) {
|
|
1659
|
+
return true;
|
|
1660
|
+
}
|
|
1661
|
+
return (
|
|
1662
|
+
thing &&
|
|
1663
|
+
thing.appendCodeblock &&
|
|
1664
|
+
thing.appendMarkdown &&
|
|
1665
|
+
thing.appendText &&
|
|
1666
|
+
thing.value !== undefined
|
|
1667
|
+
);
|
|
1668
|
+
}
|
|
1669
|
+
|
|
1670
|
+
constructor(value?: string, supportThemeIcons = false) {
|
|
1671
|
+
this.#delegate = new BaseMarkdownString(value, { supportThemeIcons });
|
|
1672
|
+
}
|
|
1673
|
+
|
|
1674
|
+
get value(): string {
|
|
1675
|
+
return this.#delegate.value;
|
|
1676
|
+
}
|
|
1677
|
+
set value(value: string) {
|
|
1678
|
+
this.#delegate.value = value;
|
|
1679
|
+
}
|
|
1680
|
+
|
|
1681
|
+
get isTrusted(): boolean | MarkdownStringTrustedOptions | undefined {
|
|
1682
|
+
return this.#delegate.isTrusted;
|
|
1683
|
+
}
|
|
1684
|
+
|
|
1685
|
+
set isTrusted(value: boolean | MarkdownStringTrustedOptions | undefined) {
|
|
1686
|
+
this.#delegate.isTrusted = value;
|
|
1687
|
+
}
|
|
1688
|
+
|
|
1689
|
+
get supportThemeIcons(): boolean | undefined {
|
|
1690
|
+
return this.#delegate.supportThemeIcons;
|
|
1691
|
+
}
|
|
1692
|
+
|
|
1693
|
+
set supportThemeIcons(value: boolean | undefined) {
|
|
1694
|
+
this.#delegate.supportThemeIcons = value;
|
|
1695
|
+
}
|
|
1696
|
+
|
|
1697
|
+
get supportHtml(): boolean | undefined {
|
|
1698
|
+
return this.#delegate.supportHtml;
|
|
1699
|
+
}
|
|
1700
|
+
|
|
1701
|
+
set supportHtml(value: boolean | undefined) {
|
|
1702
|
+
this.#delegate.supportHtml = value;
|
|
1703
|
+
}
|
|
1704
|
+
|
|
1705
|
+
get baseUri(): vscode.Uri | undefined {
|
|
1706
|
+
return this.#delegate.baseUri;
|
|
1707
|
+
}
|
|
1708
|
+
|
|
1709
|
+
set baseUri(value: vscode.Uri | undefined) {
|
|
1710
|
+
this.#delegate.baseUri = value;
|
|
1711
|
+
}
|
|
1712
|
+
|
|
1713
|
+
appendText(value: string): vscode.MarkdownString {
|
|
1714
|
+
this.#delegate.appendText(value);
|
|
1715
|
+
return this;
|
|
1716
|
+
}
|
|
1717
|
+
|
|
1718
|
+
appendMarkdown(value: string): vscode.MarkdownString {
|
|
1719
|
+
this.#delegate.appendMarkdown(value);
|
|
1720
|
+
return this;
|
|
1721
|
+
}
|
|
1722
|
+
|
|
1723
|
+
appendCodeblock(value: string, language?: string): vscode.MarkdownString {
|
|
1724
|
+
this.#delegate.appendCodeblock(language ?? '', value);
|
|
1725
|
+
return this;
|
|
1726
|
+
}
|
|
1727
|
+
}
|
|
1728
|
+
|
|
1729
|
+
export class ParameterInformation {
|
|
1730
|
+
label: string | [number, number];
|
|
1731
|
+
documentation?: string | vscode.MarkdownString;
|
|
1732
|
+
|
|
1733
|
+
constructor(
|
|
1734
|
+
label: string | [number, number],
|
|
1735
|
+
documentation?: string | vscode.MarkdownString,
|
|
1736
|
+
) {
|
|
1737
|
+
this.label = label;
|
|
1738
|
+
this.documentation = documentation;
|
|
1739
|
+
}
|
|
1740
|
+
}
|
|
1741
|
+
|
|
1742
|
+
export class SignatureInformation {
|
|
1743
|
+
label: string;
|
|
1744
|
+
documentation?: string | vscode.MarkdownString;
|
|
1745
|
+
parameters: ParameterInformation[];
|
|
1746
|
+
activeParameter?: number;
|
|
1747
|
+
|
|
1748
|
+
constructor(label: string, documentation?: string | vscode.MarkdownString) {
|
|
1749
|
+
this.label = label;
|
|
1750
|
+
this.documentation = documentation;
|
|
1751
|
+
this.parameters = [];
|
|
1752
|
+
}
|
|
1753
|
+
}
|
|
1754
|
+
|
|
1755
|
+
export class SignatureHelp {
|
|
1756
|
+
signatures: SignatureInformation[];
|
|
1757
|
+
activeSignature = 0;
|
|
1758
|
+
activeParameter = 0;
|
|
1759
|
+
|
|
1760
|
+
constructor() {
|
|
1761
|
+
this.signatures = [];
|
|
1762
|
+
}
|
|
1763
|
+
}
|
|
1764
|
+
|
|
1765
|
+
export enum SignatureHelpTriggerKind {
|
|
1766
|
+
Invoke = 1,
|
|
1767
|
+
TriggerCharacter = 2,
|
|
1768
|
+
ContentChange = 3,
|
|
1769
|
+
}
|
|
1770
|
+
|
|
1771
|
+
export enum InlayHintKind {
|
|
1772
|
+
Type = 1,
|
|
1773
|
+
Parameter = 2,
|
|
1774
|
+
}
|
|
1775
|
+
|
|
1776
|
+
export class InlayHintLabelPart {
|
|
1777
|
+
value: string;
|
|
1778
|
+
tooltip?: string | vscode.MarkdownString;
|
|
1779
|
+
location?: Location;
|
|
1780
|
+
command?: vscode.Command;
|
|
1781
|
+
|
|
1782
|
+
constructor(value: string) {
|
|
1783
|
+
this.value = value;
|
|
1784
|
+
}
|
|
1785
|
+
}
|
|
1786
|
+
|
|
1787
|
+
export class InlayHint implements vscode.InlayHint {
|
|
1788
|
+
label: string | InlayHintLabelPart[];
|
|
1789
|
+
tooltip?: string | vscode.MarkdownString;
|
|
1790
|
+
position: Position;
|
|
1791
|
+
textEdits?: TextEdit[];
|
|
1792
|
+
kind?: vscode.InlayHintKind;
|
|
1793
|
+
paddingLeft?: boolean;
|
|
1794
|
+
paddingRight?: boolean;
|
|
1795
|
+
|
|
1796
|
+
constructor(
|
|
1797
|
+
position: Position,
|
|
1798
|
+
label: string | InlayHintLabelPart[],
|
|
1799
|
+
kind?: vscode.InlayHintKind,
|
|
1800
|
+
) {
|
|
1801
|
+
this.position = position;
|
|
1802
|
+
this.label = label;
|
|
1803
|
+
this.kind = kind;
|
|
1804
|
+
}
|
|
1805
|
+
}
|
|
1806
|
+
|
|
1807
|
+
export enum CompletionTriggerKind {
|
|
1808
|
+
Invoke = 0,
|
|
1809
|
+
TriggerCharacter = 1,
|
|
1810
|
+
TriggerForIncompleteCompletions = 2,
|
|
1811
|
+
}
|
|
1812
|
+
|
|
1813
|
+
export interface CompletionContext {
|
|
1814
|
+
readonly triggerKind: CompletionTriggerKind;
|
|
1815
|
+
readonly triggerCharacter: string | undefined;
|
|
1816
|
+
}
|
|
1817
|
+
|
|
1818
|
+
export enum CompletionItemKind {
|
|
1819
|
+
Text = 0,
|
|
1820
|
+
Method = 1,
|
|
1821
|
+
Function = 2,
|
|
1822
|
+
Constructor = 3,
|
|
1823
|
+
Field = 4,
|
|
1824
|
+
Variable = 5,
|
|
1825
|
+
Class = 6,
|
|
1826
|
+
Interface = 7,
|
|
1827
|
+
Module = 8,
|
|
1828
|
+
Property = 9,
|
|
1829
|
+
Unit = 10,
|
|
1830
|
+
Value = 11,
|
|
1831
|
+
Enum = 12,
|
|
1832
|
+
Keyword = 13,
|
|
1833
|
+
Snippet = 14,
|
|
1834
|
+
Color = 15,
|
|
1835
|
+
File = 16,
|
|
1836
|
+
Reference = 17,
|
|
1837
|
+
Folder = 18,
|
|
1838
|
+
EnumMember = 19,
|
|
1839
|
+
Constant = 20,
|
|
1840
|
+
Struct = 21,
|
|
1841
|
+
Event = 22,
|
|
1842
|
+
Operator = 23,
|
|
1843
|
+
TypeParameter = 24,
|
|
1844
|
+
User = 25,
|
|
1845
|
+
Issue = 26,
|
|
1846
|
+
}
|
|
1847
|
+
|
|
1848
|
+
export enum CompletionItemTag {
|
|
1849
|
+
Deprecated = 1,
|
|
1850
|
+
}
|
|
1851
|
+
|
|
1852
|
+
export interface CompletionItemLabel {
|
|
1853
|
+
label: string;
|
|
1854
|
+
detail?: string;
|
|
1855
|
+
description?: string;
|
|
1856
|
+
}
|
|
1857
|
+
|
|
1858
|
+
export class CompletionItem implements vscode.CompletionItem {
|
|
1859
|
+
label: string | CompletionItemLabel;
|
|
1860
|
+
kind?: CompletionItemKind;
|
|
1861
|
+
tags?: CompletionItemTag[];
|
|
1862
|
+
detail?: string;
|
|
1863
|
+
documentation?: string | vscode.MarkdownString;
|
|
1864
|
+
sortText?: string;
|
|
1865
|
+
filterText?: string;
|
|
1866
|
+
preselect?: boolean;
|
|
1867
|
+
insertText?: string | SnippetString;
|
|
1868
|
+
keepWhitespace?: boolean;
|
|
1869
|
+
range?: Range | { inserting: Range; replacing: Range };
|
|
1870
|
+
commitCharacters?: string[];
|
|
1871
|
+
textEdit?: TextEdit;
|
|
1872
|
+
additionalTextEdits?: TextEdit[];
|
|
1873
|
+
command?: vscode.Command;
|
|
1874
|
+
|
|
1875
|
+
constructor(label: string | CompletionItemLabel, kind?: CompletionItemKind) {
|
|
1876
|
+
this.label = label;
|
|
1877
|
+
this.kind = kind;
|
|
1878
|
+
}
|
|
1879
|
+
|
|
1880
|
+
toJSON(): any {
|
|
1881
|
+
return {
|
|
1882
|
+
label: this.label,
|
|
1883
|
+
kind: this.kind && CompletionItemKind[this.kind],
|
|
1884
|
+
detail: this.detail,
|
|
1885
|
+
documentation: this.documentation,
|
|
1886
|
+
sortText: this.sortText,
|
|
1887
|
+
filterText: this.filterText,
|
|
1888
|
+
preselect: this.preselect,
|
|
1889
|
+
insertText: this.insertText,
|
|
1890
|
+
textEdit: this.textEdit,
|
|
1891
|
+
};
|
|
1892
|
+
}
|
|
1893
|
+
}
|
|
1894
|
+
|
|
1895
|
+
export class CompletionList {
|
|
1896
|
+
isIncomplete?: boolean;
|
|
1897
|
+
items: vscode.CompletionItem[];
|
|
1898
|
+
|
|
1899
|
+
constructor(items: vscode.CompletionItem[] = [], isIncomplete = false) {
|
|
1900
|
+
this.items = items;
|
|
1901
|
+
this.isIncomplete = isIncomplete;
|
|
1902
|
+
}
|
|
1903
|
+
}
|
|
1904
|
+
|
|
1905
|
+
export class InlineSuggestion implements vscode.InlineCompletionItem {
|
|
1906
|
+
filterText?: string;
|
|
1907
|
+
insertText: string;
|
|
1908
|
+
range?: Range;
|
|
1909
|
+
command?: vscode.Command;
|
|
1910
|
+
|
|
1911
|
+
constructor(insertText: string, range?: Range, command?: vscode.Command) {
|
|
1912
|
+
this.insertText = insertText;
|
|
1913
|
+
this.range = range;
|
|
1914
|
+
this.command = command;
|
|
1915
|
+
}
|
|
1916
|
+
}
|
|
1917
|
+
|
|
1918
|
+
export class InlineSuggestionList implements vscode.InlineCompletionList {
|
|
1919
|
+
items: vscode.InlineCompletionItem[];
|
|
1920
|
+
|
|
1921
|
+
commands: vscode.Command[] | undefined = undefined;
|
|
1922
|
+
|
|
1923
|
+
suppressSuggestions: boolean | undefined = undefined;
|
|
1924
|
+
|
|
1925
|
+
constructor(items: vscode.InlineCompletionItem[]) {
|
|
1926
|
+
this.items = items;
|
|
1927
|
+
}
|
|
1928
|
+
}
|
|
1929
|
+
|
|
1930
|
+
export enum ViewColumn {
|
|
1931
|
+
Active = -1,
|
|
1932
|
+
Beside = -2,
|
|
1933
|
+
One = 1,
|
|
1934
|
+
Two = 2,
|
|
1935
|
+
Three = 3,
|
|
1936
|
+
Four = 4,
|
|
1937
|
+
Five = 5,
|
|
1938
|
+
Six = 6,
|
|
1939
|
+
Seven = 7,
|
|
1940
|
+
Eight = 8,
|
|
1941
|
+
Nine = 9,
|
|
1942
|
+
}
|
|
1943
|
+
|
|
1944
|
+
export enum StatusBarAlignment {
|
|
1945
|
+
Left = 1,
|
|
1946
|
+
Right = 2,
|
|
1947
|
+
}
|
|
1948
|
+
|
|
1949
|
+
export enum TextEditorLineNumbersStyle {
|
|
1950
|
+
Off = 0,
|
|
1951
|
+
On = 1,
|
|
1952
|
+
Relative = 2,
|
|
1953
|
+
}
|
|
1954
|
+
|
|
1955
|
+
export enum TextDocumentSaveReason {
|
|
1956
|
+
Manual = 1,
|
|
1957
|
+
AfterDelay = 2,
|
|
1958
|
+
FocusOut = 3,
|
|
1959
|
+
}
|
|
1960
|
+
|
|
1961
|
+
export enum TextEditorRevealType {
|
|
1962
|
+
Default = 0,
|
|
1963
|
+
InCenter = 1,
|
|
1964
|
+
InCenterIfOutsideViewport = 2,
|
|
1965
|
+
AtTop = 3,
|
|
1966
|
+
}
|
|
1967
|
+
|
|
1968
|
+
export enum TextEditorSelectionChangeKind {
|
|
1969
|
+
Keyboard = 1,
|
|
1970
|
+
Mouse = 2,
|
|
1971
|
+
Command = 3,
|
|
1972
|
+
}
|
|
1973
|
+
|
|
1974
|
+
export enum TextDocumentChangeReason {
|
|
1975
|
+
Undo = 1,
|
|
1976
|
+
Redo = 2,
|
|
1977
|
+
}
|
|
1978
|
+
|
|
1979
|
+
/**
|
|
1980
|
+
* These values match very carefully the values of `TrackedRangeStickiness`
|
|
1981
|
+
*/
|
|
1982
|
+
export enum DecorationRangeBehavior {
|
|
1983
|
+
/**
|
|
1984
|
+
* TrackedRangeStickiness.AlwaysGrowsWhenTypingAtEdges
|
|
1985
|
+
*/
|
|
1986
|
+
OpenOpen = 0,
|
|
1987
|
+
/**
|
|
1988
|
+
* TrackedRangeStickiness.NeverGrowsWhenTypingAtEdges
|
|
1989
|
+
*/
|
|
1990
|
+
ClosedClosed = 1,
|
|
1991
|
+
/**
|
|
1992
|
+
* TrackedRangeStickiness.GrowsOnlyWhenTypingBefore
|
|
1993
|
+
*/
|
|
1994
|
+
OpenClosed = 2,
|
|
1995
|
+
/**
|
|
1996
|
+
* TrackedRangeStickiness.GrowsOnlyWhenTypingAfter
|
|
1997
|
+
*/
|
|
1998
|
+
ClosedOpen = 3,
|
|
1999
|
+
}
|
|
2000
|
+
|
|
2001
|
+
export namespace TextEditorSelectionChangeKind {
|
|
2002
|
+
export function fromValue(s: string | undefined) {
|
|
2003
|
+
switch (s) {
|
|
2004
|
+
case 'keyboard':
|
|
2005
|
+
return TextEditorSelectionChangeKind.Keyboard;
|
|
2006
|
+
case 'mouse':
|
|
2007
|
+
return TextEditorSelectionChangeKind.Mouse;
|
|
2008
|
+
case 'api':
|
|
2009
|
+
return TextEditorSelectionChangeKind.Command;
|
|
2010
|
+
}
|
|
2011
|
+
return undefined;
|
|
2012
|
+
}
|
|
2013
|
+
}
|
|
2014
|
+
|
|
2015
|
+
export enum SyntaxTokenType {
|
|
2016
|
+
Other = 0,
|
|
2017
|
+
Comment = 1,
|
|
2018
|
+
String = 2,
|
|
2019
|
+
RegEx = 3,
|
|
2020
|
+
}
|
|
2021
|
+
export namespace SyntaxTokenType {
|
|
2022
|
+
export function toString(
|
|
2023
|
+
v: SyntaxTokenType | unknown,
|
|
2024
|
+
): 'other' | 'comment' | 'string' | 'regex' {
|
|
2025
|
+
switch (v) {
|
|
2026
|
+
case SyntaxTokenType.Other:
|
|
2027
|
+
return 'other';
|
|
2028
|
+
case SyntaxTokenType.Comment:
|
|
2029
|
+
return 'comment';
|
|
2030
|
+
case SyntaxTokenType.String:
|
|
2031
|
+
return 'string';
|
|
2032
|
+
case SyntaxTokenType.RegEx:
|
|
2033
|
+
return 'regex';
|
|
2034
|
+
}
|
|
2035
|
+
return 'other';
|
|
2036
|
+
}
|
|
2037
|
+
}
|
|
2038
|
+
|
|
2039
|
+
export class DocumentLink {
|
|
2040
|
+
range: Range;
|
|
2041
|
+
|
|
2042
|
+
target?: URI;
|
|
2043
|
+
|
|
2044
|
+
tooltip?: string;
|
|
2045
|
+
|
|
2046
|
+
constructor(range: Range, target: URI | undefined) {
|
|
2047
|
+
if (target && !URI.isUri(target)) {
|
|
2048
|
+
throw illegalArgument('target');
|
|
2049
|
+
}
|
|
2050
|
+
if (!Range.isRange(range) || range.isEmpty) {
|
|
2051
|
+
throw illegalArgument('range');
|
|
2052
|
+
}
|
|
2053
|
+
this.range = range;
|
|
2054
|
+
this.target = target;
|
|
2055
|
+
}
|
|
2056
|
+
}
|
|
2057
|
+
|
|
2058
|
+
export class Color {
|
|
2059
|
+
readonly red: number;
|
|
2060
|
+
readonly green: number;
|
|
2061
|
+
readonly blue: number;
|
|
2062
|
+
readonly alpha: number;
|
|
2063
|
+
|
|
2064
|
+
constructor(red: number, green: number, blue: number, alpha: number) {
|
|
2065
|
+
this.red = red;
|
|
2066
|
+
this.green = green;
|
|
2067
|
+
this.blue = blue;
|
|
2068
|
+
this.alpha = alpha;
|
|
2069
|
+
}
|
|
2070
|
+
}
|
|
2071
|
+
|
|
2072
|
+
export type IColorFormat = string | { opaque: string; transparent: string };
|
|
2073
|
+
|
|
2074
|
+
export class ColorInformation {
|
|
2075
|
+
range: Range;
|
|
2076
|
+
|
|
2077
|
+
color: Color;
|
|
2078
|
+
|
|
2079
|
+
constructor(range: Range, color: Color) {
|
|
2080
|
+
if (color && !(color instanceof Color)) {
|
|
2081
|
+
throw illegalArgument('color');
|
|
2082
|
+
}
|
|
2083
|
+
if (!Range.isRange(range) || range.isEmpty) {
|
|
2084
|
+
throw illegalArgument('range');
|
|
2085
|
+
}
|
|
2086
|
+
this.range = range;
|
|
2087
|
+
this.color = color;
|
|
2088
|
+
}
|
|
2089
|
+
}
|
|
2090
|
+
|
|
2091
|
+
export class ColorPresentation {
|
|
2092
|
+
label: string;
|
|
2093
|
+
textEdit?: TextEdit;
|
|
2094
|
+
additionalTextEdits?: TextEdit[];
|
|
2095
|
+
|
|
2096
|
+
constructor(label: string) {
|
|
2097
|
+
if (!label || typeof label !== 'string') {
|
|
2098
|
+
throw illegalArgument('label');
|
|
2099
|
+
}
|
|
2100
|
+
this.label = label;
|
|
2101
|
+
}
|
|
2102
|
+
}
|
|
2103
|
+
|
|
2104
|
+
export enum ColorFormat {
|
|
2105
|
+
RGB = 0,
|
|
2106
|
+
HEX = 1,
|
|
2107
|
+
HSL = 2,
|
|
2108
|
+
}
|
|
2109
|
+
|
|
2110
|
+
export enum SourceControlInputBoxValidationType {
|
|
2111
|
+
Error = 0,
|
|
2112
|
+
Warning = 1,
|
|
2113
|
+
Information = 2,
|
|
2114
|
+
}
|
|
2115
|
+
|
|
2116
|
+
export enum TerminalExitReason {
|
|
2117
|
+
Unknown = 0,
|
|
2118
|
+
Shutdown = 1,
|
|
2119
|
+
Process = 2,
|
|
2120
|
+
User = 3,
|
|
2121
|
+
Extension = 4,
|
|
2122
|
+
}
|
|
2123
|
+
|
|
2124
|
+
export class TerminalLink implements vscode.TerminalLink {
|
|
2125
|
+
constructor(
|
|
2126
|
+
public startIndex: number,
|
|
2127
|
+
public length: number,
|
|
2128
|
+
public tooltip?: string,
|
|
2129
|
+
) {
|
|
2130
|
+
if (typeof startIndex !== 'number' || startIndex < 0) {
|
|
2131
|
+
throw illegalArgument('startIndex');
|
|
2132
|
+
}
|
|
2133
|
+
if (typeof length !== 'number' || length < 1) {
|
|
2134
|
+
throw illegalArgument('length');
|
|
2135
|
+
}
|
|
2136
|
+
if (tooltip !== undefined && typeof tooltip !== 'string') {
|
|
2137
|
+
throw illegalArgument('tooltip');
|
|
2138
|
+
}
|
|
2139
|
+
}
|
|
2140
|
+
}
|
|
2141
|
+
|
|
2142
|
+
export class TerminalQuickFixOpener {
|
|
2143
|
+
uri: vscode.Uri;
|
|
2144
|
+
constructor(uri: vscode.Uri) {
|
|
2145
|
+
this.uri = uri;
|
|
2146
|
+
}
|
|
2147
|
+
}
|
|
2148
|
+
|
|
2149
|
+
export class TerminalQuickFixCommand {
|
|
2150
|
+
terminalCommand: string;
|
|
2151
|
+
constructor(terminalCommand: string) {
|
|
2152
|
+
this.terminalCommand = terminalCommand;
|
|
2153
|
+
}
|
|
2154
|
+
}
|
|
2155
|
+
|
|
2156
|
+
export enum TerminalLocation {
|
|
2157
|
+
Panel = 1,
|
|
2158
|
+
Editor = 2,
|
|
2159
|
+
}
|
|
2160
|
+
|
|
2161
|
+
export class TerminalProfile implements vscode.TerminalProfile {
|
|
2162
|
+
constructor(
|
|
2163
|
+
public options: vscode.TerminalOptions | vscode.ExtensionTerminalOptions,
|
|
2164
|
+
) {
|
|
2165
|
+
if (typeof options !== 'object') {
|
|
2166
|
+
throw illegalArgument('options');
|
|
2167
|
+
}
|
|
2168
|
+
}
|
|
2169
|
+
}
|
|
2170
|
+
|
|
2171
|
+
export enum TaskRevealKind {
|
|
2172
|
+
Always = 1,
|
|
2173
|
+
|
|
2174
|
+
Silent = 2,
|
|
2175
|
+
|
|
2176
|
+
Never = 3,
|
|
2177
|
+
}
|
|
2178
|
+
|
|
2179
|
+
export enum TaskPanelKind {
|
|
2180
|
+
Shared = 1,
|
|
2181
|
+
|
|
2182
|
+
Dedicated = 2,
|
|
2183
|
+
|
|
2184
|
+
New = 3,
|
|
2185
|
+
}
|
|
2186
|
+
|
|
2187
|
+
export class TaskGroup implements vscode.TaskGroup {
|
|
2188
|
+
isDefault: boolean | undefined;
|
|
2189
|
+
private _id: string;
|
|
2190
|
+
|
|
2191
|
+
public static Clean: TaskGroup = new TaskGroup('clean', 'Clean');
|
|
2192
|
+
|
|
2193
|
+
public static Build: TaskGroup = new TaskGroup('build', 'Build');
|
|
2194
|
+
|
|
2195
|
+
public static Rebuild: TaskGroup = new TaskGroup('rebuild', 'Rebuild');
|
|
2196
|
+
|
|
2197
|
+
public static Test: TaskGroup = new TaskGroup('test', 'Test');
|
|
2198
|
+
|
|
2199
|
+
public static from(value: string) {
|
|
2200
|
+
switch (value) {
|
|
2201
|
+
case 'clean':
|
|
2202
|
+
return TaskGroup.Clean;
|
|
2203
|
+
case 'build':
|
|
2204
|
+
return TaskGroup.Build;
|
|
2205
|
+
case 'rebuild':
|
|
2206
|
+
return TaskGroup.Rebuild;
|
|
2207
|
+
case 'test':
|
|
2208
|
+
return TaskGroup.Test;
|
|
2209
|
+
default:
|
|
2210
|
+
return undefined;
|
|
2211
|
+
}
|
|
2212
|
+
}
|
|
2213
|
+
|
|
2214
|
+
constructor(
|
|
2215
|
+
id: string,
|
|
2216
|
+
public readonly label: string,
|
|
2217
|
+
) {
|
|
2218
|
+
if (typeof id !== 'string') {
|
|
2219
|
+
throw illegalArgument('name');
|
|
2220
|
+
}
|
|
2221
|
+
if (typeof label !== 'string') {
|
|
2222
|
+
throw illegalArgument('name');
|
|
2223
|
+
}
|
|
2224
|
+
this._id = id;
|
|
2225
|
+
}
|
|
2226
|
+
|
|
2227
|
+
get id(): string {
|
|
2228
|
+
return this._id;
|
|
2229
|
+
}
|
|
2230
|
+
}
|
|
2231
|
+
|
|
2232
|
+
function computeTaskExecutionId(values: string[]): string {
|
|
2233
|
+
let id = '';
|
|
2234
|
+
for (let i = 0; i < values.length; i++) {
|
|
2235
|
+
id += values[i].replace(/,/g, ',,') + ',';
|
|
2236
|
+
}
|
|
2237
|
+
return id;
|
|
2238
|
+
}
|
|
2239
|
+
|
|
2240
|
+
export class ProcessExecution implements vscode.ProcessExecution {
|
|
2241
|
+
private _process: string;
|
|
2242
|
+
private _args: string[];
|
|
2243
|
+
private _options: vscode.ProcessExecutionOptions | undefined;
|
|
2244
|
+
|
|
2245
|
+
constructor(process: string, options?: vscode.ProcessExecutionOptions);
|
|
2246
|
+
constructor(
|
|
2247
|
+
process: string,
|
|
2248
|
+
args: string[],
|
|
2249
|
+
options?: vscode.ProcessExecutionOptions,
|
|
2250
|
+
);
|
|
2251
|
+
constructor(
|
|
2252
|
+
process: string,
|
|
2253
|
+
varg1?: string[] | vscode.ProcessExecutionOptions,
|
|
2254
|
+
varg2?: vscode.ProcessExecutionOptions,
|
|
2255
|
+
) {
|
|
2256
|
+
if (typeof process !== 'string') {
|
|
2257
|
+
throw illegalArgument('process');
|
|
2258
|
+
}
|
|
2259
|
+
this._args = [];
|
|
2260
|
+
this._process = process;
|
|
2261
|
+
if (varg1 !== undefined) {
|
|
2262
|
+
if (Array.isArray(varg1)) {
|
|
2263
|
+
this._args = varg1;
|
|
2264
|
+
this._options = varg2;
|
|
2265
|
+
} else {
|
|
2266
|
+
this._options = varg1;
|
|
2267
|
+
}
|
|
2268
|
+
}
|
|
2269
|
+
}
|
|
2270
|
+
|
|
2271
|
+
get process(): string {
|
|
2272
|
+
return this._process;
|
|
2273
|
+
}
|
|
2274
|
+
|
|
2275
|
+
set process(value: string) {
|
|
2276
|
+
if (typeof value !== 'string') {
|
|
2277
|
+
throw illegalArgument('process');
|
|
2278
|
+
}
|
|
2279
|
+
this._process = value;
|
|
2280
|
+
}
|
|
2281
|
+
|
|
2282
|
+
get args(): string[] {
|
|
2283
|
+
return this._args;
|
|
2284
|
+
}
|
|
2285
|
+
|
|
2286
|
+
set args(value: string[]) {
|
|
2287
|
+
if (!Array.isArray(value)) {
|
|
2288
|
+
value = [];
|
|
2289
|
+
}
|
|
2290
|
+
this._args = value;
|
|
2291
|
+
}
|
|
2292
|
+
|
|
2293
|
+
get options(): vscode.ProcessExecutionOptions | undefined {
|
|
2294
|
+
return this._options;
|
|
2295
|
+
}
|
|
2296
|
+
|
|
2297
|
+
set options(value: vscode.ProcessExecutionOptions | undefined) {
|
|
2298
|
+
this._options = value;
|
|
2299
|
+
}
|
|
2300
|
+
|
|
2301
|
+
public computeId(): string {
|
|
2302
|
+
const props: string[] = [];
|
|
2303
|
+
props.push('process');
|
|
2304
|
+
if (this._process !== undefined) {
|
|
2305
|
+
props.push(this._process);
|
|
2306
|
+
}
|
|
2307
|
+
if (this._args && this._args.length > 0) {
|
|
2308
|
+
for (const arg of this._args) {
|
|
2309
|
+
props.push(arg);
|
|
2310
|
+
}
|
|
2311
|
+
}
|
|
2312
|
+
return computeTaskExecutionId(props);
|
|
2313
|
+
}
|
|
2314
|
+
}
|
|
2315
|
+
|
|
2316
|
+
export class ShellExecution implements vscode.ShellExecution {
|
|
2317
|
+
private _commandLine: string | undefined;
|
|
2318
|
+
private _command: string | vscode.ShellQuotedString | undefined;
|
|
2319
|
+
private _args: (string | vscode.ShellQuotedString)[] = [];
|
|
2320
|
+
private _options: vscode.ShellExecutionOptions | undefined;
|
|
2321
|
+
|
|
2322
|
+
constructor(commandLine: string, options?: vscode.ShellExecutionOptions);
|
|
2323
|
+
constructor(
|
|
2324
|
+
command: string | vscode.ShellQuotedString,
|
|
2325
|
+
args: (string | vscode.ShellQuotedString)[],
|
|
2326
|
+
options?: vscode.ShellExecutionOptions,
|
|
2327
|
+
);
|
|
2328
|
+
constructor(
|
|
2329
|
+
arg0: string | vscode.ShellQuotedString,
|
|
2330
|
+
arg1?: vscode.ShellExecutionOptions | (string | vscode.ShellQuotedString)[],
|
|
2331
|
+
arg2?: vscode.ShellExecutionOptions,
|
|
2332
|
+
) {
|
|
2333
|
+
if (Array.isArray(arg1)) {
|
|
2334
|
+
if (!arg0) {
|
|
2335
|
+
throw illegalArgument("command can't be undefined or null");
|
|
2336
|
+
}
|
|
2337
|
+
if (typeof arg0 !== 'string' && typeof arg0.value !== 'string') {
|
|
2338
|
+
throw illegalArgument('command');
|
|
2339
|
+
}
|
|
2340
|
+
this._command = arg0;
|
|
2341
|
+
this._args = arg1 as (string | vscode.ShellQuotedString)[];
|
|
2342
|
+
this._options = arg2;
|
|
2343
|
+
} else {
|
|
2344
|
+
if (typeof arg0 !== 'string') {
|
|
2345
|
+
throw illegalArgument('commandLine');
|
|
2346
|
+
}
|
|
2347
|
+
this._commandLine = arg0;
|
|
2348
|
+
this._options = arg1;
|
|
2349
|
+
}
|
|
2350
|
+
}
|
|
2351
|
+
|
|
2352
|
+
get commandLine(): string | undefined {
|
|
2353
|
+
return this._commandLine;
|
|
2354
|
+
}
|
|
2355
|
+
|
|
2356
|
+
set commandLine(value: string | undefined) {
|
|
2357
|
+
if (typeof value !== 'string') {
|
|
2358
|
+
throw illegalArgument('commandLine');
|
|
2359
|
+
}
|
|
2360
|
+
this._commandLine = value;
|
|
2361
|
+
}
|
|
2362
|
+
|
|
2363
|
+
get command(): string | vscode.ShellQuotedString {
|
|
2364
|
+
return this._command ? this._command : '';
|
|
2365
|
+
}
|
|
2366
|
+
|
|
2367
|
+
set command(value: string | vscode.ShellQuotedString) {
|
|
2368
|
+
if (typeof value !== 'string' && typeof value.value !== 'string') {
|
|
2369
|
+
throw illegalArgument('command');
|
|
2370
|
+
}
|
|
2371
|
+
this._command = value;
|
|
2372
|
+
}
|
|
2373
|
+
|
|
2374
|
+
get args(): (string | vscode.ShellQuotedString)[] {
|
|
2375
|
+
return this._args;
|
|
2376
|
+
}
|
|
2377
|
+
|
|
2378
|
+
set args(value: (string | vscode.ShellQuotedString)[]) {
|
|
2379
|
+
this._args = value || [];
|
|
2380
|
+
}
|
|
2381
|
+
|
|
2382
|
+
get options(): vscode.ShellExecutionOptions | undefined {
|
|
2383
|
+
return this._options;
|
|
2384
|
+
}
|
|
2385
|
+
|
|
2386
|
+
set options(value: vscode.ShellExecutionOptions | undefined) {
|
|
2387
|
+
this._options = value;
|
|
2388
|
+
}
|
|
2389
|
+
|
|
2390
|
+
public computeId(): string {
|
|
2391
|
+
const props: string[] = [];
|
|
2392
|
+
props.push('shell');
|
|
2393
|
+
if (this._commandLine !== undefined) {
|
|
2394
|
+
props.push(this._commandLine);
|
|
2395
|
+
}
|
|
2396
|
+
if (this._command !== undefined) {
|
|
2397
|
+
props.push(
|
|
2398
|
+
typeof this._command === 'string' ? this._command : this._command.value,
|
|
2399
|
+
);
|
|
2400
|
+
}
|
|
2401
|
+
if (this._args && this._args.length > 0) {
|
|
2402
|
+
for (const arg of this._args) {
|
|
2403
|
+
props.push(typeof arg === 'string' ? arg : arg.value);
|
|
2404
|
+
}
|
|
2405
|
+
}
|
|
2406
|
+
return computeTaskExecutionId(props);
|
|
2407
|
+
}
|
|
2408
|
+
}
|
|
2409
|
+
|
|
2410
|
+
export enum ShellQuoting {
|
|
2411
|
+
Escape = 1,
|
|
2412
|
+
Strong = 2,
|
|
2413
|
+
Weak = 3,
|
|
2414
|
+
}
|
|
2415
|
+
|
|
2416
|
+
export enum TaskScope {
|
|
2417
|
+
Global = 1,
|
|
2418
|
+
Workspace = 2,
|
|
2419
|
+
}
|
|
2420
|
+
|
|
2421
|
+
export class CustomExecution implements vscode.CustomExecution {
|
|
2422
|
+
private _callback: (
|
|
2423
|
+
resolvedDefinition: vscode.TaskDefinition,
|
|
2424
|
+
) => Thenable<vscode.Pseudoterminal>;
|
|
2425
|
+
constructor(
|
|
2426
|
+
callback: (
|
|
2427
|
+
resolvedDefinition: vscode.TaskDefinition,
|
|
2428
|
+
) => Thenable<vscode.Pseudoterminal>,
|
|
2429
|
+
) {
|
|
2430
|
+
this._callback = callback;
|
|
2431
|
+
}
|
|
2432
|
+
public computeId(): string {
|
|
2433
|
+
return 'customExecution' + generateUuid();
|
|
2434
|
+
}
|
|
2435
|
+
|
|
2436
|
+
public set callback(
|
|
2437
|
+
value: (
|
|
2438
|
+
resolvedDefinition: vscode.TaskDefinition,
|
|
2439
|
+
) => Thenable<vscode.Pseudoterminal>,
|
|
2440
|
+
) {
|
|
2441
|
+
this._callback = value;
|
|
2442
|
+
}
|
|
2443
|
+
|
|
2444
|
+
public get callback(): (
|
|
2445
|
+
resolvedDefinition: vscode.TaskDefinition,
|
|
2446
|
+
) => Thenable<vscode.Pseudoterminal> {
|
|
2447
|
+
return this._callback;
|
|
2448
|
+
}
|
|
2449
|
+
}
|
|
2450
|
+
|
|
2451
|
+
export class Task implements vscode.Task {
|
|
2452
|
+
private static ExtensionCallbackType = 'customExecution';
|
|
2453
|
+
private static ProcessType = 'process';
|
|
2454
|
+
private static ShellType = 'shell';
|
|
2455
|
+
private static EmptyType = '$empty';
|
|
2456
|
+
|
|
2457
|
+
private __id: string | undefined;
|
|
2458
|
+
private __deprecated = false;
|
|
2459
|
+
|
|
2460
|
+
private _definition: vscode.TaskDefinition;
|
|
2461
|
+
private _scope:
|
|
2462
|
+
| vscode.TaskScope.Global
|
|
2463
|
+
| vscode.TaskScope.Workspace
|
|
2464
|
+
| vscode.WorkspaceFolder
|
|
2465
|
+
| undefined;
|
|
2466
|
+
private _name: string;
|
|
2467
|
+
private _execution: ProcessExecution | ShellExecution | CustomExecution | undefined;
|
|
2468
|
+
private _problemMatchers: string[];
|
|
2469
|
+
private _hasDefinedMatchers: boolean;
|
|
2470
|
+
private _isBackground: boolean;
|
|
2471
|
+
private _source: string;
|
|
2472
|
+
private _group: TaskGroup | undefined;
|
|
2473
|
+
private _presentationOptions: vscode.TaskPresentationOptions;
|
|
2474
|
+
private _runOptions: vscode.RunOptions;
|
|
2475
|
+
private _detail: string | undefined;
|
|
2476
|
+
|
|
2477
|
+
constructor(
|
|
2478
|
+
definition: vscode.TaskDefinition,
|
|
2479
|
+
name: string,
|
|
2480
|
+
source: string,
|
|
2481
|
+
execution?: ProcessExecution | ShellExecution | CustomExecution,
|
|
2482
|
+
problemMatchers?: string | string[],
|
|
2483
|
+
);
|
|
2484
|
+
constructor(
|
|
2485
|
+
definition: vscode.TaskDefinition,
|
|
2486
|
+
scope:
|
|
2487
|
+
| vscode.TaskScope.Global
|
|
2488
|
+
| vscode.TaskScope.Workspace
|
|
2489
|
+
| vscode.WorkspaceFolder,
|
|
2490
|
+
name: string,
|
|
2491
|
+
source: string,
|
|
2492
|
+
execution?: ProcessExecution | ShellExecution | CustomExecution,
|
|
2493
|
+
problemMatchers?: string | string[],
|
|
2494
|
+
);
|
|
2495
|
+
constructor(
|
|
2496
|
+
definition: vscode.TaskDefinition,
|
|
2497
|
+
arg2:
|
|
2498
|
+
| string
|
|
2499
|
+
| (vscode.TaskScope.Global | vscode.TaskScope.Workspace)
|
|
2500
|
+
| vscode.WorkspaceFolder,
|
|
2501
|
+
arg3: any,
|
|
2502
|
+
arg4?: any,
|
|
2503
|
+
arg5?: any,
|
|
2504
|
+
arg6?: any,
|
|
2505
|
+
) {
|
|
2506
|
+
this._definition = this.definition = definition;
|
|
2507
|
+
let problemMatchers: string | string[];
|
|
2508
|
+
if (typeof arg2 === 'string') {
|
|
2509
|
+
this._name = this.name = arg2;
|
|
2510
|
+
this._source = this.source = arg3;
|
|
2511
|
+
this.execution = arg4;
|
|
2512
|
+
problemMatchers = arg5;
|
|
2513
|
+
this.__deprecated = true;
|
|
2514
|
+
} else if (arg2 === TaskScope.Global || arg2 === TaskScope.Workspace) {
|
|
2515
|
+
this.target = arg2;
|
|
2516
|
+
this._name = this.name = arg3;
|
|
2517
|
+
this._source = this.source = arg4;
|
|
2518
|
+
this.execution = arg5;
|
|
2519
|
+
problemMatchers = arg6;
|
|
2520
|
+
} else {
|
|
2521
|
+
this.target = arg2;
|
|
2522
|
+
this._name = this.name = arg3;
|
|
2523
|
+
this._source = this.source = arg4;
|
|
2524
|
+
this.execution = arg5;
|
|
2525
|
+
problemMatchers = arg6;
|
|
2526
|
+
}
|
|
2527
|
+
if (typeof problemMatchers === 'string') {
|
|
2528
|
+
this._problemMatchers = [problemMatchers];
|
|
2529
|
+
this._hasDefinedMatchers = true;
|
|
2530
|
+
} else if (Array.isArray(problemMatchers)) {
|
|
2531
|
+
this._problemMatchers = problemMatchers;
|
|
2532
|
+
this._hasDefinedMatchers = true;
|
|
2533
|
+
} else {
|
|
2534
|
+
this._problemMatchers = [];
|
|
2535
|
+
this._hasDefinedMatchers = false;
|
|
2536
|
+
}
|
|
2537
|
+
this._isBackground = false;
|
|
2538
|
+
this._presentationOptions = Object.create(null);
|
|
2539
|
+
this._runOptions = Object.create(null);
|
|
2540
|
+
}
|
|
2541
|
+
|
|
2542
|
+
get _id(): string | undefined {
|
|
2543
|
+
return this.__id;
|
|
2544
|
+
}
|
|
2545
|
+
|
|
2546
|
+
set _id(value: string | undefined) {
|
|
2547
|
+
this.__id = value;
|
|
2548
|
+
}
|
|
2549
|
+
|
|
2550
|
+
get _deprecated(): boolean {
|
|
2551
|
+
return this.__deprecated;
|
|
2552
|
+
}
|
|
2553
|
+
|
|
2554
|
+
private clear(): void {
|
|
2555
|
+
if (this.__id === undefined) {
|
|
2556
|
+
return;
|
|
2557
|
+
}
|
|
2558
|
+
this.__id = undefined;
|
|
2559
|
+
this._scope = undefined;
|
|
2560
|
+
this.computeDefinitionBasedOnExecution();
|
|
2561
|
+
}
|
|
2562
|
+
|
|
2563
|
+
private computeDefinitionBasedOnExecution(): void {
|
|
2564
|
+
if (this._execution instanceof ProcessExecution) {
|
|
2565
|
+
this._definition = {
|
|
2566
|
+
type: Task.ProcessType,
|
|
2567
|
+
id: this._execution.computeId(),
|
|
2568
|
+
};
|
|
2569
|
+
} else if (this._execution instanceof ShellExecution) {
|
|
2570
|
+
this._definition = {
|
|
2571
|
+
type: Task.ShellType,
|
|
2572
|
+
id: this._execution.computeId(),
|
|
2573
|
+
};
|
|
2574
|
+
} else if (this._execution instanceof CustomExecution) {
|
|
2575
|
+
this._definition = {
|
|
2576
|
+
type: Task.ExtensionCallbackType,
|
|
2577
|
+
id: this._execution.computeId(),
|
|
2578
|
+
};
|
|
2579
|
+
} else {
|
|
2580
|
+
this._definition = {
|
|
2581
|
+
type: Task.EmptyType,
|
|
2582
|
+
id: generateUuid(),
|
|
2583
|
+
};
|
|
2584
|
+
}
|
|
2585
|
+
}
|
|
2586
|
+
|
|
2587
|
+
get definition(): vscode.TaskDefinition {
|
|
2588
|
+
return this._definition;
|
|
2589
|
+
}
|
|
2590
|
+
|
|
2591
|
+
set definition(value: vscode.TaskDefinition) {
|
|
2592
|
+
if (value === undefined || value === null) {
|
|
2593
|
+
throw illegalArgument("Kind can't be undefined or null");
|
|
2594
|
+
}
|
|
2595
|
+
this.clear();
|
|
2596
|
+
this._definition = value;
|
|
2597
|
+
}
|
|
2598
|
+
|
|
2599
|
+
get scope():
|
|
2600
|
+
| vscode.TaskScope.Global
|
|
2601
|
+
| vscode.TaskScope.Workspace
|
|
2602
|
+
| vscode.WorkspaceFolder
|
|
2603
|
+
| undefined {
|
|
2604
|
+
return this._scope;
|
|
2605
|
+
}
|
|
2606
|
+
|
|
2607
|
+
set target(
|
|
2608
|
+
value:
|
|
2609
|
+
| vscode.TaskScope.Global
|
|
2610
|
+
| vscode.TaskScope.Workspace
|
|
2611
|
+
| vscode.WorkspaceFolder,
|
|
2612
|
+
) {
|
|
2613
|
+
this.clear();
|
|
2614
|
+
this._scope = value;
|
|
2615
|
+
}
|
|
2616
|
+
|
|
2617
|
+
get name(): string {
|
|
2618
|
+
return this._name;
|
|
2619
|
+
}
|
|
2620
|
+
|
|
2621
|
+
set name(value: string) {
|
|
2622
|
+
if (typeof value !== 'string') {
|
|
2623
|
+
throw illegalArgument('name');
|
|
2624
|
+
}
|
|
2625
|
+
this.clear();
|
|
2626
|
+
this._name = value;
|
|
2627
|
+
}
|
|
2628
|
+
|
|
2629
|
+
get execution(): ProcessExecution | ShellExecution | CustomExecution | undefined {
|
|
2630
|
+
return this._execution;
|
|
2631
|
+
}
|
|
2632
|
+
|
|
2633
|
+
set execution(
|
|
2634
|
+
value: ProcessExecution | ShellExecution | CustomExecution | undefined,
|
|
2635
|
+
) {
|
|
2636
|
+
if (value === null) {
|
|
2637
|
+
value = undefined;
|
|
2638
|
+
}
|
|
2639
|
+
this.clear();
|
|
2640
|
+
this._execution = value;
|
|
2641
|
+
const type = this._definition.type;
|
|
2642
|
+
if (
|
|
2643
|
+
Task.EmptyType === type ||
|
|
2644
|
+
Task.ProcessType === type ||
|
|
2645
|
+
Task.ShellType === type ||
|
|
2646
|
+
Task.ExtensionCallbackType === type
|
|
2647
|
+
) {
|
|
2648
|
+
this.computeDefinitionBasedOnExecution();
|
|
2649
|
+
}
|
|
2650
|
+
}
|
|
2651
|
+
|
|
2652
|
+
get problemMatchers(): string[] {
|
|
2653
|
+
return this._problemMatchers;
|
|
2654
|
+
}
|
|
2655
|
+
|
|
2656
|
+
set problemMatchers(value: string[]) {
|
|
2657
|
+
if (!Array.isArray(value)) {
|
|
2658
|
+
this.clear();
|
|
2659
|
+
this._problemMatchers = [];
|
|
2660
|
+
this._hasDefinedMatchers = false;
|
|
2661
|
+
return;
|
|
2662
|
+
} else {
|
|
2663
|
+
this.clear();
|
|
2664
|
+
this._problemMatchers = value;
|
|
2665
|
+
this._hasDefinedMatchers = true;
|
|
2666
|
+
}
|
|
2667
|
+
}
|
|
2668
|
+
|
|
2669
|
+
get hasDefinedMatchers(): boolean {
|
|
2670
|
+
return this._hasDefinedMatchers;
|
|
2671
|
+
}
|
|
2672
|
+
|
|
2673
|
+
get isBackground(): boolean {
|
|
2674
|
+
return this._isBackground;
|
|
2675
|
+
}
|
|
2676
|
+
|
|
2677
|
+
set isBackground(value: boolean) {
|
|
2678
|
+
if (value !== true && value !== false) {
|
|
2679
|
+
value = false;
|
|
2680
|
+
}
|
|
2681
|
+
this.clear();
|
|
2682
|
+
this._isBackground = value;
|
|
2683
|
+
}
|
|
2684
|
+
|
|
2685
|
+
get source(): string {
|
|
2686
|
+
return this._source;
|
|
2687
|
+
}
|
|
2688
|
+
|
|
2689
|
+
set source(value: string) {
|
|
2690
|
+
if (typeof value !== 'string' || value.length === 0) {
|
|
2691
|
+
throw illegalArgument('source must be a string of length > 0');
|
|
2692
|
+
}
|
|
2693
|
+
this.clear();
|
|
2694
|
+
this._source = value;
|
|
2695
|
+
}
|
|
2696
|
+
|
|
2697
|
+
get group(): TaskGroup | undefined {
|
|
2698
|
+
return this._group;
|
|
2699
|
+
}
|
|
2700
|
+
|
|
2701
|
+
set group(value: TaskGroup | undefined) {
|
|
2702
|
+
if (value === null) {
|
|
2703
|
+
value = undefined;
|
|
2704
|
+
}
|
|
2705
|
+
this.clear();
|
|
2706
|
+
this._group = value;
|
|
2707
|
+
}
|
|
2708
|
+
|
|
2709
|
+
get detail(): string | undefined {
|
|
2710
|
+
return this._detail;
|
|
2711
|
+
}
|
|
2712
|
+
|
|
2713
|
+
set detail(value: string | undefined) {
|
|
2714
|
+
if (value === null) {
|
|
2715
|
+
value = undefined;
|
|
2716
|
+
}
|
|
2717
|
+
this._detail = value;
|
|
2718
|
+
}
|
|
2719
|
+
|
|
2720
|
+
get presentationOptions(): vscode.TaskPresentationOptions {
|
|
2721
|
+
return this._presentationOptions;
|
|
2722
|
+
}
|
|
2723
|
+
|
|
2724
|
+
set presentationOptions(value: vscode.TaskPresentationOptions) {
|
|
2725
|
+
if (value === null || value === undefined) {
|
|
2726
|
+
value = Object.create(null);
|
|
2727
|
+
}
|
|
2728
|
+
this.clear();
|
|
2729
|
+
this._presentationOptions = value;
|
|
2730
|
+
}
|
|
2731
|
+
|
|
2732
|
+
get runOptions(): vscode.RunOptions {
|
|
2733
|
+
return this._runOptions;
|
|
2734
|
+
}
|
|
2735
|
+
|
|
2736
|
+
set runOptions(value: vscode.RunOptions) {
|
|
2737
|
+
if (value === null || value === undefined) {
|
|
2738
|
+
value = Object.create(null);
|
|
2739
|
+
}
|
|
2740
|
+
this.clear();
|
|
2741
|
+
this._runOptions = value;
|
|
2742
|
+
}
|
|
2743
|
+
}
|
|
2744
|
+
|
|
2745
|
+
export enum ProgressLocation {
|
|
2746
|
+
SourceControl = 1,
|
|
2747
|
+
Window = 10,
|
|
2748
|
+
Notification = 15,
|
|
2749
|
+
}
|
|
2750
|
+
|
|
2751
|
+
export namespace ViewBadge {
|
|
2752
|
+
export function isViewBadge(thing: any): thing is vscode.ViewBadge {
|
|
2753
|
+
const viewBadgeThing = thing as vscode.ViewBadge;
|
|
2754
|
+
|
|
2755
|
+
if (!isNumber(viewBadgeThing.value)) {
|
|
2756
|
+
console.log('INVALID view badge, invalid value', viewBadgeThing.value);
|
|
2757
|
+
return false;
|
|
2758
|
+
}
|
|
2759
|
+
if (viewBadgeThing.tooltip && !isString(viewBadgeThing.tooltip)) {
|
|
2760
|
+
console.log('INVALID view badge, invalid tooltip', viewBadgeThing.tooltip);
|
|
2761
|
+
return false;
|
|
2762
|
+
}
|
|
2763
|
+
return true;
|
|
2764
|
+
}
|
|
2765
|
+
}
|
|
2766
|
+
|
|
2767
|
+
export class TreeItem {
|
|
2768
|
+
label?: string | vscode.TreeItemLabel;
|
|
2769
|
+
resourceUri?: URI;
|
|
2770
|
+
iconPath?: string | URI | { light: string | URI; dark: string | URI } | ThemeIcon;
|
|
2771
|
+
command?: vscode.Command;
|
|
2772
|
+
contextValue?: string;
|
|
2773
|
+
tooltip?: string | vscode.MarkdownString;
|
|
2774
|
+
checkboxState?: vscode.TreeItemCheckboxState;
|
|
2775
|
+
|
|
2776
|
+
static isTreeItem(thing: any): thing is TreeItem {
|
|
2777
|
+
const treeItemThing = thing as vscode.TreeItem;
|
|
2778
|
+
|
|
2779
|
+
if (treeItemThing.checkboxState !== undefined) {
|
|
2780
|
+
const checkbox = isNumber(treeItemThing.checkboxState)
|
|
2781
|
+
? treeItemThing.checkboxState
|
|
2782
|
+
: isObject(treeItemThing.checkboxState) &&
|
|
2783
|
+
isNumber(treeItemThing.checkboxState.state)
|
|
2784
|
+
? treeItemThing.checkboxState.state
|
|
2785
|
+
: undefined;
|
|
2786
|
+
const tooltip =
|
|
2787
|
+
!isNumber(treeItemThing.checkboxState) && isObject(treeItemThing.checkboxState)
|
|
2788
|
+
? treeItemThing.checkboxState.tooltip
|
|
2789
|
+
: undefined;
|
|
2790
|
+
if (
|
|
2791
|
+
checkbox === undefined ||
|
|
2792
|
+
(checkbox !== TreeItemCheckboxState.Checked &&
|
|
2793
|
+
checkbox !== TreeItemCheckboxState.Unchecked) ||
|
|
2794
|
+
(tooltip !== undefined && !isString(tooltip))
|
|
2795
|
+
) {
|
|
2796
|
+
console.log(
|
|
2797
|
+
'INVALID tree item, invalid checkboxState',
|
|
2798
|
+
treeItemThing.checkboxState,
|
|
2799
|
+
);
|
|
2800
|
+
return false;
|
|
2801
|
+
}
|
|
2802
|
+
}
|
|
2803
|
+
|
|
2804
|
+
if (thing instanceof TreeItem) {
|
|
2805
|
+
return true;
|
|
2806
|
+
}
|
|
2807
|
+
|
|
2808
|
+
if (
|
|
2809
|
+
treeItemThing.label !== undefined &&
|
|
2810
|
+
!isString(treeItemThing.label) &&
|
|
2811
|
+
!treeItemThing.label?.label
|
|
2812
|
+
) {
|
|
2813
|
+
console.log('INVALID tree item, invalid label', treeItemThing.label);
|
|
2814
|
+
return false;
|
|
2815
|
+
}
|
|
2816
|
+
if (treeItemThing.id !== undefined && !isString(treeItemThing.id)) {
|
|
2817
|
+
console.log('INVALID tree item, invalid id', treeItemThing.id);
|
|
2818
|
+
return false;
|
|
2819
|
+
}
|
|
2820
|
+
if (
|
|
2821
|
+
treeItemThing.iconPath !== undefined &&
|
|
2822
|
+
!isString(treeItemThing.iconPath) &&
|
|
2823
|
+
!URI.isUri(treeItemThing.iconPath) &&
|
|
2824
|
+
(!treeItemThing.iconPath ||
|
|
2825
|
+
!isString((treeItemThing.iconPath as vscode.ThemeIcon).id))
|
|
2826
|
+
) {
|
|
2827
|
+
const asLightAndDarkThing = treeItemThing.iconPath as {
|
|
2828
|
+
light: string | URI;
|
|
2829
|
+
dark: string | URI;
|
|
2830
|
+
} | null;
|
|
2831
|
+
if (
|
|
2832
|
+
!asLightAndDarkThing ||
|
|
2833
|
+
(!isString(asLightAndDarkThing.light) &&
|
|
2834
|
+
!URI.isUri(asLightAndDarkThing.light) &&
|
|
2835
|
+
!isString(asLightAndDarkThing.dark) &&
|
|
2836
|
+
!URI.isUri(asLightAndDarkThing.dark))
|
|
2837
|
+
) {
|
|
2838
|
+
console.log('INVALID tree item, invalid iconPath', treeItemThing.iconPath);
|
|
2839
|
+
return false;
|
|
2840
|
+
}
|
|
2841
|
+
}
|
|
2842
|
+
if (
|
|
2843
|
+
treeItemThing.description !== undefined &&
|
|
2844
|
+
!isString(treeItemThing.description) &&
|
|
2845
|
+
typeof treeItemThing.description !== 'boolean'
|
|
2846
|
+
) {
|
|
2847
|
+
console.log('INVALID tree item, invalid description', treeItemThing.description);
|
|
2848
|
+
return false;
|
|
2849
|
+
}
|
|
2850
|
+
if (
|
|
2851
|
+
treeItemThing.resourceUri !== undefined &&
|
|
2852
|
+
!URI.isUri(treeItemThing.resourceUri)
|
|
2853
|
+
) {
|
|
2854
|
+
console.log('INVALID tree item, invalid resourceUri', treeItemThing.resourceUri);
|
|
2855
|
+
return false;
|
|
2856
|
+
}
|
|
2857
|
+
if (
|
|
2858
|
+
treeItemThing.tooltip !== undefined &&
|
|
2859
|
+
!isString(treeItemThing.tooltip) &&
|
|
2860
|
+
!(treeItemThing.tooltip instanceof MarkdownString)
|
|
2861
|
+
) {
|
|
2862
|
+
console.log('INVALID tree item, invalid tooltip', treeItemThing.tooltip);
|
|
2863
|
+
return false;
|
|
2864
|
+
}
|
|
2865
|
+
if (treeItemThing.command !== undefined && !treeItemThing.command.command) {
|
|
2866
|
+
console.log('INVALID tree item, invalid command', treeItemThing.command);
|
|
2867
|
+
return false;
|
|
2868
|
+
}
|
|
2869
|
+
if (
|
|
2870
|
+
treeItemThing.collapsibleState !== undefined &&
|
|
2871
|
+
treeItemThing.collapsibleState < TreeItemCollapsibleState.None &&
|
|
2872
|
+
treeItemThing.collapsibleState > TreeItemCollapsibleState.Expanded
|
|
2873
|
+
) {
|
|
2874
|
+
console.log(
|
|
2875
|
+
'INVALID tree item, invalid collapsibleState',
|
|
2876
|
+
treeItemThing.collapsibleState,
|
|
2877
|
+
);
|
|
2878
|
+
return false;
|
|
2879
|
+
}
|
|
2880
|
+
if (
|
|
2881
|
+
treeItemThing.contextValue !== undefined &&
|
|
2882
|
+
!isString(treeItemThing.contextValue)
|
|
2883
|
+
) {
|
|
2884
|
+
console.log(
|
|
2885
|
+
'INVALID tree item, invalid contextValue',
|
|
2886
|
+
treeItemThing.contextValue,
|
|
2887
|
+
);
|
|
2888
|
+
return false;
|
|
2889
|
+
}
|
|
2890
|
+
if (
|
|
2891
|
+
treeItemThing.accessibilityInformation !== undefined &&
|
|
2892
|
+
!treeItemThing.accessibilityInformation?.label
|
|
2893
|
+
) {
|
|
2894
|
+
console.log(
|
|
2895
|
+
'INVALID tree item, invalid accessibilityInformation',
|
|
2896
|
+
treeItemThing.accessibilityInformation,
|
|
2897
|
+
);
|
|
2898
|
+
return false;
|
|
2899
|
+
}
|
|
2900
|
+
|
|
2901
|
+
return true;
|
|
2902
|
+
}
|
|
2903
|
+
|
|
2904
|
+
constructor(
|
|
2905
|
+
label: string | vscode.TreeItemLabel,
|
|
2906
|
+
collapsibleState?: vscode.TreeItemCollapsibleState,
|
|
2907
|
+
);
|
|
2908
|
+
constructor(resourceUri: URI, collapsibleState?: vscode.TreeItemCollapsibleState);
|
|
2909
|
+
constructor(
|
|
2910
|
+
arg1: string | vscode.TreeItemLabel | URI,
|
|
2911
|
+
public collapsibleState: vscode.TreeItemCollapsibleState = TreeItemCollapsibleState.None,
|
|
2912
|
+
) {
|
|
2913
|
+
if (URI.isUri(arg1)) {
|
|
2914
|
+
this.resourceUri = arg1;
|
|
2915
|
+
} else {
|
|
2916
|
+
this.label = arg1;
|
|
2917
|
+
}
|
|
2918
|
+
}
|
|
2919
|
+
}
|
|
2920
|
+
|
|
2921
|
+
export enum TreeItemCollapsibleState {
|
|
2922
|
+
None = 0,
|
|
2923
|
+
Collapsed = 1,
|
|
2924
|
+
Expanded = 2,
|
|
2925
|
+
}
|
|
2926
|
+
|
|
2927
|
+
export enum TreeItemCheckboxState {
|
|
2928
|
+
Unchecked = 0,
|
|
2929
|
+
Checked = 1,
|
|
2930
|
+
}
|
|
2931
|
+
|
|
2932
|
+
export class DataTransferItem implements vscode.DataTransferItem {
|
|
2933
|
+
async asString(): Promise<string> {
|
|
2934
|
+
return typeof this.value === 'string' ? this.value : JSON.stringify(this.value);
|
|
2935
|
+
}
|
|
2936
|
+
|
|
2937
|
+
asFile(): undefined | vscode.DataTransferFile {
|
|
2938
|
+
return undefined;
|
|
2939
|
+
}
|
|
2940
|
+
|
|
2941
|
+
constructor(public readonly value: any) {}
|
|
2942
|
+
}
|
|
2943
|
+
|
|
2944
|
+
/**
|
|
2945
|
+
* A data transfer item that has been created by VS Code instead of by a extension.
|
|
2946
|
+
*
|
|
2947
|
+
* Intentionally not exported to extensions.
|
|
2948
|
+
*/
|
|
2949
|
+
export class InternalDataTransferItem extends DataTransferItem {}
|
|
2950
|
+
|
|
2951
|
+
/**
|
|
2952
|
+
* A data transfer item for a file.
|
|
2953
|
+
*
|
|
2954
|
+
* Intentionally not exported to extensions as only we can create these.
|
|
2955
|
+
*/
|
|
2956
|
+
export class InternalFileDataTransferItem extends InternalDataTransferItem {
|
|
2957
|
+
readonly #file: vscode.DataTransferFile;
|
|
2958
|
+
|
|
2959
|
+
constructor(file: vscode.DataTransferFile) {
|
|
2960
|
+
super('');
|
|
2961
|
+
this.#file = file;
|
|
2962
|
+
}
|
|
2963
|
+
|
|
2964
|
+
override asFile() {
|
|
2965
|
+
return this.#file;
|
|
2966
|
+
}
|
|
2967
|
+
}
|
|
2968
|
+
|
|
2969
|
+
/**
|
|
2970
|
+
* Intentionally not exported to extensions
|
|
2971
|
+
*/
|
|
2972
|
+
export class DataTransferFile implements vscode.DataTransferFile {
|
|
2973
|
+
public readonly name: string;
|
|
2974
|
+
public readonly uri: vscode.Uri | undefined;
|
|
2975
|
+
|
|
2976
|
+
public readonly _itemId: string;
|
|
2977
|
+
private readonly _getData: () => Promise<Uint8Array>;
|
|
2978
|
+
|
|
2979
|
+
constructor(
|
|
2980
|
+
name: string,
|
|
2981
|
+
uri: vscode.Uri | undefined,
|
|
2982
|
+
itemId: string,
|
|
2983
|
+
getData: () => Promise<Uint8Array>,
|
|
2984
|
+
) {
|
|
2985
|
+
this.name = name;
|
|
2986
|
+
this.uri = uri;
|
|
2987
|
+
this._itemId = itemId;
|
|
2988
|
+
this._getData = getData;
|
|
2989
|
+
}
|
|
2990
|
+
|
|
2991
|
+
data(): Promise<Uint8Array> {
|
|
2992
|
+
return this._getData();
|
|
2993
|
+
}
|
|
2994
|
+
}
|
|
2995
|
+
|
|
2996
|
+
export class DataTransfer implements vscode.DataTransfer {
|
|
2997
|
+
#items = new Map<string, DataTransferItem[]>();
|
|
2998
|
+
|
|
2999
|
+
constructor(init?: Iterable<readonly [string, DataTransferItem]>) {
|
|
3000
|
+
for (const [mime, item] of init ?? []) {
|
|
3001
|
+
const existing = this.#items.get(this.#normalizeMime(mime));
|
|
3002
|
+
if (existing) {
|
|
3003
|
+
existing.push(item);
|
|
3004
|
+
} else {
|
|
3005
|
+
this.#items.set(this.#normalizeMime(mime), [item]);
|
|
3006
|
+
}
|
|
3007
|
+
}
|
|
3008
|
+
}
|
|
3009
|
+
|
|
3010
|
+
get(mimeType: string): DataTransferItem | undefined {
|
|
3011
|
+
return this.#items.get(this.#normalizeMime(mimeType))?.[0];
|
|
3012
|
+
}
|
|
3013
|
+
|
|
3014
|
+
set(mimeType: string, value: DataTransferItem): void {
|
|
3015
|
+
// This intentionally overwrites all entries for a given mimetype.
|
|
3016
|
+
// This is similar to how the DOM DataTransfer type works
|
|
3017
|
+
this.#items.set(this.#normalizeMime(mimeType), [value]);
|
|
3018
|
+
}
|
|
3019
|
+
|
|
3020
|
+
forEach(
|
|
3021
|
+
callbackfn: (
|
|
3022
|
+
value: DataTransferItem,
|
|
3023
|
+
key: string,
|
|
3024
|
+
dataTransfer: DataTransfer,
|
|
3025
|
+
) => void,
|
|
3026
|
+
thisArg?: unknown,
|
|
3027
|
+
): void {
|
|
3028
|
+
for (const [mime, items] of this.#items) {
|
|
3029
|
+
for (const item of items) {
|
|
3030
|
+
callbackfn.call(thisArg, item, mime, this);
|
|
3031
|
+
}
|
|
3032
|
+
}
|
|
3033
|
+
}
|
|
3034
|
+
|
|
3035
|
+
*[Symbol.iterator](): IterableIterator<
|
|
3036
|
+
[mimeType: string, item: vscode.DataTransferItem]
|
|
3037
|
+
> {
|
|
3038
|
+
for (const [mime, items] of this.#items) {
|
|
3039
|
+
for (const item of items) {
|
|
3040
|
+
yield [mime, item];
|
|
3041
|
+
}
|
|
3042
|
+
}
|
|
3043
|
+
}
|
|
3044
|
+
|
|
3045
|
+
#normalizeMime(mimeType: string): string {
|
|
3046
|
+
return mimeType.toLowerCase();
|
|
3047
|
+
}
|
|
3048
|
+
}
|
|
3049
|
+
|
|
3050
|
+
export class DocumentDropEdit {
|
|
3051
|
+
id: string | undefined;
|
|
3052
|
+
|
|
3053
|
+
insertText: string | SnippetString;
|
|
3054
|
+
|
|
3055
|
+
additionalEdit?: WorkspaceEdit;
|
|
3056
|
+
|
|
3057
|
+
constructor(insertText: string | SnippetString) {
|
|
3058
|
+
this.insertText = insertText;
|
|
3059
|
+
}
|
|
3060
|
+
}
|
|
3061
|
+
|
|
3062
|
+
export class DocumentPasteEdit {
|
|
3063
|
+
label: string;
|
|
3064
|
+
insertText: string | SnippetString;
|
|
3065
|
+
additionalEdit?: WorkspaceEdit;
|
|
3066
|
+
|
|
3067
|
+
constructor(insertText: string | SnippetString, label: string) {
|
|
3068
|
+
this.label = label;
|
|
3069
|
+
this.insertText = insertText;
|
|
3070
|
+
}
|
|
3071
|
+
}
|
|
3072
|
+
|
|
3073
|
+
export class ThemeIcon {
|
|
3074
|
+
static File: ThemeIcon;
|
|
3075
|
+
static Folder: ThemeIcon;
|
|
3076
|
+
|
|
3077
|
+
readonly id: string;
|
|
3078
|
+
readonly color?: ThemeColor;
|
|
3079
|
+
|
|
3080
|
+
constructor(id: string, color?: ThemeColor) {
|
|
3081
|
+
this.id = id;
|
|
3082
|
+
this.color = color;
|
|
3083
|
+
}
|
|
3084
|
+
|
|
3085
|
+
static isThemeIcon(thing: any) {
|
|
3086
|
+
if (typeof thing.id !== 'string') {
|
|
3087
|
+
console.log('INVALID ThemeIcon, invalid id', thing.id);
|
|
3088
|
+
return false;
|
|
3089
|
+
}
|
|
3090
|
+
return true;
|
|
3091
|
+
}
|
|
3092
|
+
}
|
|
3093
|
+
ThemeIcon.File = new ThemeIcon('file');
|
|
3094
|
+
ThemeIcon.Folder = new ThemeIcon('folder');
|
|
3095
|
+
|
|
3096
|
+
export class ThemeColor {
|
|
3097
|
+
id: string;
|
|
3098
|
+
constructor(id: string) {
|
|
3099
|
+
this.id = id;
|
|
3100
|
+
}
|
|
3101
|
+
}
|
|
3102
|
+
|
|
3103
|
+
export enum ConfigurationTarget {
|
|
3104
|
+
Global = 1,
|
|
3105
|
+
|
|
3106
|
+
Workspace = 2,
|
|
3107
|
+
|
|
3108
|
+
WorkspaceFolder = 3,
|
|
3109
|
+
}
|
|
3110
|
+
|
|
3111
|
+
export class RelativePattern implements IRelativePattern {
|
|
3112
|
+
pattern: string;
|
|
3113
|
+
|
|
3114
|
+
private _base!: string;
|
|
3115
|
+
get base(): string {
|
|
3116
|
+
return this._base;
|
|
3117
|
+
}
|
|
3118
|
+
set base(base: string) {
|
|
3119
|
+
this._base = base;
|
|
3120
|
+
this._baseUri = URI.file(base);
|
|
3121
|
+
}
|
|
3122
|
+
|
|
3123
|
+
private _baseUri!: URI;
|
|
3124
|
+
get baseUri(): URI {
|
|
3125
|
+
return this._baseUri;
|
|
3126
|
+
}
|
|
3127
|
+
set baseUri(baseUri: URI) {
|
|
3128
|
+
this._baseUri = baseUri;
|
|
3129
|
+
this._base = baseUri.fsPath;
|
|
3130
|
+
}
|
|
3131
|
+
|
|
3132
|
+
constructor(base: vscode.WorkspaceFolder | URI | string, pattern: string) {
|
|
3133
|
+
if (typeof base !== 'string') {
|
|
3134
|
+
if (!base || (!URI.isUri(base) && !URI.isUri(base.uri))) {
|
|
3135
|
+
throw illegalArgument('base');
|
|
3136
|
+
}
|
|
3137
|
+
}
|
|
3138
|
+
|
|
3139
|
+
if (typeof pattern !== 'string') {
|
|
3140
|
+
throw illegalArgument('pattern');
|
|
3141
|
+
}
|
|
3142
|
+
|
|
3143
|
+
if (typeof base === 'string') {
|
|
3144
|
+
this.baseUri = URI.file(base);
|
|
3145
|
+
} else if (URI.isUri(base)) {
|
|
3146
|
+
this.baseUri = base;
|
|
3147
|
+
} else {
|
|
3148
|
+
this.baseUri = base.uri;
|
|
3149
|
+
}
|
|
3150
|
+
|
|
3151
|
+
this.pattern = pattern;
|
|
3152
|
+
}
|
|
3153
|
+
|
|
3154
|
+
toJSON(): IRelativePatternDto {
|
|
3155
|
+
return {
|
|
3156
|
+
pattern: this.pattern,
|
|
3157
|
+
base: this.base,
|
|
3158
|
+
baseUri: this.baseUri.toJSON(),
|
|
3159
|
+
};
|
|
3160
|
+
}
|
|
3161
|
+
}
|
|
3162
|
+
|
|
3163
|
+
const breakpointIds = new WeakMap<Breakpoint, string>();
|
|
3164
|
+
|
|
3165
|
+
/**
|
|
3166
|
+
* We want to be able to construct Breakpoints internally that have a particular id, but we don't want extensions to be
|
|
3167
|
+
* able to do this with the exposed Breakpoint classes in extension API.
|
|
3168
|
+
* We also want "instanceof" to work with debug.breakpoints and the exposed breakpoint classes.
|
|
3169
|
+
* And private members will be renamed in the built js, so casting to any and setting a private member is not safe.
|
|
3170
|
+
* So, we store internal breakpoint IDs in a WeakMap. This function must be called after constructing a Breakpoint
|
|
3171
|
+
* with a known id.
|
|
3172
|
+
*/
|
|
3173
|
+
export function setBreakpointId(bp: Breakpoint, id: string) {
|
|
3174
|
+
breakpointIds.set(bp, id);
|
|
3175
|
+
}
|
|
3176
|
+
|
|
3177
|
+
export class Breakpoint {
|
|
3178
|
+
private _id: string | undefined;
|
|
3179
|
+
|
|
3180
|
+
readonly enabled: boolean;
|
|
3181
|
+
readonly condition?: string;
|
|
3182
|
+
readonly hitCondition?: string;
|
|
3183
|
+
readonly logMessage?: string;
|
|
3184
|
+
|
|
3185
|
+
protected constructor(
|
|
3186
|
+
enabled?: boolean,
|
|
3187
|
+
condition?: string,
|
|
3188
|
+
hitCondition?: string,
|
|
3189
|
+
logMessage?: string,
|
|
3190
|
+
) {
|
|
3191
|
+
this.enabled = typeof enabled === 'boolean' ? enabled : true;
|
|
3192
|
+
if (typeof condition === 'string') {
|
|
3193
|
+
this.condition = condition;
|
|
3194
|
+
}
|
|
3195
|
+
if (typeof hitCondition === 'string') {
|
|
3196
|
+
this.hitCondition = hitCondition;
|
|
3197
|
+
}
|
|
3198
|
+
if (typeof logMessage === 'string') {
|
|
3199
|
+
this.logMessage = logMessage;
|
|
3200
|
+
}
|
|
3201
|
+
}
|
|
3202
|
+
|
|
3203
|
+
get id(): string {
|
|
3204
|
+
if (!this._id) {
|
|
3205
|
+
this._id = breakpointIds.get(this) ?? generateUuid();
|
|
3206
|
+
}
|
|
3207
|
+
return this._id;
|
|
3208
|
+
}
|
|
3209
|
+
}
|
|
3210
|
+
|
|
3211
|
+
export class SourceBreakpoint extends Breakpoint {
|
|
3212
|
+
readonly location: Location;
|
|
3213
|
+
|
|
3214
|
+
constructor(
|
|
3215
|
+
location: Location,
|
|
3216
|
+
enabled?: boolean,
|
|
3217
|
+
condition?: string,
|
|
3218
|
+
hitCondition?: string,
|
|
3219
|
+
logMessage?: string,
|
|
3220
|
+
) {
|
|
3221
|
+
super(enabled, condition, hitCondition, logMessage);
|
|
3222
|
+
if (location === null) {
|
|
3223
|
+
throw illegalArgument('location');
|
|
3224
|
+
}
|
|
3225
|
+
this.location = location;
|
|
3226
|
+
}
|
|
3227
|
+
}
|
|
3228
|
+
|
|
3229
|
+
export class FunctionBreakpoint extends Breakpoint {
|
|
3230
|
+
readonly functionName: string;
|
|
3231
|
+
|
|
3232
|
+
constructor(
|
|
3233
|
+
functionName: string,
|
|
3234
|
+
enabled?: boolean,
|
|
3235
|
+
condition?: string,
|
|
3236
|
+
hitCondition?: string,
|
|
3237
|
+
logMessage?: string,
|
|
3238
|
+
) {
|
|
3239
|
+
super(enabled, condition, hitCondition, logMessage);
|
|
3240
|
+
this.functionName = functionName;
|
|
3241
|
+
}
|
|
3242
|
+
}
|
|
3243
|
+
|
|
3244
|
+
export class DataBreakpoint extends Breakpoint {
|
|
3245
|
+
readonly label: string;
|
|
3246
|
+
readonly dataId: string;
|
|
3247
|
+
readonly canPersist: boolean;
|
|
3248
|
+
|
|
3249
|
+
constructor(
|
|
3250
|
+
label: string,
|
|
3251
|
+
dataId: string,
|
|
3252
|
+
canPersist: boolean,
|
|
3253
|
+
enabled?: boolean,
|
|
3254
|
+
condition?: string,
|
|
3255
|
+
hitCondition?: string,
|
|
3256
|
+
logMessage?: string,
|
|
3257
|
+
) {
|
|
3258
|
+
super(enabled, condition, hitCondition, logMessage);
|
|
3259
|
+
if (!dataId) {
|
|
3260
|
+
throw illegalArgument('dataId');
|
|
3261
|
+
}
|
|
3262
|
+
this.label = label;
|
|
3263
|
+
this.dataId = dataId;
|
|
3264
|
+
this.canPersist = canPersist;
|
|
3265
|
+
}
|
|
3266
|
+
}
|
|
3267
|
+
|
|
3268
|
+
export class DebugAdapterExecutable implements vscode.DebugAdapterExecutable {
|
|
3269
|
+
readonly command: string;
|
|
3270
|
+
readonly args: string[];
|
|
3271
|
+
readonly options?: vscode.DebugAdapterExecutableOptions;
|
|
3272
|
+
|
|
3273
|
+
constructor(
|
|
3274
|
+
command: string,
|
|
3275
|
+
args: string[],
|
|
3276
|
+
options?: vscode.DebugAdapterExecutableOptions,
|
|
3277
|
+
) {
|
|
3278
|
+
this.command = command;
|
|
3279
|
+
this.args = args || [];
|
|
3280
|
+
this.options = options;
|
|
3281
|
+
}
|
|
3282
|
+
}
|
|
3283
|
+
|
|
3284
|
+
export class DebugAdapterServer implements vscode.DebugAdapterServer {
|
|
3285
|
+
readonly port: number;
|
|
3286
|
+
readonly host?: string;
|
|
3287
|
+
|
|
3288
|
+
constructor(port: number, host?: string) {
|
|
3289
|
+
this.port = port;
|
|
3290
|
+
this.host = host;
|
|
3291
|
+
}
|
|
3292
|
+
}
|
|
3293
|
+
|
|
3294
|
+
export class DebugAdapterNamedPipeServer implements vscode.DebugAdapterNamedPipeServer {
|
|
3295
|
+
constructor(public readonly path: string) {}
|
|
3296
|
+
}
|
|
3297
|
+
|
|
3298
|
+
export class DebugAdapterInlineImplementation
|
|
3299
|
+
implements vscode.DebugAdapterInlineImplementation
|
|
3300
|
+
{
|
|
3301
|
+
readonly implementation: vscode.DebugAdapter;
|
|
3302
|
+
|
|
3303
|
+
constructor(impl: vscode.DebugAdapter) {
|
|
3304
|
+
this.implementation = impl;
|
|
3305
|
+
}
|
|
3306
|
+
}
|
|
3307
|
+
|
|
3308
|
+
export class StackFrameFocus {
|
|
3309
|
+
constructor(
|
|
3310
|
+
public readonly session: vscode.DebugSession,
|
|
3311
|
+
readonly threadId?: number,
|
|
3312
|
+
readonly frameId?: number,
|
|
3313
|
+
) {}
|
|
3314
|
+
}
|
|
3315
|
+
|
|
3316
|
+
export class ThreadFocus {
|
|
3317
|
+
constructor(
|
|
3318
|
+
public readonly session: vscode.DebugSession,
|
|
3319
|
+
readonly threadId?: number,
|
|
3320
|
+
) {}
|
|
3321
|
+
}
|
|
3322
|
+
|
|
3323
|
+
export class EvaluatableExpression implements vscode.EvaluatableExpression {
|
|
3324
|
+
readonly range: vscode.Range;
|
|
3325
|
+
readonly expression?: string;
|
|
3326
|
+
|
|
3327
|
+
constructor(range: vscode.Range, expression?: string) {
|
|
3328
|
+
this.range = range;
|
|
3329
|
+
this.expression = expression;
|
|
3330
|
+
}
|
|
3331
|
+
}
|
|
3332
|
+
|
|
3333
|
+
export enum InlineCompletionTriggerKind {
|
|
3334
|
+
Invoke = 0,
|
|
3335
|
+
Automatic = 1,
|
|
3336
|
+
}
|
|
3337
|
+
|
|
3338
|
+
export class InlineValueText implements vscode.InlineValueText {
|
|
3339
|
+
readonly range: Range;
|
|
3340
|
+
readonly text: string;
|
|
3341
|
+
|
|
3342
|
+
constructor(range: Range, text: string) {
|
|
3343
|
+
this.range = range;
|
|
3344
|
+
this.text = text;
|
|
3345
|
+
}
|
|
3346
|
+
}
|
|
3347
|
+
|
|
3348
|
+
export class InlineValueVariableLookup implements vscode.InlineValueVariableLookup {
|
|
3349
|
+
readonly range: Range;
|
|
3350
|
+
readonly variableName?: string;
|
|
3351
|
+
readonly caseSensitiveLookup: boolean;
|
|
3352
|
+
|
|
3353
|
+
constructor(range: Range, variableName?: string, caseSensitiveLookup = true) {
|
|
3354
|
+
this.range = range;
|
|
3355
|
+
this.variableName = variableName;
|
|
3356
|
+
this.caseSensitiveLookup = caseSensitiveLookup;
|
|
3357
|
+
}
|
|
3358
|
+
}
|
|
3359
|
+
|
|
3360
|
+
export class InlineValueEvaluatableExpression
|
|
3361
|
+
implements vscode.InlineValueEvaluatableExpression
|
|
3362
|
+
{
|
|
3363
|
+
readonly range: Range;
|
|
3364
|
+
readonly expression?: string;
|
|
3365
|
+
|
|
3366
|
+
constructor(range: Range, expression?: string) {
|
|
3367
|
+
this.range = range;
|
|
3368
|
+
this.expression = expression;
|
|
3369
|
+
}
|
|
3370
|
+
}
|
|
3371
|
+
|
|
3372
|
+
export class InlineValueContext implements vscode.InlineValueContext {
|
|
3373
|
+
readonly frameId: number;
|
|
3374
|
+
readonly stoppedLocation: vscode.Range;
|
|
3375
|
+
|
|
3376
|
+
constructor(frameId: number, range: vscode.Range) {
|
|
3377
|
+
this.frameId = frameId;
|
|
3378
|
+
this.stoppedLocation = range;
|
|
3379
|
+
}
|
|
3380
|
+
}
|
|
3381
|
+
|
|
3382
|
+
//#region file api
|
|
3383
|
+
|
|
3384
|
+
export enum FileChangeType {
|
|
3385
|
+
Changed = 1,
|
|
3386
|
+
Created = 2,
|
|
3387
|
+
Deleted = 3,
|
|
3388
|
+
}
|
|
3389
|
+
|
|
3390
|
+
export class FileSystemError extends Error {
|
|
3391
|
+
static FileExists(messageOrUri?: string | URI): FileSystemError {
|
|
3392
|
+
return new FileSystemError(
|
|
3393
|
+
messageOrUri,
|
|
3394
|
+
FileSystemProviderErrorCode.FileExists,
|
|
3395
|
+
FileSystemError.FileExists,
|
|
3396
|
+
);
|
|
3397
|
+
}
|
|
3398
|
+
static FileNotFound(messageOrUri?: string | URI): FileSystemError {
|
|
3399
|
+
return new FileSystemError(
|
|
3400
|
+
messageOrUri,
|
|
3401
|
+
FileSystemProviderErrorCode.FileNotFound,
|
|
3402
|
+
FileSystemError.FileNotFound,
|
|
3403
|
+
);
|
|
3404
|
+
}
|
|
3405
|
+
static FileNotADirectory(messageOrUri?: string | URI): FileSystemError {
|
|
3406
|
+
return new FileSystemError(
|
|
3407
|
+
messageOrUri,
|
|
3408
|
+
FileSystemProviderErrorCode.FileNotADirectory,
|
|
3409
|
+
FileSystemError.FileNotADirectory,
|
|
3410
|
+
);
|
|
3411
|
+
}
|
|
3412
|
+
static FileIsADirectory(messageOrUri?: string | URI): FileSystemError {
|
|
3413
|
+
return new FileSystemError(
|
|
3414
|
+
messageOrUri,
|
|
3415
|
+
FileSystemProviderErrorCode.FileIsADirectory,
|
|
3416
|
+
FileSystemError.FileIsADirectory,
|
|
3417
|
+
);
|
|
3418
|
+
}
|
|
3419
|
+
static NoPermissions(messageOrUri?: string | URI): FileSystemError {
|
|
3420
|
+
return new FileSystemError(
|
|
3421
|
+
messageOrUri,
|
|
3422
|
+
FileSystemProviderErrorCode.NoPermissions,
|
|
3423
|
+
FileSystemError.NoPermissions,
|
|
3424
|
+
);
|
|
3425
|
+
}
|
|
3426
|
+
static Unavailable(messageOrUri?: string | URI): FileSystemError {
|
|
3427
|
+
return new FileSystemError(
|
|
3428
|
+
messageOrUri,
|
|
3429
|
+
FileSystemProviderErrorCode.Unavailable,
|
|
3430
|
+
FileSystemError.Unavailable,
|
|
3431
|
+
);
|
|
3432
|
+
}
|
|
3433
|
+
|
|
3434
|
+
readonly code: string;
|
|
3435
|
+
|
|
3436
|
+
constructor(
|
|
3437
|
+
uriOrMessage?: string | URI,
|
|
3438
|
+
code: FileSystemProviderErrorCode = FileSystemProviderErrorCode.Unknown,
|
|
3439
|
+
terminator?: Function,
|
|
3440
|
+
) {
|
|
3441
|
+
super(URI.isUri(uriOrMessage) ? uriOrMessage.toString(true) : uriOrMessage);
|
|
3442
|
+
|
|
3443
|
+
this.code = terminator?.name ?? 'Unknown';
|
|
3444
|
+
|
|
3445
|
+
// mark the error as file system provider error so that
|
|
3446
|
+
// we can extract the error code on the receiving side
|
|
3447
|
+
markAsFileSystemProviderError(this, code);
|
|
3448
|
+
|
|
3449
|
+
// workaround when extending builtin objects and when compiling to ES5, see:
|
|
3450
|
+
// https://github.com/microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work
|
|
3451
|
+
Object.setPrototypeOf(this, FileSystemError.prototype);
|
|
3452
|
+
|
|
3453
|
+
if (
|
|
3454
|
+
typeof Error.captureStackTrace === 'function' &&
|
|
3455
|
+
typeof terminator === 'function'
|
|
3456
|
+
) {
|
|
3457
|
+
// nice stack traces
|
|
3458
|
+
Error.captureStackTrace(this, terminator);
|
|
3459
|
+
}
|
|
3460
|
+
}
|
|
3461
|
+
}
|
|
3462
|
+
|
|
3463
|
+
//#endregion
|
|
3464
|
+
|
|
3465
|
+
//#region folding api
|
|
3466
|
+
|
|
3467
|
+
export class FoldingRange {
|
|
3468
|
+
start: number;
|
|
3469
|
+
|
|
3470
|
+
end: number;
|
|
3471
|
+
|
|
3472
|
+
kind?: FoldingRangeKind;
|
|
3473
|
+
|
|
3474
|
+
constructor(start: number, end: number, kind?: FoldingRangeKind) {
|
|
3475
|
+
this.start = start;
|
|
3476
|
+
this.end = end;
|
|
3477
|
+
this.kind = kind;
|
|
3478
|
+
}
|
|
3479
|
+
}
|
|
3480
|
+
|
|
3481
|
+
export enum FoldingRangeKind {
|
|
3482
|
+
Comment = 1,
|
|
3483
|
+
Imports = 2,
|
|
3484
|
+
Region = 3,
|
|
3485
|
+
}
|
|
3486
|
+
|
|
3487
|
+
//#endregion
|
|
3488
|
+
|
|
3489
|
+
//#region Comment
|
|
3490
|
+
export enum CommentThreadCollapsibleState {
|
|
3491
|
+
/**
|
|
3492
|
+
* Determines an item is collapsed
|
|
3493
|
+
*/
|
|
3494
|
+
Collapsed = 0,
|
|
3495
|
+
/**
|
|
3496
|
+
* Determines an item is expanded
|
|
3497
|
+
*/
|
|
3498
|
+
Expanded = 1,
|
|
3499
|
+
}
|
|
3500
|
+
|
|
3501
|
+
export enum CommentMode {
|
|
3502
|
+
Editing = 0,
|
|
3503
|
+
Preview = 1,
|
|
3504
|
+
}
|
|
3505
|
+
|
|
3506
|
+
export enum CommentState {
|
|
3507
|
+
Published = 0,
|
|
3508
|
+
Draft = 1,
|
|
3509
|
+
}
|
|
3510
|
+
|
|
3511
|
+
export enum CommentThreadState {
|
|
3512
|
+
Unresolved = 0,
|
|
3513
|
+
Resolved = 1,
|
|
3514
|
+
}
|
|
3515
|
+
|
|
3516
|
+
//#endregion
|
|
3517
|
+
|
|
3518
|
+
//#region Semantic Coloring
|
|
3519
|
+
|
|
3520
|
+
export class SemanticTokensLegend {
|
|
3521
|
+
public readonly tokenTypes: string[];
|
|
3522
|
+
public readonly tokenModifiers: string[];
|
|
3523
|
+
|
|
3524
|
+
constructor(tokenTypes: string[], tokenModifiers: string[] = []) {
|
|
3525
|
+
this.tokenTypes = tokenTypes;
|
|
3526
|
+
this.tokenModifiers = tokenModifiers;
|
|
3527
|
+
}
|
|
3528
|
+
}
|
|
3529
|
+
|
|
3530
|
+
function isStrArrayOrUndefined(arg: any): arg is string[] | undefined {
|
|
3531
|
+
return typeof arg === 'undefined' || isStringArray(arg);
|
|
3532
|
+
}
|
|
3533
|
+
|
|
3534
|
+
export class SemanticTokensBuilder {
|
|
3535
|
+
private _prevLine: number;
|
|
3536
|
+
private _prevChar: number;
|
|
3537
|
+
private _dataIsSortedAndDeltaEncoded: boolean;
|
|
3538
|
+
private _data: number[];
|
|
3539
|
+
private _dataLen: number;
|
|
3540
|
+
private _tokenTypeStrToInt: Map<string, number>;
|
|
3541
|
+
private _tokenModifierStrToInt: Map<string, number>;
|
|
3542
|
+
private _hasLegend: boolean;
|
|
3543
|
+
|
|
3544
|
+
constructor(legend?: vscode.SemanticTokensLegend) {
|
|
3545
|
+
this._prevLine = 0;
|
|
3546
|
+
this._prevChar = 0;
|
|
3547
|
+
this._dataIsSortedAndDeltaEncoded = true;
|
|
3548
|
+
this._data = [];
|
|
3549
|
+
this._dataLen = 0;
|
|
3550
|
+
this._tokenTypeStrToInt = new Map<string, number>();
|
|
3551
|
+
this._tokenModifierStrToInt = new Map<string, number>();
|
|
3552
|
+
this._hasLegend = false;
|
|
3553
|
+
if (legend) {
|
|
3554
|
+
this._hasLegend = true;
|
|
3555
|
+
for (let i = 0, len = legend.tokenTypes.length; i < len; i++) {
|
|
3556
|
+
this._tokenTypeStrToInt.set(legend.tokenTypes[i], i);
|
|
3557
|
+
}
|
|
3558
|
+
for (let i = 0, len = legend.tokenModifiers.length; i < len; i++) {
|
|
3559
|
+
this._tokenModifierStrToInt.set(legend.tokenModifiers[i], i);
|
|
3560
|
+
}
|
|
3561
|
+
}
|
|
3562
|
+
}
|
|
3563
|
+
|
|
3564
|
+
public push(
|
|
3565
|
+
line: number,
|
|
3566
|
+
char: number,
|
|
3567
|
+
length: number,
|
|
3568
|
+
tokenType: number,
|
|
3569
|
+
tokenModifiers?: number,
|
|
3570
|
+
): void;
|
|
3571
|
+
public push(range: Range, tokenType: string, tokenModifiers?: string[]): void;
|
|
3572
|
+
public push(arg0: any, arg1: any, arg2: any, arg3?: any, arg4?: any): void {
|
|
3573
|
+
if (
|
|
3574
|
+
typeof arg0 === 'number' &&
|
|
3575
|
+
typeof arg1 === 'number' &&
|
|
3576
|
+
typeof arg2 === 'number' &&
|
|
3577
|
+
typeof arg3 === 'number' &&
|
|
3578
|
+
(typeof arg4 === 'number' || typeof arg4 === 'undefined')
|
|
3579
|
+
) {
|
|
3580
|
+
if (typeof arg4 === 'undefined') {
|
|
3581
|
+
arg4 = 0;
|
|
3582
|
+
}
|
|
3583
|
+
// 1st overload
|
|
3584
|
+
return this._pushEncoded(arg0, arg1, arg2, arg3, arg4);
|
|
3585
|
+
}
|
|
3586
|
+
if (
|
|
3587
|
+
Range.isRange(arg0) &&
|
|
3588
|
+
typeof arg1 === 'string' &&
|
|
3589
|
+
isStrArrayOrUndefined(arg2)
|
|
3590
|
+
) {
|
|
3591
|
+
// 2nd overload
|
|
3592
|
+
return this._push(arg0, arg1, arg2);
|
|
3593
|
+
}
|
|
3594
|
+
throw illegalArgument();
|
|
3595
|
+
}
|
|
3596
|
+
|
|
3597
|
+
private _push(
|
|
3598
|
+
range: vscode.Range,
|
|
3599
|
+
tokenType: string,
|
|
3600
|
+
tokenModifiers?: string[],
|
|
3601
|
+
): void {
|
|
3602
|
+
if (!this._hasLegend) {
|
|
3603
|
+
throw new Error('Legend must be provided in constructor');
|
|
3604
|
+
}
|
|
3605
|
+
if (range.start.line !== range.end.line) {
|
|
3606
|
+
throw new Error('`range` cannot span multiple lines');
|
|
3607
|
+
}
|
|
3608
|
+
if (!this._tokenTypeStrToInt.has(tokenType)) {
|
|
3609
|
+
throw new Error('`tokenType` is not in the provided legend');
|
|
3610
|
+
}
|
|
3611
|
+
const line = range.start.line;
|
|
3612
|
+
const char = range.start.character;
|
|
3613
|
+
const length = range.end.character - range.start.character;
|
|
3614
|
+
const nTokenType = this._tokenTypeStrToInt.get(tokenType)!;
|
|
3615
|
+
let nTokenModifiers = 0;
|
|
3616
|
+
if (tokenModifiers) {
|
|
3617
|
+
for (const tokenModifier of tokenModifiers) {
|
|
3618
|
+
if (!this._tokenModifierStrToInt.has(tokenModifier)) {
|
|
3619
|
+
throw new Error('`tokenModifier` is not in the provided legend');
|
|
3620
|
+
}
|
|
3621
|
+
const nTokenModifier = this._tokenModifierStrToInt.get(tokenModifier)!;
|
|
3622
|
+
nTokenModifiers |= (1 << nTokenModifier) >>> 0;
|
|
3623
|
+
}
|
|
3624
|
+
}
|
|
3625
|
+
this._pushEncoded(line, char, length, nTokenType, nTokenModifiers);
|
|
3626
|
+
}
|
|
3627
|
+
|
|
3628
|
+
private _pushEncoded(
|
|
3629
|
+
line: number,
|
|
3630
|
+
char: number,
|
|
3631
|
+
length: number,
|
|
3632
|
+
tokenType: number,
|
|
3633
|
+
tokenModifiers: number,
|
|
3634
|
+
): void {
|
|
3635
|
+
if (
|
|
3636
|
+
this._dataIsSortedAndDeltaEncoded &&
|
|
3637
|
+
(line < this._prevLine || (line === this._prevLine && char < this._prevChar))
|
|
3638
|
+
) {
|
|
3639
|
+
// push calls were ordered and are no longer ordered
|
|
3640
|
+
this._dataIsSortedAndDeltaEncoded = false;
|
|
3641
|
+
|
|
3642
|
+
// Remove delta encoding from data
|
|
3643
|
+
const tokenCount = (this._data.length / 5) | 0;
|
|
3644
|
+
let prevLine = 0;
|
|
3645
|
+
let prevChar = 0;
|
|
3646
|
+
for (let i = 0; i < tokenCount; i++) {
|
|
3647
|
+
let line = this._data[5 * i];
|
|
3648
|
+
let char = this._data[5 * i + 1];
|
|
3649
|
+
|
|
3650
|
+
if (line === 0) {
|
|
3651
|
+
// on the same line as previous token
|
|
3652
|
+
line = prevLine;
|
|
3653
|
+
char += prevChar;
|
|
3654
|
+
} else {
|
|
3655
|
+
// on a different line than previous token
|
|
3656
|
+
line += prevLine;
|
|
3657
|
+
}
|
|
3658
|
+
|
|
3659
|
+
this._data[5 * i] = line;
|
|
3660
|
+
this._data[5 * i + 1] = char;
|
|
3661
|
+
|
|
3662
|
+
prevLine = line;
|
|
3663
|
+
prevChar = char;
|
|
3664
|
+
}
|
|
3665
|
+
}
|
|
3666
|
+
|
|
3667
|
+
let pushLine = line;
|
|
3668
|
+
let pushChar = char;
|
|
3669
|
+
if (this._dataIsSortedAndDeltaEncoded && this._dataLen > 0) {
|
|
3670
|
+
pushLine -= this._prevLine;
|
|
3671
|
+
if (pushLine === 0) {
|
|
3672
|
+
pushChar -= this._prevChar;
|
|
3673
|
+
}
|
|
3674
|
+
}
|
|
3675
|
+
|
|
3676
|
+
this._data[this._dataLen++] = pushLine;
|
|
3677
|
+
this._data[this._dataLen++] = pushChar;
|
|
3678
|
+
this._data[this._dataLen++] = length;
|
|
3679
|
+
this._data[this._dataLen++] = tokenType;
|
|
3680
|
+
this._data[this._dataLen++] = tokenModifiers;
|
|
3681
|
+
|
|
3682
|
+
this._prevLine = line;
|
|
3683
|
+
this._prevChar = char;
|
|
3684
|
+
}
|
|
3685
|
+
|
|
3686
|
+
private static _sortAndDeltaEncode(data: number[]): Uint32Array {
|
|
3687
|
+
const pos: number[] = [];
|
|
3688
|
+
const tokenCount = (data.length / 5) | 0;
|
|
3689
|
+
for (let i = 0; i < tokenCount; i++) {
|
|
3690
|
+
pos[i] = i;
|
|
3691
|
+
}
|
|
3692
|
+
pos.sort((a, b) => {
|
|
3693
|
+
const aLine = data[5 * a];
|
|
3694
|
+
const bLine = data[5 * b];
|
|
3695
|
+
if (aLine === bLine) {
|
|
3696
|
+
const aChar = data[5 * a + 1];
|
|
3697
|
+
const bChar = data[5 * b + 1];
|
|
3698
|
+
return aChar - bChar;
|
|
3699
|
+
}
|
|
3700
|
+
return aLine - bLine;
|
|
3701
|
+
});
|
|
3702
|
+
const result = new Uint32Array(data.length);
|
|
3703
|
+
let prevLine = 0;
|
|
3704
|
+
let prevChar = 0;
|
|
3705
|
+
for (let i = 0; i < tokenCount; i++) {
|
|
3706
|
+
const srcOffset = 5 * pos[i];
|
|
3707
|
+
const line = data[srcOffset + 0];
|
|
3708
|
+
const char = data[srcOffset + 1];
|
|
3709
|
+
const length = data[srcOffset + 2];
|
|
3710
|
+
const tokenType = data[srcOffset + 3];
|
|
3711
|
+
const tokenModifiers = data[srcOffset + 4];
|
|
3712
|
+
|
|
3713
|
+
const pushLine = line - prevLine;
|
|
3714
|
+
const pushChar = pushLine === 0 ? char - prevChar : char;
|
|
3715
|
+
|
|
3716
|
+
const dstOffset = 5 * i;
|
|
3717
|
+
result[dstOffset + 0] = pushLine;
|
|
3718
|
+
result[dstOffset + 1] = pushChar;
|
|
3719
|
+
result[dstOffset + 2] = length;
|
|
3720
|
+
result[dstOffset + 3] = tokenType;
|
|
3721
|
+
result[dstOffset + 4] = tokenModifiers;
|
|
3722
|
+
|
|
3723
|
+
prevLine = line;
|
|
3724
|
+
prevChar = char;
|
|
3725
|
+
}
|
|
3726
|
+
|
|
3727
|
+
return result;
|
|
3728
|
+
}
|
|
3729
|
+
|
|
3730
|
+
public build(resultId?: string): SemanticTokens {
|
|
3731
|
+
if (!this._dataIsSortedAndDeltaEncoded) {
|
|
3732
|
+
return new SemanticTokens(
|
|
3733
|
+
SemanticTokensBuilder._sortAndDeltaEncode(this._data),
|
|
3734
|
+
resultId,
|
|
3735
|
+
);
|
|
3736
|
+
}
|
|
3737
|
+
return new SemanticTokens(new Uint32Array(this._data), resultId);
|
|
3738
|
+
}
|
|
3739
|
+
}
|
|
3740
|
+
|
|
3741
|
+
export class SemanticTokens {
|
|
3742
|
+
readonly resultId: string | undefined;
|
|
3743
|
+
readonly data: Uint32Array;
|
|
3744
|
+
|
|
3745
|
+
constructor(data: Uint32Array, resultId?: string) {
|
|
3746
|
+
this.resultId = resultId;
|
|
3747
|
+
this.data = data;
|
|
3748
|
+
}
|
|
3749
|
+
}
|
|
3750
|
+
|
|
3751
|
+
export class SemanticTokensEdit {
|
|
3752
|
+
readonly start: number;
|
|
3753
|
+
readonly deleteCount: number;
|
|
3754
|
+
readonly data: Uint32Array | undefined;
|
|
3755
|
+
|
|
3756
|
+
constructor(start: number, deleteCount: number, data?: Uint32Array) {
|
|
3757
|
+
this.start = start;
|
|
3758
|
+
this.deleteCount = deleteCount;
|
|
3759
|
+
this.data = data;
|
|
3760
|
+
}
|
|
3761
|
+
}
|
|
3762
|
+
|
|
3763
|
+
export class SemanticTokensEdits {
|
|
3764
|
+
readonly resultId: string | undefined;
|
|
3765
|
+
readonly edits: SemanticTokensEdit[];
|
|
3766
|
+
|
|
3767
|
+
constructor(edits: SemanticTokensEdit[], resultId?: string) {
|
|
3768
|
+
this.resultId = resultId;
|
|
3769
|
+
this.edits = edits;
|
|
3770
|
+
}
|
|
3771
|
+
}
|
|
3772
|
+
|
|
3773
|
+
//#endregion
|
|
3774
|
+
|
|
3775
|
+
//#region debug
|
|
3776
|
+
export enum DebugConsoleMode {
|
|
3777
|
+
/**
|
|
3778
|
+
* Debug session should have a separate debug console.
|
|
3779
|
+
*/
|
|
3780
|
+
Separate = 0,
|
|
3781
|
+
|
|
3782
|
+
/**
|
|
3783
|
+
* Debug session should share debug console with its parent session.
|
|
3784
|
+
* This value has no effect for sessions which do not have a parent session.
|
|
3785
|
+
*/
|
|
3786
|
+
MergeWithParent = 1,
|
|
3787
|
+
}
|
|
3788
|
+
|
|
3789
|
+
//#endregion
|
|
3790
|
+
|
|
3791
|
+
export class QuickInputButtons {
|
|
3792
|
+
static readonly Back: vscode.QuickInputButton = {
|
|
3793
|
+
iconPath: new ThemeIcon('arrow-left'),
|
|
3794
|
+
};
|
|
3795
|
+
|
|
3796
|
+
private constructor() {}
|
|
3797
|
+
}
|
|
3798
|
+
|
|
3799
|
+
export enum QuickPickItemKind {
|
|
3800
|
+
Separator = -1,
|
|
3801
|
+
Default = 0,
|
|
3802
|
+
}
|
|
3803
|
+
|
|
3804
|
+
export enum InputBoxValidationSeverity {
|
|
3805
|
+
Info = 1,
|
|
3806
|
+
Warning = 2,
|
|
3807
|
+
Error = 3,
|
|
3808
|
+
}
|
|
3809
|
+
|
|
3810
|
+
export enum ExtensionKind {
|
|
3811
|
+
UI = 1,
|
|
3812
|
+
Workspace = 2,
|
|
3813
|
+
}
|
|
3814
|
+
|
|
3815
|
+
// export class FileDecoration {
|
|
3816
|
+
// static validate(d: FileDecoration): boolean {
|
|
3817
|
+
// if (typeof d.badge === 'string') {
|
|
3818
|
+
// let len = nextCharLength(d.badge, 0);
|
|
3819
|
+
// if (len < d.badge.length) {
|
|
3820
|
+
// len += nextCharLength(d.badge, len);
|
|
3821
|
+
// }
|
|
3822
|
+
// if (d.badge.length > len) {
|
|
3823
|
+
// throw new Error(`The 'badge'-property must be undefined or a short character`);
|
|
3824
|
+
// }
|
|
3825
|
+
// } else if (d.badge) {
|
|
3826
|
+
// if (!ThemeIcon.isThemeIcon(d.badge)) {
|
|
3827
|
+
// throw new Error(`The 'badge'-property is not a valid ThemeIcon`);
|
|
3828
|
+
// }
|
|
3829
|
+
// }
|
|
3830
|
+
// if (!d.color && !d.badge && !d.tooltip) {
|
|
3831
|
+
// throw new Error(`The decoration is empty`);
|
|
3832
|
+
// }
|
|
3833
|
+
// return true;
|
|
3834
|
+
// }
|
|
3835
|
+
|
|
3836
|
+
// badge?: string | vscode.ThemeIcon;
|
|
3837
|
+
// tooltip?: string;
|
|
3838
|
+
// color?: vscode.ThemeColor;
|
|
3839
|
+
// propagate?: boolean;
|
|
3840
|
+
|
|
3841
|
+
// constructor(badge?: string | ThemeIcon, tooltip?: string, color?: ThemeColor) {
|
|
3842
|
+
// this.badge = badge;
|
|
3843
|
+
// this.tooltip = tooltip;
|
|
3844
|
+
// this.color = color;
|
|
3845
|
+
// }
|
|
3846
|
+
// }
|
|
3847
|
+
|
|
3848
|
+
//#region Theming
|
|
3849
|
+
|
|
3850
|
+
export class ColorTheme implements vscode.ColorTheme {
|
|
3851
|
+
constructor(public readonly kind: ColorThemeKind) {}
|
|
3852
|
+
}
|
|
3853
|
+
|
|
3854
|
+
export enum ColorThemeKind {
|
|
3855
|
+
Light = 1,
|
|
3856
|
+
Dark = 2,
|
|
3857
|
+
HighContrast = 3,
|
|
3858
|
+
HighContrastLight = 4,
|
|
3859
|
+
}
|
|
3860
|
+
|
|
3861
|
+
//#endregion Theming
|
|
3862
|
+
|
|
3863
|
+
//#region Notebook
|
|
3864
|
+
|
|
3865
|
+
export class NotebookRange {
|
|
3866
|
+
static isNotebookRange(thing: any): thing is vscode.NotebookRange {
|
|
3867
|
+
if (thing instanceof NotebookRange) {
|
|
3868
|
+
return true;
|
|
3869
|
+
}
|
|
3870
|
+
if (!thing) {
|
|
3871
|
+
return false;
|
|
3872
|
+
}
|
|
3873
|
+
return (
|
|
3874
|
+
typeof (<NotebookRange>thing).start === 'number' &&
|
|
3875
|
+
typeof (<NotebookRange>thing).end === 'number'
|
|
3876
|
+
);
|
|
3877
|
+
}
|
|
3878
|
+
|
|
3879
|
+
private _start: number;
|
|
3880
|
+
private _end: number;
|
|
3881
|
+
|
|
3882
|
+
get start() {
|
|
3883
|
+
return this._start;
|
|
3884
|
+
}
|
|
3885
|
+
|
|
3886
|
+
get end() {
|
|
3887
|
+
return this._end;
|
|
3888
|
+
}
|
|
3889
|
+
|
|
3890
|
+
get isEmpty(): boolean {
|
|
3891
|
+
return this._start === this._end;
|
|
3892
|
+
}
|
|
3893
|
+
|
|
3894
|
+
constructor(start: number, end: number) {
|
|
3895
|
+
if (start < 0) {
|
|
3896
|
+
throw illegalArgument('start must be positive');
|
|
3897
|
+
}
|
|
3898
|
+
if (end < 0) {
|
|
3899
|
+
throw illegalArgument('end must be positive');
|
|
3900
|
+
}
|
|
3901
|
+
if (start <= end) {
|
|
3902
|
+
this._start = start;
|
|
3903
|
+
this._end = end;
|
|
3904
|
+
} else {
|
|
3905
|
+
this._start = end;
|
|
3906
|
+
this._end = start;
|
|
3907
|
+
}
|
|
3908
|
+
}
|
|
3909
|
+
|
|
3910
|
+
with(change: { start?: number; end?: number }): NotebookRange {
|
|
3911
|
+
let start = this._start;
|
|
3912
|
+
let end = this._end;
|
|
3913
|
+
|
|
3914
|
+
if (change.start !== undefined) {
|
|
3915
|
+
start = change.start;
|
|
3916
|
+
}
|
|
3917
|
+
if (change.end !== undefined) {
|
|
3918
|
+
end = change.end;
|
|
3919
|
+
}
|
|
3920
|
+
if (start === this._start && end === this._end) {
|
|
3921
|
+
return this;
|
|
3922
|
+
}
|
|
3923
|
+
return new NotebookRange(start, end);
|
|
3924
|
+
}
|
|
3925
|
+
}
|
|
3926
|
+
|
|
3927
|
+
export class NotebookCellData {
|
|
3928
|
+
static validate(data: NotebookCellData): void {
|
|
3929
|
+
if (typeof data.kind !== 'number') {
|
|
3930
|
+
throw new Error("NotebookCellData MUST have 'kind' property");
|
|
3931
|
+
}
|
|
3932
|
+
if (typeof data.value !== 'string') {
|
|
3933
|
+
throw new Error("NotebookCellData MUST have 'value' property");
|
|
3934
|
+
}
|
|
3935
|
+
if (typeof data.languageId !== 'string') {
|
|
3936
|
+
throw new Error("NotebookCellData MUST have 'languageId' property");
|
|
3937
|
+
}
|
|
3938
|
+
}
|
|
3939
|
+
|
|
3940
|
+
static isNotebookCellDataArray(value: unknown): value is vscode.NotebookCellData[] {
|
|
3941
|
+
return (
|
|
3942
|
+
Array.isArray(value) &&
|
|
3943
|
+
(<unknown[]>value).every((elem) => NotebookCellData.isNotebookCellData(elem))
|
|
3944
|
+
);
|
|
3945
|
+
}
|
|
3946
|
+
|
|
3947
|
+
static isNotebookCellData(value: unknown): value is vscode.NotebookCellData {
|
|
3948
|
+
// return value instanceof NotebookCellData;
|
|
3949
|
+
return true;
|
|
3950
|
+
}
|
|
3951
|
+
|
|
3952
|
+
kind: NotebookCellKind;
|
|
3953
|
+
value: string;
|
|
3954
|
+
languageId: string;
|
|
3955
|
+
mime?: string;
|
|
3956
|
+
outputs?: vscode.NotebookCellOutput[];
|
|
3957
|
+
metadata?: Record<string, any>;
|
|
3958
|
+
executionSummary?: vscode.NotebookCellExecutionSummary;
|
|
3959
|
+
|
|
3960
|
+
constructor(
|
|
3961
|
+
kind: NotebookCellKind,
|
|
3962
|
+
value: string,
|
|
3963
|
+
languageId: string,
|
|
3964
|
+
mime?: string,
|
|
3965
|
+
outputs?: vscode.NotebookCellOutput[],
|
|
3966
|
+
metadata?: Record<string, any>,
|
|
3967
|
+
executionSummary?: vscode.NotebookCellExecutionSummary,
|
|
3968
|
+
) {
|
|
3969
|
+
this.kind = kind;
|
|
3970
|
+
this.value = value;
|
|
3971
|
+
this.languageId = languageId;
|
|
3972
|
+
this.mime = mime;
|
|
3973
|
+
this.outputs = outputs ?? [];
|
|
3974
|
+
this.metadata = metadata;
|
|
3975
|
+
this.executionSummary = executionSummary;
|
|
3976
|
+
|
|
3977
|
+
NotebookCellData.validate(this);
|
|
3978
|
+
}
|
|
3979
|
+
}
|
|
3980
|
+
|
|
3981
|
+
export class NotebookData {
|
|
3982
|
+
cells: NotebookCellData[];
|
|
3983
|
+
metadata?: { [key: string]: any };
|
|
3984
|
+
|
|
3985
|
+
constructor(cells: NotebookCellData[]) {
|
|
3986
|
+
this.cells = cells;
|
|
3987
|
+
}
|
|
3988
|
+
}
|
|
3989
|
+
|
|
3990
|
+
export class NotebookCellOutputItem {
|
|
3991
|
+
static isNotebookCellOutputItem(obj: unknown): obj is vscode.NotebookCellOutputItem {
|
|
3992
|
+
if (obj instanceof NotebookCellOutputItem) {
|
|
3993
|
+
return true;
|
|
3994
|
+
}
|
|
3995
|
+
if (!obj) {
|
|
3996
|
+
return false;
|
|
3997
|
+
}
|
|
3998
|
+
return (
|
|
3999
|
+
typeof (<vscode.NotebookCellOutputItem>obj).mime === 'string' &&
|
|
4000
|
+
(<vscode.NotebookCellOutputItem>obj).data instanceof Uint8Array
|
|
4001
|
+
);
|
|
4002
|
+
}
|
|
4003
|
+
|
|
4004
|
+
static error(
|
|
4005
|
+
err: Error | { name: string; message?: string; stack?: string },
|
|
4006
|
+
): NotebookCellOutputItem {
|
|
4007
|
+
const obj = {
|
|
4008
|
+
name: err.name,
|
|
4009
|
+
message: err.message,
|
|
4010
|
+
stack: err.stack,
|
|
4011
|
+
};
|
|
4012
|
+
return NotebookCellOutputItem.json(obj, 'application/vnd.code.notebook.error');
|
|
4013
|
+
}
|
|
4014
|
+
|
|
4015
|
+
static stdout(value: string): NotebookCellOutputItem {
|
|
4016
|
+
return NotebookCellOutputItem.text(value, 'application/vnd.code.notebook.stdout');
|
|
4017
|
+
}
|
|
4018
|
+
|
|
4019
|
+
static stderr(value: string): NotebookCellOutputItem {
|
|
4020
|
+
return NotebookCellOutputItem.text(value, 'application/vnd.code.notebook.stderr');
|
|
4021
|
+
}
|
|
4022
|
+
|
|
4023
|
+
static bytes(
|
|
4024
|
+
value: Uint8Array,
|
|
4025
|
+
mime = 'application/octet-stream',
|
|
4026
|
+
): NotebookCellOutputItem {
|
|
4027
|
+
return new NotebookCellOutputItem(value, mime);
|
|
4028
|
+
}
|
|
4029
|
+
|
|
4030
|
+
static #encoder = new TextEncoder();
|
|
4031
|
+
|
|
4032
|
+
static text(value: string, mime: string = Mimes.text): NotebookCellOutputItem {
|
|
4033
|
+
const bytes = NotebookCellOutputItem.#encoder.encode(String(value));
|
|
4034
|
+
return new NotebookCellOutputItem(bytes, mime);
|
|
4035
|
+
}
|
|
4036
|
+
|
|
4037
|
+
static json(value: any, mime = 'text/x-json'): NotebookCellOutputItem {
|
|
4038
|
+
const rawStr = JSON.stringify(value, undefined, '\t');
|
|
4039
|
+
return NotebookCellOutputItem.text(rawStr, mime);
|
|
4040
|
+
}
|
|
4041
|
+
|
|
4042
|
+
constructor(
|
|
4043
|
+
public data: Uint8Array,
|
|
4044
|
+
public mime: string,
|
|
4045
|
+
) {
|
|
4046
|
+
const mimeNormalized = normalizeMimeType(mime, true);
|
|
4047
|
+
if (!mimeNormalized) {
|
|
4048
|
+
throw new Error(
|
|
4049
|
+
`INVALID mime type: ${mime}. Must be in the format "type/subtype[;optionalparameter]"`,
|
|
4050
|
+
);
|
|
4051
|
+
}
|
|
4052
|
+
this.mime = mimeNormalized;
|
|
4053
|
+
}
|
|
4054
|
+
}
|
|
4055
|
+
|
|
4056
|
+
export class NotebookCellOutput {
|
|
4057
|
+
static isNotebookCellOutput(candidate: any): candidate is vscode.NotebookCellOutput {
|
|
4058
|
+
if (candidate instanceof NotebookCellOutput) {
|
|
4059
|
+
return true;
|
|
4060
|
+
}
|
|
4061
|
+
if (!candidate || typeof candidate !== 'object') {
|
|
4062
|
+
return false;
|
|
4063
|
+
}
|
|
4064
|
+
return (
|
|
4065
|
+
typeof (<NotebookCellOutput>candidate).id === 'string' &&
|
|
4066
|
+
Array.isArray((<NotebookCellOutput>candidate).items)
|
|
4067
|
+
);
|
|
4068
|
+
}
|
|
4069
|
+
|
|
4070
|
+
static ensureUniqueMimeTypes(
|
|
4071
|
+
items: NotebookCellOutputItem[],
|
|
4072
|
+
warn = false,
|
|
4073
|
+
): NotebookCellOutputItem[] {
|
|
4074
|
+
const seen = new Set<string>();
|
|
4075
|
+
const removeIdx = new Set<number>();
|
|
4076
|
+
for (let i = 0; i < items.length; i++) {
|
|
4077
|
+
const item = items[i];
|
|
4078
|
+
const normalMime = normalizeMimeType(item.mime);
|
|
4079
|
+
// We can have multiple text stream mime types in the same output.
|
|
4080
|
+
if (!seen.has(normalMime) || isTextStreamMime(normalMime)) {
|
|
4081
|
+
seen.add(normalMime);
|
|
4082
|
+
continue;
|
|
4083
|
+
}
|
|
4084
|
+
// duplicated mime types... first has won
|
|
4085
|
+
removeIdx.add(i);
|
|
4086
|
+
if (warn) {
|
|
4087
|
+
console.warn(`DUPLICATED mime type '${item.mime}' will be dropped`);
|
|
4088
|
+
}
|
|
4089
|
+
}
|
|
4090
|
+
if (removeIdx.size === 0) {
|
|
4091
|
+
return items;
|
|
4092
|
+
}
|
|
4093
|
+
return items.filter((_item, index) => !removeIdx.has(index));
|
|
4094
|
+
}
|
|
4095
|
+
|
|
4096
|
+
id: string;
|
|
4097
|
+
items: NotebookCellOutputItem[];
|
|
4098
|
+
metadata?: Record<string, any>;
|
|
4099
|
+
|
|
4100
|
+
constructor(
|
|
4101
|
+
items: NotebookCellOutputItem[],
|
|
4102
|
+
idOrMetadata?: string | Record<string, any>,
|
|
4103
|
+
metadata?: Record<string, any>,
|
|
4104
|
+
) {
|
|
4105
|
+
this.items = NotebookCellOutput.ensureUniqueMimeTypes(items, true);
|
|
4106
|
+
if (typeof idOrMetadata === 'string') {
|
|
4107
|
+
this.id = idOrMetadata;
|
|
4108
|
+
this.metadata = metadata;
|
|
4109
|
+
} else {
|
|
4110
|
+
this.id = generateUuid();
|
|
4111
|
+
this.metadata = idOrMetadata ?? metadata;
|
|
4112
|
+
}
|
|
4113
|
+
}
|
|
4114
|
+
}
|
|
4115
|
+
|
|
4116
|
+
export enum NotebookCellKind {
|
|
4117
|
+
Markup = 1,
|
|
4118
|
+
Code = 2,
|
|
4119
|
+
}
|
|
4120
|
+
|
|
4121
|
+
export enum NotebookCellExecutionState {
|
|
4122
|
+
Idle = 1,
|
|
4123
|
+
Pending = 2,
|
|
4124
|
+
Executing = 3,
|
|
4125
|
+
}
|
|
4126
|
+
|
|
4127
|
+
export enum NotebookCellStatusBarAlignment {
|
|
4128
|
+
Left = 1,
|
|
4129
|
+
Right = 2,
|
|
4130
|
+
}
|
|
4131
|
+
|
|
4132
|
+
export enum NotebookEditorRevealType {
|
|
4133
|
+
Default = 0,
|
|
4134
|
+
InCenter = 1,
|
|
4135
|
+
InCenterIfOutsideViewport = 2,
|
|
4136
|
+
AtTop = 3,
|
|
4137
|
+
}
|
|
4138
|
+
|
|
4139
|
+
export class NotebookCellStatusBarItem {
|
|
4140
|
+
constructor(
|
|
4141
|
+
public text: string,
|
|
4142
|
+
public alignment: NotebookCellStatusBarAlignment,
|
|
4143
|
+
) {}
|
|
4144
|
+
}
|
|
4145
|
+
|
|
4146
|
+
export enum NotebookControllerAffinity {
|
|
4147
|
+
Default = 1,
|
|
4148
|
+
Preferred = 2,
|
|
4149
|
+
}
|
|
4150
|
+
|
|
4151
|
+
export enum NotebookControllerAffinity2 {
|
|
4152
|
+
Default = 1,
|
|
4153
|
+
Preferred = 2,
|
|
4154
|
+
Hidden = -1,
|
|
4155
|
+
}
|
|
4156
|
+
|
|
4157
|
+
export class NotebookRendererScript {
|
|
4158
|
+
public provides: readonly string[];
|
|
4159
|
+
|
|
4160
|
+
constructor(
|
|
4161
|
+
public uri: vscode.Uri,
|
|
4162
|
+
provides: string | readonly string[] = [],
|
|
4163
|
+
) {
|
|
4164
|
+
this.provides = asArray(provides);
|
|
4165
|
+
}
|
|
4166
|
+
}
|
|
4167
|
+
|
|
4168
|
+
export class NotebookKernelSourceAction {
|
|
4169
|
+
description?: string;
|
|
4170
|
+
detail?: string;
|
|
4171
|
+
command?: vscode.Command;
|
|
4172
|
+
constructor(public label: string) {}
|
|
4173
|
+
}
|
|
4174
|
+
|
|
4175
|
+
export enum NotebookVariablesRequestKind {
|
|
4176
|
+
Named = 1,
|
|
4177
|
+
Indexed = 2,
|
|
4178
|
+
}
|
|
4179
|
+
|
|
4180
|
+
//#endregion
|
|
4181
|
+
|
|
4182
|
+
//#region Timeline
|
|
4183
|
+
|
|
4184
|
+
// export class TimelineItem implements vscode.TimelineItem {
|
|
4185
|
+
// constructor(
|
|
4186
|
+
// public label: string,
|
|
4187
|
+
// public timestamp: number,
|
|
4188
|
+
// ) {}
|
|
4189
|
+
// }
|
|
4190
|
+
|
|
4191
|
+
//#endregion Timeline
|
|
4192
|
+
|
|
4193
|
+
//#region ExtensionContext
|
|
4194
|
+
|
|
4195
|
+
export enum ExtensionMode {
|
|
4196
|
+
/**
|
|
4197
|
+
* The extension is installed normally (for example, from the marketplace
|
|
4198
|
+
* or VSIX) in VS Code.
|
|
4199
|
+
*/
|
|
4200
|
+
Production = 1,
|
|
4201
|
+
|
|
4202
|
+
/**
|
|
4203
|
+
* The extension is running from an `--extensionDevelopmentPath` provided
|
|
4204
|
+
* when launching VS Code.
|
|
4205
|
+
*/
|
|
4206
|
+
Development = 2,
|
|
4207
|
+
|
|
4208
|
+
/**
|
|
4209
|
+
* The extension is running from an `--extensionDevelopmentPath` and
|
|
4210
|
+
* the extension host is running unit tests.
|
|
4211
|
+
*/
|
|
4212
|
+
Test = 3,
|
|
4213
|
+
}
|
|
4214
|
+
|
|
4215
|
+
export enum ExtensionRuntime {
|
|
4216
|
+
/**
|
|
4217
|
+
* The extension is running in a NodeJS extension host. Runtime access to NodeJS APIs is available.
|
|
4218
|
+
*/
|
|
4219
|
+
Node = 1,
|
|
4220
|
+
/**
|
|
4221
|
+
* The extension is running in a Webworker extension host. Runtime access is limited to Webworker APIs.
|
|
4222
|
+
*/
|
|
4223
|
+
Webworker = 2,
|
|
4224
|
+
}
|
|
4225
|
+
|
|
4226
|
+
//#endregion ExtensionContext
|
|
4227
|
+
|
|
4228
|
+
export enum StandardTokenType {
|
|
4229
|
+
Other = 0,
|
|
4230
|
+
Comment = 1,
|
|
4231
|
+
String = 2,
|
|
4232
|
+
RegEx = 3,
|
|
4233
|
+
}
|
|
4234
|
+
|
|
4235
|
+
export class LinkedEditingRanges {
|
|
4236
|
+
constructor(ranges: Range[], wordPattern?: RegExp | undefined) {
|
|
4237
|
+
this.ranges = ranges;
|
|
4238
|
+
this.wordPattern = wordPattern;
|
|
4239
|
+
}
|
|
4240
|
+
|
|
4241
|
+
/**
|
|
4242
|
+
* A list of ranges that can be edited together. The ranges must have
|
|
4243
|
+
* identical length and text content. The ranges cannot overlap.
|
|
4244
|
+
*/
|
|
4245
|
+
readonly ranges: Range[];
|
|
4246
|
+
|
|
4247
|
+
/**
|
|
4248
|
+
* An optional word pattern that describes valid contents for the given ranges.
|
|
4249
|
+
* If no pattern is provided, the language configuration's word pattern will be used.
|
|
4250
|
+
*/
|
|
4251
|
+
readonly wordPattern: RegExp | undefined;
|
|
4252
|
+
}
|
|
4253
|
+
|
|
4254
|
+
//#region ports
|
|
4255
|
+
export class PortAttributes {
|
|
4256
|
+
private _autoForwardAction: PortAutoForwardAction;
|
|
4257
|
+
|
|
4258
|
+
constructor(autoForwardAction: PortAutoForwardAction) {
|
|
4259
|
+
this._autoForwardAction = autoForwardAction;
|
|
4260
|
+
}
|
|
4261
|
+
|
|
4262
|
+
get autoForwardAction(): PortAutoForwardAction {
|
|
4263
|
+
return this._autoForwardAction;
|
|
4264
|
+
}
|
|
4265
|
+
}
|
|
4266
|
+
//#endregion ports
|
|
4267
|
+
|
|
4268
|
+
//#region Testing
|
|
4269
|
+
export enum TestResultState {
|
|
4270
|
+
Queued = 1,
|
|
4271
|
+
Running = 2,
|
|
4272
|
+
Passed = 3,
|
|
4273
|
+
Failed = 4,
|
|
4274
|
+
Skipped = 5,
|
|
4275
|
+
Errored = 6,
|
|
4276
|
+
}
|
|
4277
|
+
|
|
4278
|
+
export enum TestRunProfileKind {
|
|
4279
|
+
Run = 1,
|
|
4280
|
+
Debug = 2,
|
|
4281
|
+
Coverage = 3,
|
|
4282
|
+
}
|
|
4283
|
+
|
|
4284
|
+
export class TestRunRequest implements vscode.TestRunRequest {
|
|
4285
|
+
constructor(
|
|
4286
|
+
public readonly include: vscode.TestItem[] | undefined = undefined,
|
|
4287
|
+
public readonly exclude: vscode.TestItem[] | undefined = undefined,
|
|
4288
|
+
public readonly profile: vscode.TestRunProfile | undefined = undefined,
|
|
4289
|
+
public readonly continuous = false,
|
|
4290
|
+
) {}
|
|
4291
|
+
}
|
|
4292
|
+
|
|
4293
|
+
export class TestMessage implements vscode.TestMessage {
|
|
4294
|
+
public expectedOutput?: string;
|
|
4295
|
+
public actualOutput?: string;
|
|
4296
|
+
public location?: vscode.Location;
|
|
4297
|
+
/** proposed: */
|
|
4298
|
+
public contextValue?: string;
|
|
4299
|
+
|
|
4300
|
+
public static diff(
|
|
4301
|
+
message: string | vscode.MarkdownString,
|
|
4302
|
+
expected: string,
|
|
4303
|
+
actual: string,
|
|
4304
|
+
) {
|
|
4305
|
+
const msg = new TestMessage(message);
|
|
4306
|
+
msg.expectedOutput = expected;
|
|
4307
|
+
msg.actualOutput = actual;
|
|
4308
|
+
return msg;
|
|
4309
|
+
}
|
|
4310
|
+
|
|
4311
|
+
constructor(public message: string | vscode.MarkdownString) {}
|
|
4312
|
+
}
|
|
4313
|
+
|
|
4314
|
+
export class TestTag implements vscode.TestTag {
|
|
4315
|
+
constructor(public readonly id: string) {}
|
|
4316
|
+
}
|
|
4317
|
+
|
|
4318
|
+
//#endregion
|
|
4319
|
+
|
|
4320
|
+
export enum ExternalUriOpenerPriority {
|
|
4321
|
+
None = 0,
|
|
4322
|
+
Option = 1,
|
|
4323
|
+
Default = 2,
|
|
4324
|
+
Preferred = 3,
|
|
4325
|
+
}
|
|
4326
|
+
|
|
4327
|
+
export enum WorkspaceTrustState {
|
|
4328
|
+
Untrusted = 0,
|
|
4329
|
+
Trusted = 1,
|
|
4330
|
+
Unspecified = 2,
|
|
4331
|
+
}
|
|
4332
|
+
|
|
4333
|
+
export enum PortAutoForwardAction {
|
|
4334
|
+
Notify = 1,
|
|
4335
|
+
OpenBrowser = 2,
|
|
4336
|
+
OpenPreview = 3,
|
|
4337
|
+
Silent = 4,
|
|
4338
|
+
Ignore = 5,
|
|
4339
|
+
OpenBrowserOnce = 6,
|
|
4340
|
+
}
|
|
4341
|
+
|
|
4342
|
+
export class TypeHierarchyItem {
|
|
4343
|
+
_sessionId?: string;
|
|
4344
|
+
_itemId?: string;
|
|
4345
|
+
|
|
4346
|
+
kind: SymbolKind;
|
|
4347
|
+
tags?: SymbolTag[];
|
|
4348
|
+
name: string;
|
|
4349
|
+
detail?: string;
|
|
4350
|
+
uri: URI;
|
|
4351
|
+
range: Range;
|
|
4352
|
+
selectionRange: Range;
|
|
4353
|
+
|
|
4354
|
+
constructor(
|
|
4355
|
+
kind: SymbolKind,
|
|
4356
|
+
name: string,
|
|
4357
|
+
detail: string,
|
|
4358
|
+
uri: URI,
|
|
4359
|
+
range: Range,
|
|
4360
|
+
selectionRange: Range,
|
|
4361
|
+
) {
|
|
4362
|
+
this.kind = kind;
|
|
4363
|
+
this.name = name;
|
|
4364
|
+
this.detail = detail;
|
|
4365
|
+
this.uri = uri;
|
|
4366
|
+
this.range = range;
|
|
4367
|
+
this.selectionRange = selectionRange;
|
|
4368
|
+
}
|
|
4369
|
+
}
|
|
4370
|
+
|
|
4371
|
+
//#region Tab Inputs
|
|
4372
|
+
|
|
4373
|
+
export class TextTabInput {
|
|
4374
|
+
constructor(readonly uri: URI) {}
|
|
4375
|
+
}
|
|
4376
|
+
|
|
4377
|
+
export class TextDiffTabInput {
|
|
4378
|
+
constructor(
|
|
4379
|
+
readonly original: URI,
|
|
4380
|
+
readonly modified: URI,
|
|
4381
|
+
) {}
|
|
4382
|
+
}
|
|
4383
|
+
|
|
4384
|
+
export class TextMergeTabInput {
|
|
4385
|
+
constructor(
|
|
4386
|
+
readonly base: URI,
|
|
4387
|
+
readonly input1: URI,
|
|
4388
|
+
readonly input2: URI,
|
|
4389
|
+
readonly result: URI,
|
|
4390
|
+
) {}
|
|
4391
|
+
}
|
|
4392
|
+
|
|
4393
|
+
export class CustomEditorTabInput {
|
|
4394
|
+
constructor(
|
|
4395
|
+
readonly uri: URI,
|
|
4396
|
+
readonly viewType: string,
|
|
4397
|
+
) {}
|
|
4398
|
+
}
|
|
4399
|
+
|
|
4400
|
+
export class WebviewEditorTabInput {
|
|
4401
|
+
constructor(readonly viewType: string) {}
|
|
4402
|
+
}
|
|
4403
|
+
|
|
4404
|
+
export class NotebookEditorTabInput {
|
|
4405
|
+
constructor(
|
|
4406
|
+
readonly uri: URI,
|
|
4407
|
+
readonly notebookType: string,
|
|
4408
|
+
) {}
|
|
4409
|
+
}
|
|
4410
|
+
|
|
4411
|
+
export class NotebookDiffEditorTabInput {
|
|
4412
|
+
constructor(
|
|
4413
|
+
readonly original: URI,
|
|
4414
|
+
readonly modified: URI,
|
|
4415
|
+
readonly notebookType: string,
|
|
4416
|
+
) {}
|
|
4417
|
+
}
|
|
4418
|
+
|
|
4419
|
+
export class TerminalEditorTabInput {
|
|
4420
|
+
constructor() {}
|
|
4421
|
+
}
|
|
4422
|
+
export class InteractiveWindowInput {
|
|
4423
|
+
constructor(
|
|
4424
|
+
readonly uri: URI,
|
|
4425
|
+
readonly inputBoxUri: URI,
|
|
4426
|
+
) {}
|
|
4427
|
+
}
|
|
4428
|
+
|
|
4429
|
+
export class ChatEditorTabInput {
|
|
4430
|
+
constructor(readonly providerId: string) {}
|
|
4431
|
+
}
|
|
4432
|
+
//#endregion
|
|
4433
|
+
|
|
4434
|
+
//#region Chat
|
|
4435
|
+
|
|
4436
|
+
export enum InteractiveSessionVoteDirection {
|
|
4437
|
+
Down = 0,
|
|
4438
|
+
Up = 1,
|
|
4439
|
+
}
|
|
4440
|
+
|
|
4441
|
+
export enum ChatAgentCopyKind {
|
|
4442
|
+
Action = 1,
|
|
4443
|
+
Toolbar = 2,
|
|
4444
|
+
}
|
|
4445
|
+
|
|
4446
|
+
export enum ChatVariableLevel {
|
|
4447
|
+
Short = 1,
|
|
4448
|
+
Medium = 2,
|
|
4449
|
+
Full = 3,
|
|
4450
|
+
}
|
|
4451
|
+
|
|
4452
|
+
//#endregion
|
|
4453
|
+
|
|
4454
|
+
//#region Interactive Editor
|
|
4455
|
+
|
|
4456
|
+
export enum InteractiveEditorResponseFeedbackKind {
|
|
4457
|
+
Unhelpful = 0,
|
|
4458
|
+
Helpful = 1,
|
|
4459
|
+
Undone = 2,
|
|
4460
|
+
Accepted = 3,
|
|
4461
|
+
Bug = 4,
|
|
4462
|
+
}
|
|
4463
|
+
|
|
4464
|
+
export enum ChatMessageRole {
|
|
4465
|
+
System = 0,
|
|
4466
|
+
User = 1,
|
|
4467
|
+
Assistant = 2,
|
|
4468
|
+
Function = 3,
|
|
4469
|
+
}
|
|
4470
|
+
|
|
4471
|
+
export enum ChatAgentResultFeedbackKind {
|
|
4472
|
+
Unhelpful = 0,
|
|
4473
|
+
Helpful = 1,
|
|
4474
|
+
}
|
|
4475
|
+
|
|
4476
|
+
//#endregion
|
|
4477
|
+
|
|
4478
|
+
//#region ai
|
|
4479
|
+
|
|
4480
|
+
export enum RelatedInformationType {
|
|
4481
|
+
SymbolInformation = 1,
|
|
4482
|
+
CommandInformation = 2,
|
|
4483
|
+
SearchInformation = 3,
|
|
4484
|
+
SettingInformation = 4,
|
|
4485
|
+
}
|
|
4486
|
+
|
|
4487
|
+
//#endregion
|
|
4488
|
+
|
|
4489
|
+
//#region Speech
|
|
4490
|
+
|
|
4491
|
+
export enum SpeechToTextStatus {
|
|
4492
|
+
Started = 1,
|
|
4493
|
+
Recognizing = 2,
|
|
4494
|
+
Recognized = 3,
|
|
4495
|
+
Stopped = 4,
|
|
4496
|
+
}
|
|
4497
|
+
|
|
4498
|
+
//#endregion
|