@opensumi/sumi 2.20.10 → 2.21.0

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.
@@ -942,6 +942,11 @@ declare module 'sumi-worker' {
942
942
  * array containing all selected tree items.
943
943
  */
944
944
  canSelectMany?: boolean;
945
+
946
+ /**
947
+ * An optional interface to implement drag and drop in the tree view.
948
+ */
949
+ dragAndDropController?: TreeDragAndDropController<T>;
945
950
  }
946
951
 
947
952
  /**
@@ -974,6 +979,167 @@ declare module 'sumi-worker' {
974
979
  readonly visible: boolean;
975
980
  }
976
981
 
982
+ /**
983
+ * A file associated with a {@linkcode DataTransferItem}.
984
+ */
985
+ export interface DataTransferFile {
986
+ /**
987
+ * The name of the file.
988
+ */
989
+ readonly name: string;
990
+
991
+ /**
992
+ * The full file path of the file.
993
+ *
994
+ * May be `undefined` on web.
995
+ */
996
+ readonly uri?: Uri;
997
+
998
+ /**
999
+ * The full file contents of the file.
1000
+ */
1001
+ data(): Thenable<Uint8Array>;
1002
+ }
1003
+
1004
+ /**
1005
+ * Encapsulates data transferred during drag and drop operations.
1006
+ */
1007
+ export class DataTransferItem {
1008
+ /**
1009
+ * Get a string representation of this item.
1010
+ *
1011
+ * If {@linkcode DataTransferItem.value} is an object, this returns the result of json stringifying {@linkcode DataTransferItem.value} value.
1012
+ */
1013
+ asString(): Thenable<string>;
1014
+
1015
+ /**
1016
+ * Try getting the {@link DataTransferFile file} associated with this data transfer item.
1017
+ *
1018
+ * Note that the file object is only valid for the scope of the drag and drop operation.
1019
+ *
1020
+ * @returns The file for the data transfer or `undefined` if the item is either not a file or the
1021
+ * file data cannot be accessed.
1022
+ */
1023
+ asFile(): DataTransferFile | undefined;
1024
+
1025
+ /**
1026
+ * Custom data stored on this item.
1027
+ *
1028
+ * You can use `value` to share data across operations. The original object can be retrieved so long as the extension that
1029
+ * created the `DataTransferItem` runs in the same extension host.
1030
+ */
1031
+ readonly value: any;
1032
+
1033
+ /**
1034
+ * @param value Custom data stored on this item. Can be retrieved using {@linkcode DataTransferItem.value}.
1035
+ */
1036
+ constructor(value: any);
1037
+ }
1038
+
1039
+ /**
1040
+ * A map containing a mapping of the mime type of the corresponding transferred data.
1041
+ *
1042
+ * Drag and drop controllers that implement {@link TreeDragAndDropController.handleDrag `handleDrag`} can add additional mime types to the
1043
+ * data transfer. These additional mime types will only be included in the `handleDrop` when the the drag was initiated from
1044
+ * an element in the same drag and drop controller.
1045
+ */
1046
+ export class DataTransfer implements Iterable<[mimeType: string, item: DataTransferItem]> {
1047
+ /**
1048
+ * Retrieves the data transfer item for a given mime type.
1049
+ *
1050
+ * @param mimeType The mime type to get the data transfer item for, such as `text/plain` or `image/png`.
1051
+ *
1052
+ * Special mime types:
1053
+ * - `text/uri-list` — A string with `toString()`ed Uris separated by `\r\n`. To specify a cursor position in the file,
1054
+ * set the Uri's fragment to `L3,5`, where 3 is the line number and 5 is the column number.
1055
+ */
1056
+ get(mimeType: string): DataTransferItem | undefined;
1057
+
1058
+ /**
1059
+ * Sets a mime type to data transfer item mapping.
1060
+ * @param mimeType The mime type to set the data for.
1061
+ * @param value The data transfer item for the given mime type.
1062
+ */
1063
+ set(mimeType: string, value: DataTransferItem): void;
1064
+
1065
+ /**
1066
+ * Allows iteration through the data transfer items.
1067
+ *
1068
+ * @param callbackfn Callback for iteration through the data transfer items.
1069
+ * @param thisArg The `this` context used when invoking the handler function.
1070
+ */
1071
+ forEach(
1072
+ callbackfn: (item: DataTransferItem, mimeType: string, dataTransfer: DataTransfer) => void,
1073
+ thisArg?: any,
1074
+ ): void;
1075
+
1076
+ /**
1077
+ * Get a new iterator with the `[mime, item]` pairs for each element in this data transfer.
1078
+ */
1079
+ [Symbol.iterator](): IterableIterator<[mimeType: string, item: DataTransferItem]>;
1080
+ }
1081
+
1082
+ /**
1083
+ * Provides support for drag and drop in `TreeView`.
1084
+ */
1085
+ export interface TreeDragAndDropController<T> {
1086
+ /**
1087
+ * The mime types that the {@link TreeDragAndDropController.handleDrop `handleDrop`} method of this `DragAndDropController` supports.
1088
+ * This could be well-defined, existing, mime types, and also mime types defined by the extension.
1089
+ *
1090
+ * To support drops from trees, you will need to add the mime type of that tree.
1091
+ * This includes drops from within the same tree.
1092
+ * The mime type of a tree is recommended to be of the format `application/vnd.code.tree.<treeidlowercase>`.
1093
+ *
1094
+ * Use the special `files` mime type to support all types of dropped files {@link DataTransferFile files}, regardless of the file's actual mime type.
1095
+ *
1096
+ * To learn the mime type of a dragged item:
1097
+ * 1. Set up your `DragAndDropController`
1098
+ * 2. Use the Developer: Set Log Level... command to set the level to "Debug"
1099
+ * 3. Open the developer tools and drag the item with unknown mime type over your tree. The mime types will be logged to the developer console
1100
+ *
1101
+ * Note that mime types that cannot be sent to the extension will be omitted.
1102
+ */
1103
+ readonly dropMimeTypes: readonly string[];
1104
+
1105
+ /**
1106
+ * The mime types that the {@link TreeDragAndDropController.handleDrag `handleDrag`} method of this `TreeDragAndDropController` may add to the tree data transfer.
1107
+ * This could be well-defined, existing, mime types, and also mime types defined by the extension.
1108
+ *
1109
+ * The recommended mime type of the tree (`application/vnd.code.tree.<treeidlowercase>`) will be automatically added.
1110
+ */
1111
+ readonly dragMimeTypes: readonly string[];
1112
+
1113
+ /**
1114
+ * When the user starts dragging items from this `DragAndDropController`, `handleDrag` will be called.
1115
+ * Extensions can use `handleDrag` to add their {@link DataTransferItem `DataTransferItem`} items to the drag and drop.
1116
+ *
1117
+ * When the items are dropped on **another tree item** in **the same tree**, your `DataTransferItem` objects
1118
+ * will be preserved. Use the recommended mime type for the tree (`application/vnd.code.tree.<treeidlowercase>`) to add
1119
+ * tree objects in a data transfer. See the documentation for `DataTransferItem` for how best to take advantage of this.
1120
+ *
1121
+ * To add a data transfer item that can be dragged into the editor, use the application specific mime type "text/uri-list".
1122
+ * The data for "text/uri-list" should be a string with `toString()`ed Uris separated by newlines. To specify a cursor position in the file,
1123
+ * set the Uri's fragment to `L3,5`, where 3 is the line number and 5 is the column number.
1124
+ *
1125
+ * @param source The source items for the drag and drop operation.
1126
+ * @param dataTransfer The data transfer associated with this drag.
1127
+ * @param token A cancellation token indicating that drag has been cancelled.
1128
+ */
1129
+ handleDrag?(source: readonly T[], dataTransfer: DataTransfer, token: CancellationToken): Thenable<void> | void;
1130
+
1131
+ /**
1132
+ * Called when a drag and drop action results in a drop on the tree that this `DragAndDropController` belongs to.
1133
+ *
1134
+ * Extensions should fire {@link TreeDataProvider.onDidChangeTreeData onDidChangeTreeData} for any elements that need to be refreshed.
1135
+ *
1136
+ * @param dataTransfer The data transfer items of the source of the drag.
1137
+ * @param target The target tree element that the drop is occurring on. When undefined, the target is the root.
1138
+ * @param token A cancellation token indicating that the drop has been cancelled.
1139
+ */
1140
+ handleDrop?(target: T | undefined, dataTransfer: DataTransfer, token: CancellationToken): Thenable<void> | void;
1141
+ }
1142
+
977
1143
  /**
978
1144
  * Represents a Tree view
979
1145
  */
