@theia/plugin 1.46.0-next.153 → 1.46.0-next.196

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.46.0-next.153+cff0a9c25",
3
+ "version": "1.46.0-next.196+cb2bd96b3",
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.48.0"
30
+ "@theia/ext-scripts": "1.49.0"
31
31
  },
32
32
  "nyc": {
33
33
  "extends": "../../configs/nyc.json"
34
34
  },
35
- "gitHead": "cff0a9c255ee748de2a055972196850faf09277f"
35
+ "gitHead": "cb2bd96b362408c90179005a5b415ddbd452ce41"
36
36
  }
package/src/theia.d.ts CHANGED
@@ -30,6 +30,7 @@ import './theia.proposed.dropMetadata';
30
30
  import './theia.proposed.editSessionIdentityProvider';
31
31
  import './theia.proposed.extensionsAny';
32
32
  import './theia.proposed.externalUriOpener';
33
+ import './theia.proposed.mappedEditsProvider';
33
34
  import './theia.proposed.notebookCellExecutionState';
34
35
  import './theia.proposed.notebookKernelSource';
35
36
  import './theia.proposed.notebookMessaging';
@@ -16035,6 +16036,18 @@ export module '@theia/plugin' {
16035
16036
  */
16036
16037
  runHandler: (request: TestRunRequest, token: CancellationToken) => Thenable<void> | void;
16037
16038
 
16039
+ /**
16040
+ * An extension-provided function that provides detailed statement and
16041
+ * function-level coverage for a file. The editor will call this when more
16042
+ * detail is needed for a file, such as when it's opened in an editor or
16043
+ * expanded in the **Test Coverage** view.
16044
+ *
16045
+ * The {@link FileCoverage} object passed to this function is the same instance
16046
+ * emitted on {@link TestRun.addCoverage} calls associated with this profile.
16047
+ * @stubbed
16048
+ */
16049
+ loadDetailedCoverage?: (testRun: TestRun, fileCoverage: FileCoverage, token: CancellationToken) => Thenable<FileCoverageDetail[]>;
16050
+
16038
16051
  /**
16039
16052
  * Deletes the run profile.
16040
16053
  */
@@ -16314,11 +16327,23 @@ export module '@theia/plugin' {
16314
16327
  */
16315
16328
  appendOutput(output: string, location?: Location, test?: TestItem): void;
16316
16329
 
16330
+ /**
16331
+ * Adds coverage for a file in the run.
16332
+ * @stubbed
16333
+ */
16334
+ addCoverage(fileCoverage: FileCoverage): void;
16335
+
16317
16336
  /**
16318
16337
  * Signals the end of the test run. Any tests included in the run whose
16319
16338
  * states have not been updated will have their state reset.
16320
16339
  */
16321
16340
  end(): void;
16341
+
16342
+ /**
16343
+ * An event fired when the editor is no longer interested in data
16344
+ * associated with the test run.
16345
+ */
16346
+ onDidDispose: Event<void>;
16322
16347
  }
16323
16348
 
16324
16349
  /**
@@ -16527,6 +16552,178 @@ export module '@theia/plugin' {
16527
16552
  */
16528
16553
  constructor(message: string | MarkdownString);
16529
16554
  }
