@theia/plugin 1.59.0-next.72 → 1.59.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theia/plugin",
3
- "version": "1.59.0-next.72+f41d8efcd",
3
+ "version": "1.59.0",
4
4
  "description": "Theia - Plugin API",
5
5
  "types": "./src/theia.d.ts",
6
6
  "publishConfig": {
@@ -27,10 +27,10 @@
27
27
  "watch": "theiaext watch"
28
28
  },
29
29
  "devDependencies": {
30
- "@theia/ext-scripts": "1.58.0"
30
+ "@theia/ext-scripts": "1.59.0"
31
31
  },
32
32
  "nyc": {
33
33
  "extends": "../../configs/nyc.json"
34
34
  },
35
- "gitHead": "f41d8efcd4abb79167b74bf476eafc7857e97306"
35
+ "gitHead": "21358137e41342742707f660b8e222f940a27652"
36
36
  }
package/src/theia.d.ts CHANGED
@@ -27,7 +27,6 @@ import './theia.proposed.createFileSystemWatcher';
27
27
  import './theia.proposed.customEditorMove';
28
28
  import './theia.proposed.debugVisualization';
29
29
  import './theia.proposed.diffCommand';
30
- import './theia.proposed.documentPaste';
31
30
  import './theia.proposed.editSessionIdentityProvider';
32
31
  import './theia.proposed.extensionsAny';
33
32
  import './theia.proposed.externalUriOpener';
@@ -3436,10 +3435,17 @@ export module '@theia/plugin' {
3436
3435
  /**
3437
3436
  * The exit code reported by the shell.
3438
3437
  *
3439
- * Note that `undefined` means the shell either did not report an exit code (ie. the shell
3440
- * integration script is misbehaving) or the shell reported a command started before the command
3441
- * finished (eg. a sub-shell was opened). Generally this should not happen, depending on the use
3442
- * case, it may be best to treat this as a failure.
3438
+ * When this is `undefined` it can mean several things:
3439
+ *
3440
+ * - The shell either did not report an exit code (ie. the shell integration script is
3441
+ * misbehaving)
3442
+ * - The shell reported a command started before the command finished (eg. a sub-shell was
3443
+ * opened).
3444
+ * - The user canceled the command via ctrl+c.
3445
+ * - The user pressed enter when there was no input.
3446
+ *
3447
+ * Generally this should not happen. Depending on the use case, it may be best to treat this
3448
+ * as a failure.
3443
3449
  *
3444
3450
  * @example
3445
3451
  * const execution = shellIntegration.executeCommand({
@@ -3449,15 +3455,14 @@ export module '@theia/plugin' {
3449
3455
  * window.onDidEndTerminalShellExecution(event => {
3450
3456
  * if (event.execution === execution) {
3451
3457
  * if (event.exitCode === undefined) {
3452
- * console.log('Command finished but exit code is unknown');
3458
+ * console.log('Command finished but exit code is unknown');
3453
3459
  * } else if (event.exitCode === 0) {
3454
- * console.log('Command succeeded');
3460
+ * console.log('Command succeeded');
3455
3461
  * } else {
3456
- * console.log('Command failed');
3462
+ * console.log('Command failed');
3457
3463
  * }
3458
3464
  * }
3459
3465
  * });
3460
- * @stubbed
3461
3466
  */
3462
3467
  readonly exitCode: number | undefined;
3463
3468
  }