@@ -216,6 +216,19 @@ declare module 'sumi-worker' {
216
216
  */
217
217
  export function registerColorProvider(selector: DocumentSelector, provider: DocumentColorProvider): Disposable;
218
218
 
219
+ /**
220
+ * Register a inlay hints provider.
221
+ *
222
+ * Multiple providers can be registered for a language. In that case providers are asked in
223
+ * parallel and the results are merged. A failing provider (rejected promise or exception) will
224
+ * not cause a failure of the whole operation.
225
+ *
226
+ * @param selector A selector that defines the documents this provider is applicable to.
227
+ * @param provider An inlay hints provider.
228
+ * @return A {@link Disposable} that unregisters this provider when being disposed.
229
+ */
230
+ export function registerInlayHintsProvider(selector: DocumentSelector, provider: InlayHintsProvider): Disposable;
231
+
219
232
  /**
220
233
  * Register a folding range provider.
221
234
  *
@@ -2172,6 +2185,159 @@ declare module 'sumi-worker' {
2172
2185
  readonly uris: ReadonlyArray<Uri>;
2173
2186
  }
2174
2187
 
2188
+ export enum InlayHintKind {
2189
+ Type = 1,
2190
+ Parameter = 2,
2191
+ }
2192
+
2193
+ /**
2194
+ * An inlay hint label part allows for interactive and composite labels of inlay hints.
2195
+ */
2196
+ export class InlayHintLabelPart {
2197
+ /**
2198
+ * The value of this label part.
2199
+ */
2200
+ value: string;
2201
+
2202
+ /**
2203
+ * The tooltip text when you hover over this label part.
2204
+ *
2205
+ * *Note* that this property can be set late during
2206
+ * {@link InlayHintsProvider.resolveInlayHint resolving} of inlay hints.
2207
+ */
2208
+ tooltip?: string | MarkdownString | undefined;
2209
+
2210
+ /**
2211
+ * An optional {@link Location source code location} that represents this label
2212
+ * part.
2213
+ *
2214
+ * The editor will use this location for the hover and for code navigation features: This
2215
+ * part will become a clickable link that resolves to the definition of the symbol at the
2216
+ * given location (not necessarily the location itself), it shows the hover that shows at
2217
+ * the given location, and it shows a context menu with further code navigation commands.
2218
+ *
2219
+ * *Note* that this property can be set late during
2220
+ * {@link InlayHintsProvider.resolveInlayHint resolving} of inlay hints.
2221
+ */
2222
+ location?: Location | undefined;
2223
+
2224
+ /**
2225
+ * An optional command for this label part.
2226
+ *
2227
+ * The editor renders parts with commands as clickable links. The command is added to the context menu
2228
+ * when a label part defines {@link InlayHintLabelPart.location location} and {@link InlayHintLabelPart.command command} .
2229
+ *
2230
+ * *Note* that this property can be set late during
2231
+ * {@link InlayHintsProvider.resolveInlayHint resolving} of inlay hints.
2232
+ */
2233
+ command?: Command | undefined;
2234
+
2235
+ /**
2236
+ * Creates a new inlay hint label part.
2237
+ *
2238
+ * @param value The value of the part.
2239
+ */
2240
+ constructor(value: string);
2241
+ }
2242
+
2243
+ /**
2244
+ * Inlay hint information.
2245
+ */
2246
+ export class InlayHint {
2247
+ /**
2248
+ * The position of this hint.
2249
+ */
2250
+ position: Position;
2251
+
2252
+ /**
2253
+ * The label of this hint. A human readable string or an array of {@link InlayHintLabelPart label parts}.
2254
+ *
2255
+ * *Note* that neither the string nor the label part can be empty.
2256
+ */
2257
+ label: string | InlayHintLabelPart[];
2258
+
2259
+ /**
2260
+ * The tooltip text when you hover over this item.
2261
+ *
2262
+ * *Note* that this property can be set late during
2263
+ * {@link InlayHintsProvider.resolveInlayHint resolving} of inlay hints.
2264
+ */
2265
+ tooltip?: string | MarkdownString | undefined;
2266
+
2267
+ /**
2268
+ * The kind of this hint. The inlay hint kind defines the appearance of this inlay hint.
2269
+ */
2270
+ kind?: InlayHintKind;
2271
+
2272
+ /**
2273
+ * Optional {@link TextEdit text edits} that are performed when accepting this inlay hint. The default
2274
+ * gesture for accepting an inlay hint is the double click.
2275
+ *
2276
+ * *Note* that edits are expected to change the document so that the inlay hint (or its nearest variant) is
2277
+ * now part of the document and the inlay hint itself is now obsolete.
2278
+ *
2279
+ * *Note* that this property can be set late during
2280
+ * {@link InlayHintsProvider.resolveInlayHint resolving} of inlay hints.
2281
+ */
2282
+ textEdits?: TextEdit[];
2283
+
2284
+ /**
2285
+ * Render padding before the hint. Padding will use the editor's background color,
2286
+ * not the background color of the hint itself. That means padding can be used to visually
2287
+ * align/separate an inlay hint.
2288
+ */
2289
+ paddingLeft?: boolean;
2290
+
2291
+ /**
2292
+ * Render padding after the hint. Padding will use the editor's background color,
2293
+ * not the background color of the hint itself. That means padding can be used to visually
2294
+ * align/separate an inlay hint.
2295
+ */
2296
+ paddingRight?: boolean;
2297
+
2298
+ /**
2299
+ * Creates a new inlay hint.
2300
+ *
2301
+ * @param position The position of the hint.
2302
+ * @param label The label of the hint.
2303
+ * @param kind The {@link InlayHintKind kind} of the hint.
2304
+ */
2305
+ constructor(position: Position, label: string | InlayHintLabelPart[], kind?: InlayHintKind);
2306
+ }
2307
+
2308
+ /**
2309
+ * The inlay hints provider interface defines the contract between extensions and
2310
+ * the inlay hints feature.
2311
+ */
2312
+ export interface InlayHintsProvider<T extends InlayHint = InlayHint> {
2313
+ /**
2314
+ * An optional event to signal that inlay hints have changed.
2315
+ * @see {@link EventEmitter}
2316
+ */
2317
+ onDidChangeInlayHints?: Event<void>;
2318
+
2319
+ /**
2320
+ *
2321
+ * @param model The document in which the command was invoked.
2322
+ * @param range The range for which inlay hints should be computed.
2323
+ * @param token A cancellation token.
2324
+ * @return A list of inlay hints or a thenable that resolves to such.
2325
+ */
2326
+ provideInlayHints(model: TextDocument, range: Range, token: CancellationToken): ProviderResult<T[]>;
2327
+
2328
+ /**
2329
+ * Given an inlay hint fill in {@link InlayHint.tooltip tooltip}, {@link InlayHint.textEdits text edits},
2330
+ * or complete label {@link InlayHintLabelPart parts}.
2331
+ *
2332
+ * *Note* that the editor will resolve an inlay hint at most once.
2333
+ *
2334
+ * @param hint An inlay hint.
2335
+ * @param token A cancellation token.
2336
+ * @return The resolved inlay hint or a thenable that resolves to such. It is OK to return the given `item`. When no result is returned, the given `item` will be used.
2337
+ */
2338
+ resolveInlayHint?(hint: T, token: CancellationToken): ProviderResult<T>;
2339
+ }
2340
+
2175
2341
  /**
2176
2342
  * A diagnostics collection is a container that manages a set of
2177
2343
  * [diagnostics](#Diagnostic). Diagnostics are always scopes to a
@@ -1,86 +1,86 @@
1
1
  declare module 'vscode' {
2
- /**
3
- * Represents a reference to a command. Provides a title which
4
- * will be used to represent a command in the UI and, optionally,
5
- * an array of arguments which will be passed to the command handler
6
- * function when invoked.
7
- */
8
- export interface Command {
9
- /**
10
- * Title of the command, like `save`.
11
- */
12
- title: string;
2
+ /**
3
+ * Represents a reference to a command. Provides a title which
4
+ * will be used to represent a command in the UI and, optionally,
5
+ * an array of arguments which will be passed to the command handler
6
+ * function when invoked.
7
+ */
8
+ export interface Command {
9
+ /**
10
+ * Title of the command, like `save`.
11
+ */
12
+ title: string;
13
13
 
14
- /**
15
- * The identifier of the actual command handler.
16
- * @see [commands.registerCommand](#commands.registerCommand).
17
- */
18
- command: string;
14
+ /**
15
+ * The identifier of the actual command handler.
16
+ * @see [commands.registerCommand](#commands.registerCommand).
17
+ */
18
+ command: string;
19
19
 
20
- /**
21
- * A tooltip for the command, when represented in the UI.
22
- */
23
- tooltip?: string;
20
+ /**
21
+ * A tooltip for the command, when represented in the UI.
22
+ */
23
+ tooltip?: string;
24
24
 
25
- /**
26
- * Arguments that the command handler should be
27
- * invoked with.
28
- */
29
- arguments?: any[];
30
- }
25
+ /**
26
+ * Arguments that the command handler should be
27
+ * invoked with.
28
+ */
29
+ arguments?: any[];
30
+ }
31
31
  export namespace commands {
32
32
  /**
33
- * Registers a command that can be invoked via a keyboard shortcut,
34
- * a menu item, an action, or directly.
35
- *
36
- * Registering a command with an existing command identifier twice
37
- * will cause an error.
38
- *
39
- * @param command A unique identifier for the command.
40
- * @param callback A command handler function.
41
- * @param thisArg The `this` context used when invoking the handler function.
42
- * @return Disposable which unregisters this command on disposal.
43
- */
44
- export function registerCommand(command: string, callback: (...args: any[]) => any, thisArg?: any): Disposable;
33
+ * Registers a command that can be invoked via a keyboard shortcut,
34
+ * a menu item, an action, or directly.
35
+ *
36
+ * Registering a command with an existing command identifier twice
37
+ * will cause an error.
38
+ *
39
+ * @param command A unique identifier for the command.
40
+ * @param callback A command handler function.
41
+ * @param thisArg The `this` context used when invoking the handler function.
42
+ * @return Disposable which unregisters this command on disposal.
43
+ */
44
+ export function registerCommand(command: string, callback: (...args: any[]) => any, thisArg?: any): Disposable;
45
45
 
46
- /**
47
- * Executes the command denoted by the given command identifier.
48
- *
49
- * * *Note 1:* When executing an editor command not all types are allowed to
50
- * be passed as arguments. Allowed are the primitive types `string`, `boolean`,
51
- * `number`, `undefined`, and `null`, as well as [`Position`](#Position), [`Range`](#Range), [`Uri`](#Uri) and [`Location`](#Location).
52
- * * *Note 2:* There are no restrictions when executing commands that have been contributed
53
- * by extensions.
54
- *
55
- * @param command Identifier of the command to execute.
56
- * @param rest Parameters passed to the command function.
57
- * @return A thenable that resolves to the returned value of the given command. `undefined` when
58
- * the command handler function doesn't return anything.
59
- */
60
- export function executeCommand<T>(command: string, ...rest: any[]): Thenable<T | undefined>;
46
+ /**
47
+ * Executes the command denoted by the given command identifier.
48
+ *
49
+ * * *Note 1:* When executing an editor command not all types are allowed to
50
+ * be passed as arguments. Allowed are the primitive types `string`, `boolean`,
51
+ * `number`, `undefined`, and `null`, as well as [`Position`](#Position), [`Range`](#Range), [`Uri`](#Uri) and [`Location`](#Location).
52
+ * * *Note 2:* There are no restrictions when executing commands that have been contributed
53
+ * by extensions.
54
+ *
55
+ * @param command Identifier of the command to execute.
56
+ * @param rest Parameters passed to the command function.
57
+ * @return A thenable that resolves to the returned value of the given command. `undefined` when
58
+ * the command handler function doesn't return anything.
59
+ */
60
+ export function executeCommand<T>(command: string, ...rest: any[]): Thenable<T | undefined>;
61
61
 
62
- /**
63
- * Retrieve the list of all available commands. Commands starting an underscore are
64
- * treated as internal commands.
65
- *
66
- * @param filterInternal Set `true` to not see internal commands (starting with an underscore)
67
- * @return Thenable that resolves to a list of command ids.
68
- */
69
- export function getCommands(filterInternal?: boolean): Thenable<string[]>;
70
- /**
71
- * Registers a text editor command that can be invoked via a keyboard shortcut,
72
- * a menu item, an action, or directly.
73
- *
74
- * Text editor commands are different from ordinary [commands](#commands.registerCommand) as
75
- * they only execute when there is an active editor when the command is called. Also, the
76
- * command handler of an editor command has access to the active editor and to an
77
- * [edit](#TextEditorEdit)-builder.
78
- *
79
- * @param command A unique identifier for the command.
80
- * @param callback A command handler function with access to an [editor](#TextEditor) and an [edit](#TextEditorEdit).
81
- * @param thisArg The `this` context used when invoking the handler function.
82
- * @return Disposable which unregisters this command on disposal.
83
- */
84
- export function registerTextEditorCommand(command: string, callback: (textEditor: TextEditor, edit: TextEditorEdit, ...args: any[]) => void, thisArg?: any): Disposable;
85
- }
62
+ /**
63
+ * Retrieve the list of all available commands. Commands starting an underscore are
64
+ * treated as internal commands.
65
+ *
66
+ * @param filterInternal Set `true` to not see internal commands (starting with an underscore)
67
+ * @return Thenable that resolves to a list of command ids.
68
+ */
69
+ export function getCommands(filterInternal?: boolean): Thenable<string[]>;
70
+ /**
71
+ * Registers a text editor command that can be invoked via a keyboard shortcut,
72
+ * a menu item, an action, or directly.
73
+ *
74
+ * Text editor commands are different from ordinary [commands](#commands.registerCommand) as
75
+ * they only execute when there is an active editor when the command is called. Also, the
76
+ * command handler of an editor command has access to the active editor and to an
77
+ * [edit](#TextEditorEdit)-builder.
78
+ *
79
+ * @param command A unique identifier for the command.
80
+ * @param callback A command handler function with access to an [editor](#TextEditor) and an [edit](#TextEditorEdit).
81
+ * @param thisArg The `this` context used when invoking the handler function.
82
+ * @return Disposable which unregisters this command on disposal.
83
+ */
84
+ export function registerTextEditorCommand(command: string, callback: (textEditor: TextEditor, edit: TextEditorEdit, ...args: any[]) => void, thisArg?: any): Disposable;
85
+ }
86
86
  }
@@ -201,6 +201,12 @@ declare module 'vscode' {
201
201
  * Label will be rendered next to authorName if exists.
202
202
  */
203
203
  label?: string;
204
+
205
+ /**
206
+ * Optional timestamp that will be displayed in comments.
207
+ * The date will be formatted according to the user's locale and settings.
208
+ */
209
+ timestamp?: Date;
204
210
  }
205
211
 
206
212
  /**