16555
+
16556
+ /**
16557
+ * A class that contains information about a covered resource. A count can
16558
+ * be give for lines, branches, and declarations in a file.
16559
+ */
16560
+ export class TestCoverageCount {
16561
+ /**
16562
+ * Number of items covered in the file.
16563
+ */
16564
+ covered: number;
16565
+ /**
16566
+ * Total number of covered items in the file.
16567
+ */
16568
+ total: number;
16569
+
16570
+ /**
16571
+ * @param covered Value for {@link TestCoverageCount.covered}
16572
+ * @param total Value for {@link TestCoverageCount.total}
16573
+ */
16574
+ constructor(covered: number, total: number);
16575
+ }
16576
+
16577
+ /**
16578
+ * Contains coverage metadata for a file.
16579
+ */
16580
+ export class FileCoverage {
16581
+ /**
16582
+ * File URI.
16583
+ */
16584
+ readonly uri: Uri;
16585
+
16586
+ /**
16587
+ * Statement coverage information. If the reporter does not provide statement
16588
+ * coverage information, this can instead be used to represent line coverage.
16589
+ */
16590
+ statementCoverage: TestCoverageCount;
16591
+
16592
+ /**
16593
+ * Branch coverage information.
16594
+ */
16595
+ branchCoverage?: TestCoverageCount;
16596
+
16597
+ /**
16598
+ * Declaration coverage information. Depending on the reporter and
16599
+ * language, this may be types such as functions, methods, or namespaces.
16600
+ */
16601
+ declarationCoverage?: TestCoverageCount;
16602
+
16603
+ /**
16604
+ * Creates a {@link FileCoverage} instance with counts filled in from
16605
+ * the coverage details.
16606
+ * @param uri Covered file URI
16607
+ * @param detailed Detailed coverage information
16608
+ */
16609
+ static fromDetails(uri: Uri, details: readonly FileCoverageDetail[]): FileCoverage;
16610
+
16611
+ /**
16612
+ * @param uri Covered file URI
16613
+ * @param statementCoverage Statement coverage information. If the reporter
16614
+ * does not provide statement coverage information, this can instead be
16615
+ * used to represent line coverage.
16616
+ * @param branchCoverage Branch coverage information
16617
+ * @param declarationCoverage Declaration coverage information
16618
+ */
16619
+ constructor(
16620
+ uri: Uri,
16621
+ statementCoverage: TestCoverageCount,
16622
+ branchCoverage?: TestCoverageCount,
16623
+ declarationCoverage?: TestCoverageCount,
16624
+ );
16625
+ }
16626
+
16627
+ /**
16628
+ * Contains coverage information for a single statement or line.
16629
+ */
16630
+ export class StatementCoverage {
16631
+ /**
16632
+ * The number of times this statement was executed, or a boolean indicating
16633
+ * whether it was executed if the exact count is unknown. If zero or false,
16634
+ * the statement will be marked as un-covered.
16635
+ */
16636
+ executed: number | boolean;
16637
+
16638
+ /**
16639
+ * Statement location.
16640
+ */
16641
+ location: Position | Range;
16642
+
16643
+ /**
16644
+ * Coverage from branches of this line or statement. If it's not a
16645
+ * conditional, this will be empty.
16646
+ */
16647
+ branches: BranchCoverage[];
16648
+
16649
+ /**
16650
+ * @param location The statement position.
16651
+ * @param executed The number of times this statement was executed, or a
16652
+ * boolean indicating whether it was executed if the exact count is
16653
+ * unknown. If zero or false, the statement will be marked as un-covered.
16654
+ * @param branches Coverage from branches of this line. If it's not a
16655
+ * conditional, this should be omitted.
16656
+ */
16657
+ constructor(executed: number | boolean, location: Position | Range, branches?: BranchCoverage[]);
16658
+ }
16659
+
16660
+ /**
16661
+ * Contains coverage information for a branch of a {@link StatementCoverage}.
16662
+ */
16663
+ export class BranchCoverage {
16664
+ /**
16665
+ * The number of times this branch was executed, or a boolean indicating
16666
+ * whether it was executed if the exact count is unknown. If zero or false,
16667
+ * the branch will be marked as un-covered.
16668
+ */
16669
+ executed: number | boolean;
16670
+
16671
+ /**
16672
+ * Branch location.
16673
+ */
16674
+ location?: Position | Range;
16675
+
16676
+ /**
16677
+ * Label for the branch, used in the context of "the ${label} branch was
16678
+ * not taken," for example.
16679
+ */
16680
+ label?: string;
16681
+
16682
+ /**
16683
+ * @param executed The number of times this branch was executed, or a
16684
+ * boolean indicating whether it was executed if the exact count is
16685
+ * unknown. If zero or false, the branch will be marked as un-covered.
16686
+ * @param location The branch position.
16687
+ */
16688
+ constructor(executed: number | boolean, location?: Position | Range, label?: string);
16689
+ }
16690
+
16691
+ /**
16692
+ * Contains coverage information for a declaration. Depending on the reporter
16693
+ * and language, this may be types such as functions, methods, or namespaces.
16694
+ */
16695
+ export class DeclarationCoverage {
16696
+ /**
16697
+ * Name of the declaration.
16698
+ */
16699
+ name: string;
16700
+
16701
+ /**
16702
+ * The number of times this declaration was executed, or a boolean
16703
+ * indicating whether it was executed if the exact count is unknown. If
16704
+ * zero or false, the declaration will be marked as un-covered.
16705
+ */
16706
+ executed: number | boolean;
16707
+
16708
+ /**
16709
+ * Declaration location.
16710
+ */
16711
+ location: Position | Range;
16712
+
16713
+ /**
16714
+ * @param executed The number of times this declaration was executed, or a
16715
+ * boolean indicating whether it was executed if the exact count is
16716
+ * unknown. If zero or false, the declaration will be marked as un-covered.
16717
+ * @param location The declaration position.
16718
+ */
16719
+ constructor(name: string, executed: number | boolean, location: Position | Range);
16720
+ }
16721
+
16722
+ /**
16723
+ * Coverage details returned from {@link TestRunProfile.loadDetailedCoverage}.
16724
+ */
16725
+ export type FileCoverageDetail = StatementCoverage | DeclarationCoverage;
16726
+
16530
16727
  /**
16531
16728
  * Thenable is a common denominator between ES6 promises, Q, jquery.Deferred, WinJS.Promise,
16532
16729
  * and others. This API makes no assumption about what promise library is being used which
@@ -23,54 +23,107 @@
23
23
  export module '@theia/plugin' {
24
24
 
25
25
  /**
26
- * Provider invoked when the user copies and pastes code.
26
+ * The reason why paste edits were requested.
27
27
  */