@@ -11375,12 +11380,44 @@ export module '@theia/plugin' {
11375
11380
  /**
11376
11381
  * Registers a new {@link DocumentDropEditProvider}.
11377
11382
  *
11383
+ * Multiple drop providers can be registered for a language. When dropping content into an editor, all
11384
+ * registered providers for the editor's language will be invoked based on the mimetypes they handle
11385
+ * as specified by their {@linkcode DocumentDropEditProviderMetadata}.
11386
+ *
11387
+ * Each provider can return one or more {@linkcode DocumentDropEdit DocumentDropEdits}. The edits are sorted
11388
+ * using the {@linkcode DocumentDropEdit.yieldTo} property. By default the first edit will be applied. If there
11389
+ * are any additional edits, these will be shown to the user as selectable drop options in the drop widget.
11390
+ *
11378
11391
  * @param selector A selector that defines the documents this provider applies to.
11379
11392
  * @param provider A drop provider.
11393
+ * @param metadata Additional metadata about the provider.
11380
11394
  *
11381
- * @return A {@link Disposable} that unregisters this provider when disposed of.
11395
+ * @returns A {@linkcode Disposable} that unregisters this provider when disposed of.
11396
+ */
11397
+ export function registerDocumentDropEditProvider(selector: DocumentSelector, provider: DocumentDropEditProvider, metadata?: DocumentDropEditProviderMetadata): Disposable;
11398
+
11399
+ /**
11400
+ * Registers a new {@linkcode DocumentPasteEditProvider}.
11401
+ *
11402
+ * Multiple providers can be registered for a language. All registered providers for a language will be invoked
11403
+ * for copy and paste operations based on their handled mimetypes as specified by the {@linkcode DocumentPasteProviderMetadata}.
11404
+ *
11405
+ * For {@link DocumentPasteEditProvider.prepareDocumentPaste copy operations}, changes to the {@linkcode DataTransfer}
11406
+ * made by each provider will be merged into a single {@linkcode DataTransfer} that is used to populate the clipboard.
11407
+ *
11408
+ * For {@link DocumentPasteEditProvider.providerDocumentPasteEdits paste operations}, each provider will be invoked
11409
+ * and can return one or more {@linkcode DocumentPasteEdit DocumentPasteEdits}. The edits are sorted using
11410
+ * the {@linkcode DocumentPasteEdit.yieldTo} property. By default the first edit will be applied
11411
+ * and the rest of the edits will be shown to the user as selectable paste options in the paste widget.
11412
+ *
11413
+ * @param selector A selector that defines the documents this provider applies to.
11414
+ * @param provider A paste editor provider.
11415
+ * @param metadata Additional metadata about the provider.
11416
+ *
11417
+ * @returns A {@linkcode Disposable} that unregisters this provider when disposed of.
11418
+ * @stubbed
11382
11419
  */
11383
- export function registerDocumentDropEditProvider(selector: DocumentSelector, provider: DocumentDropEditProvider): Disposable;
11420
+ export function registerDocumentPasteEditProvider(selector: DocumentSelector, provider: DocumentPasteEditProvider, metadata: DocumentPasteProviderMetadata): Disposable;
11384
11421
 
11385
11422
  /**
11386
11423
  * Register a declaration provider.
@@ -13186,7 +13223,7 @@ export module '@theia/plugin' {
13186
13223
  /**
13187
13224
  * The shell command line. Is `undefined` if created with a command and arguments.
13188
13225
  */
13189
- commandLine?: string;
13226
+ commandLine: string | undefined;
13190
13227
 
13191
13228
  /**
13192
13229
  * The shell options used when the command line is executed in a shell.
@@ -13197,12 +13234,12 @@ export module '@theia/plugin' {
13197
13234
  /**
13198
13235
  * The shell command. Is `undefined` if created with a full command line.
13199
13236
  */
13200
- command?: string | ShellQuotedString;
13237
+ command: string | ShellQuotedString | undefined;
13201
13238
 
13202
13239
  /**
13203
13240
  * The shell args. Is `undefined` if created with a full command line.
13204
13241
  */
13205
- args?: (string | ShellQuotedString)[];
13242
+ args: Array<string | ShellQuotedString> | undefined;
13206
13243
  }
13207
13244
 