28
- export interface DocumentPasteEditProvider {
28
+ export enum DocumentPasteTriggerKind {
29
+ /**
30
+ * Pasting was requested as part of a normal paste operation.
31
+ */
32
+ Automatic = 0,
33
+
34
+ /**
35
+ * Pasting was requested by the user with the `paste as` command.
36
+ */
37
+ PasteAs = 1,
38
+ }
39
+
40
+ /**
41
+ * Additional information about the paste operation.
42
+ */
43
+
44
+ export interface DocumentPasteEditContext {
45
+ /**
46
+ * Requested kind of paste edits to return.
47
+ */
48
+ readonly only: DocumentPasteEditKind | undefined;
49
+
50
+ /**
51
+ * The reason why paste edits were requested.
52
+ */
53
+ readonly triggerKind: DocumentPasteTriggerKind;
54
+ }
55
+
56
+ /**
57
+ * Provider invoked when the user copies or pastes in a {@linkcode TextDocument}.
58
+ */
59
+ interface DocumentPasteEditProvider<T extends DocumentPasteEdit = DocumentPasteEdit> {
29
60
 
30
61
  /**
31
62
  * Optional method invoked after the user copies text in a file.
32
63
  *
33
- * During {@link prepareDocumentPaste}, an extension can compute metadata that is attached to
34
- * a {@link DataTransfer} and is passed back to the provider in {@link provideDocumentPasteEdits}.
64
+ * This allows the provider to attach copy metadata to the {@link DataTransfer}
65
+ * which is then passed back to providers in {@linkcode provideDocumentPasteEdits}.
66
+ *
67
+ * Note that currently any changes to the {@linkcode DataTransfer} are isolated to the current editor session.
68
+ * This means that added metadata cannot be seen by other applications.
35
69
  *
36
70
  * @param document Document where the copy took place.
37
- * @param ranges Ranges being copied in the `document`.
38
- * @param dataTransfer The data transfer associated with the copy. You can store additional values on this for later use in {@link provideDocumentPasteEdits}.
71
+ * @param ranges Ranges being copied in {@linkcode document}.
72
+ * @param dataTransfer The data transfer associated with the copy. You can store additional values on this for later use in {@linkcode provideDocumentPasteEdits}.
73
+ * This object is only valid for the duration of this method.
39
74
  * @param token A cancellation token.
75
+ *
76
+ * @return Optional thenable that resolves when all changes to the `dataTransfer` are complete.
40
77
  */
41
78
  prepareDocumentPaste?(document: TextDocument, ranges: readonly Range[], dataTransfer: DataTransfer, token: CancellationToken): void | Thenable<void>;
42
79
 
43
80
  /**
44
81
  * Invoked before the user pastes into a document.
45
82
  *
46
- * In this method, extensions can return a workspace edit that replaces the standard pasting behavior.
83
+ * Returned edits can replace the standard pasting behavior.
47
84
  *
48
85
  * @param document Document being pasted into
49
- * @param ranges Currently selected ranges in the document.
50
- * @param dataTransfer The data transfer associated with the paste.
86
+ * @param ranges Range in the {@linkcode document} to paste into.
87
+ * @param dataTransfer The {@link DataTransfer data transfer} associated with the paste. This object is only valid for the duration of the paste operation.
88
+ * @param context Additional context for the paste.
51
89
  * @param token A cancellation token.
52
90
  *
53
- * @return Optional workspace edit that applies the paste. Return undefined to use standard pasting.
91
+ * @return Set of potential {@link DocumentPasteEdit edits} that apply the paste. Return `undefined` to use standard pasting.
54
92
  */
55
- provideDocumentPasteEdits?(document: TextDocument, ranges: readonly Range[], dataTransfer: DataTransfer, token: CancellationToken): ProviderResult<DocumentPasteEdit>;
93
+ provideDocumentPasteEdits?(document: TextDocument, ranges: readonly Range[], dataTransfer: DataTransfer, context: DocumentPasteEditContext,
94
+ token: CancellationToken): ProviderResult<T[]>;
95
+
96
+ /**
97
+ * Optional method which fills in the {@linkcode DocumentPasteEdit.additionalEdit} before the edit is applied.
98
+ *
99
+ * This is called once per edit and should be used if generating the complete edit may take a long time.
100
+ * Resolve can only be used to change {@link DocumentPasteEdit.additionalEdit}.
101
+ *
102
+ * @param pasteEdit The {@linkcode DocumentPasteEdit} to resolve.
103
+ * @param token A cancellation token.
104
+ *
105
+ * @returns The resolved paste edit or a thenable that resolves to such. It is OK to return the given
106
+ * `pasteEdit`. If no result is returned, the given `pasteEdit` is used.
107
+ */
108
+ resolveDocumentPasteEdit?(pasteEdit: T, token: CancellationToken): ProviderResult<T>;
56
109
  }
57
110
 
58
111
  /**
59
- * An operation applied on paste
112
+ * An edit applied on paste.
60
113
  */
61
114
  class DocumentPasteEdit {
115
+
62
116
  /**
63
117
  * Human readable label that describes the edit.
64
118
  */
65
- label: string;
119
+ title: string;
66
120
 
67
121
  /**
68
- * Controls the ordering or multiple paste edits. If this provider yield to edits, it will be shown lower in the list.
122
+ * {@link DocumentPasteEditKind Kind} of the edit.
123
+ *
124
+ * Used to identify specific types of edits.
69
125
  */
70
- yieldTo?: ReadonlyArray<
71
- | { readonly extensionId: string; readonly providerId: string }
72
- | { readonly mimeType: string }
73
- >;
126
+ kind: DocumentPasteEditKind;
74
127
 
75
128
  /**
76
129
  * The text or snippet to insert at the pasted locations.
@@ -83,43 +136,77 @@ export module '@theia/plugin' {
83
136
  additionalEdit?: WorkspaceEdit;
84
137
 
85
138
  /**
86
- * @param insertText The text or snippet to insert at the pasted locations.
139
+ * Controls the ordering of paste edits provided by multiple providers.
87
140
  *
88
- * TODO: Reverse args, but this will break existing consumers :(
141
+ * If this edit yields to another, it will be shown lower in the list of paste edit.
89
142
  */
90
- constructor(insertText: string | SnippetString, id: string, label: string);
143
+ yieldTo?: readonly DocumentPasteEditKind[];
144
+
145
+ /**
146
+ * Create a new paste edit.
147
+ *
148
+ * @param insertText The text or snippet to insert at the pasted locations.
149
+ * @param title Human readable label that describes the edit.
150
+ * @param kind {@link DocumentPasteEditKind Kind} of the edit.
151
+ */
152
+ constructor(insertText: string | SnippetString, title: string, kind: DocumentPasteEditKind);
153
+ }
154
+
155
+ /**
156
+ * TODO: Share with code action kind?
157
+ */
158
+ class DocumentPasteEditKind {
159
+ static readonly Empty: DocumentPasteEditKind;
160
+
161
+ // TODO: Add `Text` any others?
162
+
163
+ private constructor(value: string);
164
+
165
+ readonly value: string;
166
+
167
+ append(...parts: string[]): CodeActionKind;
168
+ intersects(other: CodeActionKind): boolean;
169
+ contains(other: CodeActionKind): boolean;
91
170
  }
92
171
 
93
172
  interface DocumentPasteProviderMetadata {
94
173
  /**
95
- * Identifies the provider.
96
- *
97
- * This id is used when users configure the default provider for paste.
174
+ * List of {@link DocumentPasteEditKind kinds} that the provider may return in {@linkcode DocumentPasteEditProvider.provideDocumentPasteEdits provideDocumentPasteEdits}.
98
175
  *
99
- * This id should be unique within the extension but does not need to be unique across extensions.
176
+ * The provider will only be invoked when one of these kinds is being requested. For normal pasting, all providers will be invoked.
100
177
  */
101
- readonly id: string;
178
+ readonly providedPasteEditKinds: readonly DocumentPasteEditKind[];
102
179
 
103
180
  /**
104
- * Mime types that {@link DocumentPasteEditProvider.prepareDocumentPaste provideDocumentPasteEdits} may add on copy.
181
+ * Mime types that {@linkcode DocumentPasteEditProvider.prepareDocumentPaste prepareDocumentPaste} may add on copy.
105
182
  */
106
183
  readonly copyMimeTypes?: readonly string[];
107
184
 
108
185
  /**
109
- * Mime types that {@link DocumentPasteEditProvider.provideDocumentPasteEdits provideDocumentPasteEdits} should be invoked for.
186
+ * Mime types that {@linkcode DocumentPasteEditProvider.provideDocumentPasteEdits provideDocumentPasteEdits} should be invoked for.
110
187
  *
111
188
  * This can either be an exact mime type such as `image/png`, or a wildcard pattern such as `image/*`.
112
189
  *
113
190
  * Use `text/uri-list` for resources dropped from the explorer or other tree views in the workbench.
114
191
  *
115
- * Use `files` to indicate that the provider should be invoked if any {@link DataTransferFile files} are present in the {@link DataTransfer}.
116
- * Note that {@link DataTransferFile} entries are only created when dropping content from outside the editor, such as
192
+ * Use `files` to indicate that the provider should be invoked if any {@link DataTransferFile files} are present in the {@linkcode DataTransfer}.
193
+ * Note that {@linkcode DataTransferFile} entries are only created when dropping content from outside the editor, such as
117
194
  * from the operating system.
118
195
  */
119
196
  readonly pasteMimeTypes?: readonly string[];
120
197
  }
121
198
 
122
199
  namespace languages {
200
+ /**
201
+ * Registers a new {@linkcode DocumentPasteEditProvider}.
202
+ *
203
+ * @param selector A selector that defines the documents this provider applies to.
204
+ * @param provider A paste editor provider.
205
+ * @param metadata Additional metadata about the provider.
206
+ *
207
+ * @returns A {@link Disposable} that unregisters this provider when disposed of.
208
+ * @stubbed
209
+ */
123
210
  export function registerDocumentPasteEditProvider(selector: DocumentSelector, provider: DocumentPasteEditProvider, metadata: DocumentPasteProviderMetadata): Disposable;
124
211
  }
125
212
  }