13208
13245
  export interface ProcessExecutionOptions {
@@ -13744,9 +13781,10 @@ export module '@theia/plugin' {
13744
13781
 
13745
13782
  /**
13746
13783
  * The range the comment thread is located within the document. The thread icon will be shown
13747
- * at the first line of the range.
13784
+ * at the last line of the range. When set to undefined, the comment will be associated with the
13785
+ * file, and not a specific range.
13748
13786
  */
13749
- range: Range;
13787
+ range: Range | undefined;
13750
13788
 
13751
13789
  /**
13752
13790
  * The ordered comments of the thread.
@@ -13921,6 +13959,21 @@ export module '@theia/plugin' {
13921
13959
  text: string;
13922
13960
  }
13923
13961
 
13962
+ /**
13963
+ * The ranges a CommentingRangeProvider enables commenting on.
13964
+ */
13965
+ export interface CommentingRanges {
13966
+ /**
13967
+ * Enables comments to be added to a file without a specific range.
13968
+ */
13969
+ enableFileComments: boolean;
13970
+
13971
+ /**
13972
+ * The ranges which allow new comment threads creation.
13973
+ */
13974
+ ranges?: Range[];
13975
+ }
13976
+
13924
13977
  /**
13925
13978
  * Commenting range provider for a {@link CommentController comment controller}.
13926
13979
  */
@@ -13928,7 +13981,7 @@ export module '@theia/plugin' {
13928
13981
  /**
13929
13982
  * Provide a list of ranges which allow new comment threads creation or null for a given document
13930
13983
  */
13931
- provideCommentingRanges(document: TextDocument, token: CancellationToken): ProviderResult<Range[]>;
13984
+ provideCommentingRanges(document: TextDocument, token: CancellationToken): ProviderResult<Range[] | CommentingRanges>;
13932
13985
  }
13933
13986
 
13934
13987
  /**
@@ -14343,6 +14396,338 @@ export module '@theia/plugin' {
14343
14396
  provideLinkedEditingRanges(document: TextDocument, position: Position, token: CancellationToken): ProviderResult<LinkedEditingRanges>;
14344
14397
  }
14345
14398
 
14399
+ /**
14400
+ * Identifies a {@linkcode DocumentDropEdit} or {@linkcode DocumentPasteEdit}
14401
+ */
14402
+ export class DocumentDropOrPasteEditKind {
14403
+ static readonly Empty: DocumentDropOrPasteEditKind;
14404
+
14405
+ /**
14406
+ * The root kind for basic text edits.
14407
+ *
14408
+ * This kind should be used for edits that insert basic text into the document. A good example of this is
14409
+ * an edit that pastes the clipboard text while also updating imports in the file based on the pasted text.
14410
+ * For this we could use a kind such as `text.updateImports.someLanguageId`.
14411
+ *
14412
+ * Even though most drop/paste edits ultimately insert text, you should not use {@linkcode Text} as the base kind
14413
+ * for every edit as this is redundant. Instead a more specific kind that describes the type of content being
14414
+ * inserted should be used instead. For example, if the edit adds a Markdown link, use `markdown.link` since even
14415
+ * though the content being inserted is text, it's more important to know that the edit inserts Markdown syntax.
14416
+ */
14417
+ static readonly Text: DocumentDropOrPasteEditKind;
14418
+
14419
+ /**
14420
+ * Root kind for edits that update imports in a document in addition to inserting text.
14421
+ */
14422
+ static readonly TextUpdateImports: DocumentDropOrPasteEditKind;
14423
+
14424
+ /**
14425
+ * Use {@linkcode DocumentDropOrPasteEditKind.Empty} instead.
14426
+ */
14427
+ private constructor(value: string);
14428
+
14429
+ /**
14430
+ * The raw string value of the kind.
14431
+ */
14432
+ readonly value: string;
14433
+
14434
+ /**
14435
+ * Create a new kind by appending additional scopes to the current kind.
14436
+ *
14437
+ * Does not modify the current kind.
14438
+ */
14439
+ append(...parts: string[]): DocumentDropOrPasteEditKind;
14440
+
14441
+ /**
14442
+ * Checks if this kind intersects `other`.
14443
+ *
14444
+ * The kind `"text.plain"` for example intersects `text`, `"text.plain"` and `"text.plain.list"`,
14445
+ * but not `"unicorn"`, or `"textUnicorn.plain"`.
14446
+ *
14447
+ * @param other Kind to check.
14448
+ */
14449
+ intersects(other: DocumentDropOrPasteEditKind): boolean;
14450
+
14451
+ /**
14452
+ * Checks if `other` is a sub-kind of this `DocumentDropOrPasteEditKind`.
14453
+ *
14454
+ * The kind `"text.plain"` for example contains `"text.plain"` and `"text.plain.list"`,
14455
+ * but not `"text"` or `"unicorn.text.plain"`.
14456
+ *
14457
+ * @param other Kind to check.
14458
+ */
14459
+ contains(other: DocumentDropOrPasteEditKind): boolean;
14460
+ }
14461
+
14462
+ /**
14463
+ * An edit operation applied {@link DocumentDropEditProvider on drop}.
14464
+ */
14465
+ export class DocumentDropEdit {
14466
+ /**
14467
+ * Human readable label that describes the edit.
14468
+ */
14469
+ title?: string;
14470
+
14471
+ /**
14472
+ * {@link DocumentDropOrPasteEditKind Kind} of the edit.
14473
+ */
14474
+ kind?: DocumentDropOrPasteEditKind;
14475
+
14476
+ /**
14477
+ * Controls the ordering or multiple edits. If this provider yield to edits, it will be shown lower in the list.
14478
+ */
14479
+ yieldTo?: readonly DocumentDropOrPasteEditKind[];
14480
+
14481
+ /**
14482
+ * The text or snippet to insert at the drop location.
14483
+ */
14484
+ insertText: string | SnippetString;
14485
+
14486
+ /**
14487
+ * An optional additional edit to apply on drop.
14488
+ */
14489
+ additionalEdit?: WorkspaceEdit;
14490
+
14491
+ /**
14492
+ * @param insertText The text or snippet to insert at the drop location.
14493
+ * @param title Human readable label that describes the edit.
14494
+ * @param kind {@link DocumentDropOrPasteEditKind Kind} of the edit.
14495
+ */
14496
+ constructor(insertText: string | SnippetString, title?: string, kind?: DocumentDropOrPasteEditKind);
14497
+ }
14498
+
14499
+ /**
14500
+ * Provider which handles dropping of resources into a text editor.
14501
+ *
14502
+ * This allows users to drag and drop resources (including resources from external apps) into the editor. While dragging
14503
+ * and dropping files, users can hold down `shift` to drop the file into the editor instead of opening it.
14504
+ * Requires `editor.dropIntoEditor.enabled` to be on.
14505
+ */
14506
+ export interface DocumentDropEditProvider<T extends DocumentDropEdit = DocumentDropEdit> {
14507
+ /**
14508
+ * Provide edits which inserts the content being dragged and dropped into the document.
14509
+ *
14510
+ * @param document The document in which the drop occurred.
14511
+ * @param position The position in the document where the drop occurred.
14512
+ * @param dataTransfer A {@link DataTransfer} object that holds data about what is being dragged and dropped.
14513
+ * @param token A cancellation token.
14514
+ *
14515
+ * @returns A {@link DocumentDropEdit} or a thenable that resolves to such. The lack of a result can be
14516
+ * signaled by returning `undefined` or `null`.
14517
+ */
14518
+ provideDocumentDropEdits(document: TextDocument, position: Position, dataTransfer: DataTransfer, token: CancellationToken): ProviderResult<T | T[]>;
14519
+
14520
+ /**
14521
+ * Optional method which fills in the {@linkcode DocumentDropEdit.additionalEdit} before the edit is applied.
14522
+ *
14523
+ * This is called once per edit and should be used if generating the complete edit may take a long time.
14524
+ * Resolve can only be used to change {@link DocumentDropEdit.additionalEdit}.
14525
+ *
14526
+ * @param edit The {@linkcode DocumentDropEdit} to resolve.
14527
+ * @param token A cancellation token.
14528
+ *
14529
+ * @returns The resolved edit or a thenable that resolves to such. It is OK to return the given
14530
+ * `edit`. If no result is returned, the given `edit` is used.
14531
+ */
14532
+ resolveDocumentDropEdit?(edit: T, token: CancellationToken): ProviderResult<T>;
14533
+ }
14534
+
14535
+ /**
14536
+ * Provides additional metadata about how a {@linkcode DocumentDropEditProvider} works.
14537
+ */
14538
+ export interface DocumentDropEditProviderMetadata {
14539
+ /**
14540
+ * List of {@link DocumentDropOrPasteEditKind kinds} that the provider may return in {@linkcode DocumentDropEditProvider.provideDocumentDropEdits provideDocumentDropEdits}.
14541
+ *
14542
+ * This is used to filter out providers when a specific {@link DocumentDropOrPasteEditKind kind} of edit is requested.
14543
+ */
14544
+ readonly providedDropEditKinds?: readonly DocumentDropOrPasteEditKind[];
14545
+
14546
+ /**
14547
+ * List of {@link DataTransfer} mime types that the provider can handle.
14548
+ *
14549
+ * This can either be an exact mime type such as `image/png`, or a wildcard pattern such as `image/*`.
14550
+ *
14551
+ * Use `text/uri-list` for resources dropped from the explorer or other tree views in the workbench.
14552
+ *
14553
+ * Use `files` to indicate that the provider should be invoked if any {@link DataTransferFile files} are present in the {@link DataTransfer}.
14554
+ * Note that {@link DataTransferFile} entries are only created when dropping content from outside the editor, such as
14555
+ * from the operating system.
14556
+ */
14557
+ readonly dropMimeTypes: readonly string[];
14558
+ }
14559
+
14560
+ /**
14561
+ * The reason why paste edits were requested.
14562
+ */
14563
+ export enum DocumentPasteTriggerKind {
14564
+ /**
14565
+ * Pasting was requested as part of a normal paste operation.
14566
+ */
14567
+ Automatic = 0,
14568
+
14569
+ /**
14570
+ * Pasting was requested by the user with the `paste as` command.
14571
+ */
14572
+ PasteAs = 1,
14573
+ }
14574
+
14575
+ /**
14576
+ * Additional information about the paste operation.
14577
+ */
14578
+ export interface DocumentPasteEditContext {
14579
+
14580
+ /**
14581
+ * Requested kind of paste edits to return.
14582
+ *
14583
+ * When a explicit kind if requested by {@linkcode DocumentPasteTriggerKind.PasteAs PasteAs}, providers are
14584
+ * encourage to be more flexible when generating an edit of the requested kind.
14585
+ */
14586
+ readonly only: DocumentDropOrPasteEditKind | undefined;
14587
+
14588
+ /**
14589
+ * The reason why paste edits were requested.
14590
+ */
14591
+ readonly triggerKind: DocumentPasteTriggerKind;
14592
+ }
14593
+
14594
+ /**
14595
+ * Provider invoked when the user copies or pastes in a {@linkcode TextDocument}.
14596
+ */
14597
+ export interface DocumentPasteEditProvider<T extends DocumentPasteEdit = DocumentPasteEdit> {
14598
+
14599
+ /**
14600
+ * Optional method invoked after the user copies from a {@link TextEditor text editor}.
14601
+ *
14602
+ * This allows the provider to attach metadata about the copied text to the {@link DataTransfer}. This data
14603
+ * transfer is then passed back to providers in {@linkcode provideDocumentPasteEdits}.
14604
+ *
14605
+ * Note that currently any changes to the {@linkcode DataTransfer} are isolated to the current editor window.
14606
+ * This means that any added metadata cannot be seen by other editor windows or by other applications.
14607
+ *
14608
+ * @param document Text document where the copy took place.
14609
+ * @param ranges Ranges being copied in {@linkcode document}.
14610
+ * @param dataTransfer The data transfer associated with the copy. You can store additional values on this for
14611
+ * later use in {@linkcode provideDocumentPasteEdits}. This object is only valid for the duration of this method.
14612
+ * @param token A cancellation token.
14613
+ *
14614
+ * @return Optional thenable that resolves when all changes to the `dataTransfer` are complete.
14615
+ */
14616
+ prepareDocumentPaste?(document: TextDocument, ranges: readonly Range[], dataTransfer: DataTransfer, token: CancellationToken): void | Thenable<void>;
14617
+
14618
+ /**
14619
+ * Invoked before the user pastes into a {@link TextEditor text editor}.
14620
+ *
14621
+ * Returned edits can replace the standard pasting behavior.
14622
+ *
14623
+ * @param document Document being pasted into
14624
+ * @param ranges Range in the {@linkcode document} to paste into.
14625
+ * @param dataTransfer The {@link DataTransfer data transfer} associated with the paste. This object is only
14626
+ * valid for the duration of the paste operation.
14627
+ * @param context Additional context for the paste.
14628
+ * @param token A cancellation token.
14629
+ *
14630
+ * @return Set of potential {@link DocumentPasteEdit edits} that can apply the paste. Only a single returned
14631
+ * {@linkcode DocumentPasteEdit} is applied at a time. If multiple edits are returned from all providers, then
14632
+ * the first is automatically applied and a widget is shown that lets the user switch to the other edits.
14633
+ */
14634
+ provideDocumentPasteEdits?(document: TextDocument, ranges: readonly Range[], dataTransfer: DataTransfer, context: DocumentPasteEditContext, token: CancellationToken): ProviderResult<T[]>;
14635
+
14636
+ /**
14637
+ * Optional method which fills in the {@linkcode DocumentPasteEdit.additionalEdit} before the edit is applied.
14638
+ *
14639
+ * This is called once per edit and should be used if generating the complete edit may take a long time.
14640
+ * Resolve can only be used to change {@linkcode DocumentPasteEdit.insertText} or {@linkcode DocumentPasteEdit.additionalEdit}.
14641
+ *
14642
+ * @param pasteEdit The {@linkcode DocumentPasteEdit} to resolve.
14643
+ * @param token A cancellation token.
14644
+ *
14645
+ * @returns The resolved paste edit or a thenable that resolves to such. It is OK to return the given
14646
+ * `pasteEdit`. If no result is returned, the given `pasteEdit` is used.
14647
+ */
14648
+ resolveDocumentPasteEdit?(pasteEdit: T, token: CancellationToken): ProviderResult<T>;
14649
+ }
14650
+
14651
+ /**
14652
+ * An edit the applies a paste operation.
14653
+ */
14654
+ export class DocumentPasteEdit {
14655
+
14656
+ /**
14657
+ * Human readable label that describes the edit.
14658
+ */
14659
+ title: string;
14660
+
14661
+ /**
14662
+ * {@link DocumentDropOrPasteEditKind Kind} of the edit.
14663
+ */
14664
+ kind: DocumentDropOrPasteEditKind;
14665
+
14666
+ /**
14667
+ * The text or snippet to insert at the pasted locations.
14668
+ *
14669
+ * If your edit requires more advanced insertion logic, set this to an empty string and provide an {@link DocumentPasteEdit.additionalEdit additional edit} instead.
14670
+ */
14671
+ insertText: string | SnippetString;
14672
+
14673
+ /**
14674
+ * An optional additional edit to apply on paste.
14675
+ */
14676
+ additionalEdit?: WorkspaceEdit;
14677
+
14678
+ /**
14679
+ * Controls ordering when multiple paste edits can potentially be applied.
14680
+ *
14681
+ * If this edit yields to another, it will be shown lower in the list of possible paste edits shown to the user.
14682
+ */
14683
+ yieldTo?: readonly DocumentDropOrPasteEditKind[];
14684
+
14685
+ /**
14686
+ * Create a new paste edit.
14687
+ *
14688
+ * @param insertText The text or snippet to insert at the pasted locations.
14689
+ * @param title Human readable label that describes the edit.
14690
+ * @param kind {@link DocumentDropOrPasteEditKind Kind} of the edit.
14691
+ */
14692
+ constructor(insertText: string | SnippetString, title: string, kind: DocumentDropOrPasteEditKind);
14693
+ }
14694
+
14695
+ /**
14696
+ * Provides additional metadata about how a {@linkcode DocumentPasteEditProvider} works.
14697
+ */
14698
+ export interface DocumentPasteProviderMetadata {
14699
+ /**
14700
+ * List of {@link DocumentDropOrPasteEditKind kinds} that the provider may return in {@linkcode DocumentPasteEditProvider.provideDocumentPasteEdits provideDocumentPasteEdits}.
14701
+ *
14702
+ * This is used to filter out providers when a specific {@link DocumentDropOrPasteEditKind kind} of edit is requested.
14703
+ */
14704
+ readonly providedPasteEditKinds: readonly DocumentDropOrPasteEditKind[];
14705
+
14706
+ /**
14707
+ * Mime types that {@linkcode DocumentPasteEditProvider.prepareDocumentPaste prepareDocumentPaste} may add on copy.
14708
+ */
14709
+ readonly copyMimeTypes?: readonly string[];
14710
+
14711
+ /**
14712
+ * Mime types that {@linkcode DocumentPasteEditProvider.provideDocumentPasteEdits provideDocumentPasteEdits} should be invoked for.
14713
+ *
14714
+ * This can either be an exact mime type such as `image/png`, or a wildcard pattern such as `image/*`.
14715
+ *
14716
+ * Use `text/uri-list` for resources dropped from the explorer or other tree views in the workbench.
14717
+ *
14718
+ * Use `files` to indicate that the provider should be invoked if any {@link DataTransferFile files} are present in the {@linkcode DataTransfer}.
14719
+ * Note that {@linkcode DataTransferFile} entries are only created when pasting content from outside the editor, such as
14720
+ * from the operating system.
14721
+ */
14722
+ readonly pasteMimeTypes?: readonly string[];
14723
+ }
14724
+
14725
+ /**
14726
+ * A tuple of two characters, like a pair of
14727
+ * opening and closing brackets.
14728
+ */
14729
+ export type CharacterPair = [string, string];
14730
+
14346
14731
  /**
14347
14732
  * An edit operation applied {@link DocumentDropEditProvider on drop}.
14348
14733
  */
@@ -1,330 +0,0 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2023 Ericsson and others.
3
- //
4
- // This program and the accompanying materials are made available under the
5
- // terms of the Eclipse Public License v. 2.0 which is available at
6
- // http://www.eclipse.org/legal/epl-2.0.
7
- //
8
- // This Source Code may also be made available under the following Secondary
9
- // Licenses when the conditions for such availability set forth in the Eclipse
10
- // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
- // with the GNU Classpath Exception which is available at
12
- // https://www.gnu.org/software/classpath/license.html.
13
- //
14
- // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
- // *****************************************************************************
16
-
17
- /*---------------------------------------------------------------------------------------------
18
- * Copyright (c) Microsoft Corporation. All rights reserved.
19
- * Licensed under the MIT License. See License.txt in the project root for license information.
20
- *--------------------------------------------------------------------------------------------*/
21
- // code copied and modified from https://github.com/microsoft/vscode/blob/1.79.0/src/vscode-dts/vscode.proposed.documentPaste.d.ts
22
-
23
- export module '@theia/plugin' {
24
-
25
- /**
26
- * Identifies a {@linkcode DocumentDropEdit} or {@linkcode DocumentPasteEdit}
27
- */
28
- class DocumentDropOrPasteEditKind {
29
- static readonly Empty: DocumentDropOrPasteEditKind;
30
-
31
- /**
32
- * The root kind for basic text edits.
33
- *
34
- * This kind should be used for edits that insert basic text into the document. A good example of this is
35
- * an edit that pastes the clipboard text while also updating imports in the file based on the pasted text.
36
- * For this we could use a kind such as `text.updateImports.someLanguageId`.
37
- *
38
- * Even though most drop/paste edits ultimately insert text, you should not use {@linkcode Text} as the base kind
39
- * for every edit as this is redundant. Instead a more specific kind that describes the type of content being
40
- * inserted should be used instead For example, if the edit adds a Markdown link, use `markdown.link` since even
41
- * though the content being inserted is text, it's more important to know that the edit inserts Markdown syntax.
42
- */
43
- static readonly Text: DocumentDropOrPasteEditKind;
44
-
45
- private constructor(value: string);
46
-
47
- /**
48
- * The raw string value of the kind.
49
- */
50
- readonly value: string;
51
-
52
- /**
53
- * Create a new kind by appending additional scopes to the current kind.
54
- *
55
- * Does not modify the current kind.
56
- */
57
- append(...parts: string[]): DocumentDropOrPasteEditKind;
58
-
59
- /**
60
- * Checks if this kind intersects `other`.
61
- *
62
- * The kind `"text.plain"` for example intersects `text`, `"text.plain"` and `"text.plain.list"`,
63
- * but not `"unicorn"`, or `"textUnicorn.plain"`.
64
- *
65
- * @param other Kind to check.
66
- */
67
- intersects(other: DocumentDropOrPasteEditKind): boolean;
68
-
69
- /**
70
- * Checks if `other` is a sub-kind of this `DocumentDropOrPasteEditKind`.
71
- *
72
- * The kind `"text.plain"` for example contains `"text.plain"` and `"text.plain.list"`,
73
- * but not `"text"` or `"unicorn.text.plain"`.
74
- *
75
- * @param other Kind to check.
76
- */
77
- contains(other: DocumentDropOrPasteEditKind): boolean;
78
- }
79
-
80
- /**
81
- * The reason why paste edits were requested.
82
- */
83
- export enum DocumentPasteTriggerKind {
84
- /**
85
- * Pasting was requested as part of a normal paste operation.
86
- */
87
- Automatic = 0,
88
-
89
- /**
90
- * Pasting was requested by the user with the `paste as` command.
91
- */
92
- PasteAs = 1,
93
- }
94
-
95
- /**
96
- * Additional information about the paste operation.
97
- */
98
-
99
- export interface DocumentPasteEditContext {
100
- /**
101
- * Requested kind of paste edits to return.
102
- */
103
- readonly only: DocumentDropOrPasteEditKind | undefined;
104
-
105
- /**
106
- * The reason why paste edits were requested.
107
- */
108
- readonly triggerKind: DocumentPasteTriggerKind;
109
- }
110
-
111
- /**
112
- * Provider invoked when the user copies or pastes in a {@linkcode TextDocument}.
113
- */
114
- interface DocumentPasteEditProvider<T extends DocumentPasteEdit = DocumentPasteEdit> {
115
-
116
- /**
117
- * Optional method invoked after the user copies from a {@link TextEditor text editor}.
118
- *
119
- * This allows the provider to attach metadata about the copied text to the {@link DataTransfer}. This data
120
- * transfer is then passed back to providers in {@linkcode provideDocumentPasteEdits}.
121
- *
122
- * Note that currently any changes to the {@linkcode DataTransfer} are isolated to the current editor window.
123
- * This means that any added metadata cannot be seen by other editor windows or by other applications.
124
- *
125
- * @param document Text document where the copy took place.
126
- * @param ranges Ranges being copied in {@linkcode document}.
127
- * @param dataTransfer The data transfer associated with the copy. You can store additional values on this for
128
- * later use in {@linkcode provideDocumentPasteEdits}. This object is only valid for the duration of this method.
129
- * @param token A cancellation token.
130
- *
131
- * @return Optional thenable that resolves when all changes to the `dataTransfer` are complete.
132
- */
133
- prepareDocumentPaste?(document: TextDocument, ranges: readonly Range[], dataTransfer: DataTransfer, token: CancellationToken): void | Thenable<void>;
134
-
135
- /**
136
- * Invoked before the user pastes into a {@link TextEditor text editor}.
137
- *
138
- * Returned edits can replace the standard pasting behavior.
139
- *
140
- * @param document Document being pasted into
141
- * @param ranges Range in the {@linkcode document} to paste into.
142
- * @param dataTransfer The {@link DataTransfer data transfer} associated with the paste. This object is only
143
- * valid for the duration of the paste operation.
144
- * @param context Additional context for the paste.
145
- * @param token A cancellation token.
146
- *
147
- * @return Set of potential {@link DocumentPasteEdit edits} that can apply the paste. Only a single returned
148
- * {@linkcode DocumentPasteEdit} is applied at a time. If multiple edits are returned from all providers, then
149
- * the first is automatically applied and a widget is shown that lets the user switch to the other edits.
150
- */
151
- provideDocumentPasteEdits?(document: TextDocument, ranges: readonly Range[], dataTransfer: DataTransfer, context: DocumentPasteEditContext, token: CancellationToken):
152
- ProviderResult<T[]>;
153
-
154
- /**
155
- * Optional method which fills in the {@linkcode DocumentPasteEdit.additionalEdit} before the edit is applied.
156
- *
157
- * This is called once per edit and should be used if generating the complete edit may take a long time.
158
- * Resolve can only be used to change {@linkcode DocumentPasteEdit.additionalEdit}.
159
- *
160
- * @param pasteEdit The {@linkcode DocumentPasteEdit} to resolve.
161
- * @param token A cancellation token.
162
- *
163
- * @returns The resolved paste edit or a thenable that resolves to such. It is OK to return the given
164
- * `pasteEdit`. If no result is returned, the given `pasteEdit` is used.
165
- */
166
- resolveDocumentPasteEdit?(pasteEdit: T, token: CancellationToken): ProviderResult<T>;
167
- }
168
-
169
- /**
170
- * An edit the applies a paste operation.
171
- */
172
- class DocumentPasteEdit {
173
-
174
- /**
175
- * Human readable label that describes the edit.
176
- */
177
- title: string;
178
-
179
- /**
180
- * {@link DocumentDropOrPasteEditKind Kind} of the edit.
181
- */
182
- kind: DocumentDropOrPasteEditKind;
183
-
184
- /**
185
- * The text or snippet to insert at the pasted locations.
186
- *
187
- * If your edit requires more advanced insertion logic, set this to an empty string and provide an {@link DocumentPasteEdit.additionalEdit additional edit} instead.
188
- */
189
- insertText: string | SnippetString;
190
-
191
- /**
192
- * An optional additional edit to apply on paste.
193
- */
194
- additionalEdit?: WorkspaceEdit;
195
-
196
- /**
197
- * Controls ordering when multiple paste edits can potentially be applied.
198
- *
199
- * If this edit yields to another, it will be shown lower in the list of possible paste edits shown to the user.
200
- */
201
- yieldTo?: readonly DocumentDropOrPasteEditKind[];
202
-
203
- /**
204
- * Create a new paste edit.
205
- *
206
- * @param insertText The text or snippet to insert at the pasted locations.
207
- * @param title Human readable label that describes the edit.
208
- * @param kind {@link DocumentDropOrPasteEditKind Kind} of the edit.
209
- */
210
- constructor(insertText: string | SnippetString, title: string, kind: DocumentDropOrPasteEditKind);
211
- }
212
-
213
- /**
214
- * Provides additional metadata about how a {@linkcode DocumentPasteEditProvider} works.
215
- */
216
- interface DocumentPasteProviderMetadata {
217
- /**
218
- * List of {@link DocumentDropOrPasteEditKind kinds} that the provider may return in
219
- * {@linkcode DocumentPasteEditProvider.provideDocumentPasteEdits provideDocumentPasteEdits}.
220
- *
221
- * This is used to filter out providers when a specific {@link DocumentDropOrPasteEditKind kind} of edit is requested.
222
- */
223
- readonly providedPasteEditKinds: readonly DocumentDropOrPasteEditKind[];
224
-
225
- /**
226
- * Mime types that {@linkcode DocumentPasteEditProvider.prepareDocumentPaste prepareDocumentPaste} may add on copy.
227
- */
228
- readonly copyMimeTypes?: readonly string[];
229
-
230
- /**
231
- * Mime types that {@linkcode DocumentPasteEditProvider.provideDocumentPasteEdits provideDocumentPasteEdits} should be invoked for.
232
- *
233
- * This can either be an exact mime type such as `image/png`, or a wildcard pattern such as `image/*`.
234
- *
235
- * Use `text/uri-list` for resources dropped from the explorer or other tree views in the workbench.
236
- *
237
- * Use `files` to indicate that the provider should be invoked if any {@link DataTransferFile files} are present in the {@linkcode DataTransfer}.
238
- * Note that {@linkcode DataTransferFile} entries are only created when pasting content from outside the editor, such as
239
- * from the operating system.
240
- */
241
- readonly pasteMimeTypes?: readonly string[];
242
- }
243
-
244
- /**
245
- * TODO on finalization:
246
- * - Add ctor(insertText: string | SnippetString, title?: string, kind?: DocumentDropOrPasteEditKind); Can't be done as this is an extension to an existing class
247
- */
248
-
249
- export interface DocumentDropEdit {
250
- /**
251
- * Human readable label that describes the edit.
252
- */
253
- title?: string;
254
-
255
- /**
256
- * {@link DocumentDropOrPasteEditKind Kind} of the edit.
257
- */
258
- kind: DocumentDropOrPasteEditKind;
259
-
260
- /**
261
- * Controls the ordering or multiple edits. If this provider yield to edits, it will be shown lower in the list.
262
- */
263
- yieldTo?: readonly DocumentDropOrPasteEditKind[];
264
- }
265
-
266
- export interface DocumentDropEditProvider<T extends DocumentDropEdit = DocumentDropEdit> {
267
- // Overload that allows returning multiple edits
268
- // Will be merged in on finalization
269
- provideDocumentDropEdits(document: TextDocument, position: Position, dataTransfer: DataTransfer, token: CancellationToken):
270
- ProviderResult<DocumentDropEdit | DocumentDropEdit[]>;
271
-
272
- /**
273
- * Optional method which fills in the {@linkcode DocumentDropEdit.additionalEdit} before the edit is applied.
274
- *
275
- * This is called once per edit and should be used if generating the complete edit may take a long time.
276
- * Resolve can only be used to change {@link DocumentDropEdit.additionalEdit}.
277
- *
278
- * @param pasteEdit The {@linkcode DocumentDropEdit} to resolve.
279
- * @param token A cancellation token.
280
- *
281
- * @returns The resolved edit or a thenable that resolves to such. It is OK to return the given
282
- * `edit`. If no result is returned, the given `edit` is used.
283
- */
284
- resolveDocumentDropEdit?(edit: T, token: CancellationToken): ProviderResult<T>;
285
- }
286
-
287
- /**
288
- * Provides additional metadata about how a {@linkcode DocumentDropEditProvider} works.
289
- */
290
- export interface DocumentDropEditProviderMetadata {
291
- /**
292
- * List of {@link DocumentDropOrPasteEditKind kinds} that the provider may return in {@linkcode DocumentDropEditProvider.provideDocumentDropEdits provideDocumentDropEdits}.
293
- *
294
- * This is used to filter out providers when a specific {@link DocumentDropOrPasteEditKind kind} of edit is requested.
295
- */
296
- readonly providedDropEditKinds?: readonly DocumentDropOrPasteEditKind[];
297
-
298
- /**
299
- * List of {@link DataTransfer} mime types that the provider can handle.
300
- *
301
- * This can either be an exact mime type such as `image/png`, or a wildcard pattern such as `image/*`.
302
- *
303
- * Use `text/uri-list` for resources dropped from the explorer or other tree views in the workbench.
304
- *
305
- * Use `files` to indicate that the provider should be invoked if any {@link DataTransferFile files} are present in the {@link DataTransfer}.
306
- * Note that {@link DataTransferFile} entries are only created when dropping content from outside the editor, such as
307
- * from the operating system.
308
- */
309
- readonly dropMimeTypes: readonly string[];
310
- }
311
-
312
- namespace languages {
313
- /**
314
- * Registers a new {@linkcode DocumentPasteEditProvider}.
315
- *
316
- * @param selector A selector that defines the documents this provider applies to.
317
- * @param provider A paste editor provider.
318
- * @param metadata Additional metadata about the provider.
319
- *
320
- * @returns A {@link Disposable} that unregisters this provider when disposed of.
321
- * @stubbed
322
- */
323
- export function registerDocumentPasteEditProvider(selector: DocumentSelector, provider: DocumentPasteEditProvider, metadata: DocumentPasteProviderMetadata): Disposable;
324
-
325
- /**
326
- * Overload which adds extra metadata. Will be removed on finalization.
327
- */
328
- export function registerDocumentDropEditProvider(selector: DocumentSelector, provider: DocumentDropEditProvider, metadata?: DocumentDropEditProviderMetadata): Disposable;
329
- }
330
- }