@@ -29,7 +29,16 @@ export module '@theia/plugin' {
29
29
  /**
30
30
  * Human readable label that describes the edit.
31
31
  */
32
- label?: string;
32
+ title?: string;
33
+
34
+ /**
35
+ * {@link DocumentPasteEditKind Kind} of the edit.
36
+ *
37
+ * Used to identify specific types of edits.
38
+ *
39
+ * TODO: use own type?
40
+ */
41
+ kind: DocumentPasteEditKind;
33
42
 
34
43
  /**
35
44
  * The mime type from the {@link DataTransfer} that this edit applies.
@@ -39,21 +48,11 @@ export module '@theia/plugin' {
39
48
  /**
40
49
  * Controls the ordering or multiple paste edits. If this provider yield to edits, it will be shown lower in the list.
41
50
  */
42
- yieldTo?: ReadonlyArray<
43
- | { readonly extensionId: string; readonly providerId: string }
44
- | { readonly mimeType: string }
45
- >;
51
+ yieldTo?: ReadonlyArray<DocumentPasteEditKind>;
46
52
  }
47
53
 
48
54
  export interface DocumentDropEditProviderMetadata {
49
- /**
50
- * Identifies the provider.
51
- *
52
- * This id is used when users configure the default provider for drop.
53
- *
54
- * This id should be unique within the extension but does not need to be unique across extensions.
55
- */
56
- readonly id: string;
55
+ readonly providedDropEditKinds?: readonly DocumentPasteEditKind[];
57
56
 
58
57
  /**
59
58
  * List of data transfer types that the provider supports.
@@ -0,0 +1,59 @@
1
+ // *****************************************************************************
2
+ // Copyright (C) 2024 STMicroelectronics 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
+
22
+ export module '@theia/plugin' {
23
+
24
+ export interface DocumentContextItem {
25
+ readonly uri: Uri;
26
+ readonly version: number;
27
+ readonly ranges: Range[];
28
+ }
29
+
30
+ export interface MappedEditsContext {
31
+ documents: DocumentContextItem[][];
32
+ }
33
+
34
+ /**
35
+ * Interface for providing mapped edits for a given document.
36
+ */
37
+ export interface MappedEditsProvider {
38
+ /**
39
+ * Provide mapped edits for a given document.
40
+ * @param document The document to provide mapped edits for.
41
+ * @param codeBlocks Code blocks that come from an LLM's reply.
42
+ * "Insert at cursor" in the panel chat only sends one edit that the user clicks on, but inline chat can send multiple blocks
43
+ * and let the lang server decide what to do with them.
44
+ * @param context The context for providing mapped edits.
45
+ * @param token A cancellation token.
46
+ * @returns A provider result of text edits.
47
+ */
48
+ provideMappedEdits(
49
+ document: TextDocument,
50
+ codeBlocks: string[],
51
+ context: MappedEditsContext,
52
+ token: CancellationToken
53
+ ): ProviderResult<WorkspaceEdit | null>;
54
+ }
55
+
56
+ export namespace chat {
57
+ export function registerMappedEditsProvider(documentSelector: DocumentSelector, provider: MappedEditsProvider): Disposable;
58
+ }
59
+ }