@theia/plugin 1.48.2 → 1.49.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.48.2",
3
+ "version": "1.49.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.48.2"
30
+ "@theia/ext-scripts": "1.49.0"
31
31
  },
32
32
  "nyc": {
33
33
  "extends": "../../configs/nyc.json"
34
34
  },
35
- "gitHead": "0e9583d043dde303de7a0f86f68439659f8827b0"
35
+ "gitHead": "d413dadd87a70fce1c80df7eb22d9d2529cc129f"
36
36
  }
package/src/theia.d.ts CHANGED
@@ -16035,6 +16035,18 @@ export module '@theia/plugin' {
16035
16035
  */
16036
16036
  runHandler: (request: TestRunRequest, token: CancellationToken) => Thenable<void> | void;
16037
16037
 
16038
+ /**
16039
+ * An extension-provided function that provides detailed statement and
16040
+ * function-level coverage for a file. The editor will call this when more
16041
+ * detail is needed for a file, such as when it's opened in an editor or
16042
+ * expanded in the **Test Coverage** view.
16043
+ *
16044
+ * The {@link FileCoverage} object passed to this function is the same instance
16045
+ * emitted on {@link TestRun.addCoverage} calls associated with this profile.
16046
+ * @stubbed
16047
+ */
16048
+ loadDetailedCoverage?: (testRun: TestRun, fileCoverage: FileCoverage, token: CancellationToken) => Thenable<FileCoverageDetail[]>;
16049
+
16038
16050
  /**
16039
16051
  * Deletes the run profile.
16040
16052
  */
@@ -16314,11 +16326,23 @@ export module '@theia/plugin' {
16314
16326
  */
16315
16327
  appendOutput(output: string, location?: Location, test?: TestItem): void;
16316
16328
 
16329
+ /**
16330
+ * Adds coverage for a file in the run.
16331
+ * @stubbed
16332
+ */
16333
+ addCoverage(fileCoverage: FileCoverage): void;
16334
+
16317
16335
  /**
16318
16336
  * Signals the end of the test run. Any tests included in the run whose
16319
16337
  * states have not been updated will have their state reset.
16320
16338
  */
16321
16339
  end(): void;
16340
+
16341
+ /**
16342
+ * An event fired when the editor is no longer interested in data
16343
+ * associated with the test run.
16344
+ */
16345
+ onDidDispose: Event<void>;
16322
16346
  }
16323
16347
 
16324
16348
  /**
@@ -16527,6 +16551,178 @@ export module '@theia/plugin' {
16527
16551
  */
16528
16552
  constructor(message: string | MarkdownString);
16529
16553
  }
16554
+
16555
+ /**
16556
+ * A class that contains information about a covered resource. A count can
16557
+ * be give for lines, branches, and declarations in a file.
16558
+ */
16559
+ export class TestCoverageCount {
16560
+ /**
16561
+ * Number of items covered in the file.
16562
+ */
16563
+ covered: number;
16564
+ /**
16565
+ * Total number of covered items in the file.
16566
+ */
16567
+ total: number;
16568
+
16569
+ /**
16570
+ * @param covered Value for {@link TestCoverageCount.covered}
16571
+ * @param total Value for {@link TestCoverageCount.total}
16572
+ */
16573
+ constructor(covered: number, total: number);
16574
+ }
16575
+
16576
+ /**
16577
+ * Contains coverage metadata for a file.
16578
+ */
16579
+ export class FileCoverage {
16580
+ /**
16581
+ * File URI.
16582
+ */
16583
+ readonly uri: Uri;
16584
+
16585
+ /**
16586
+ * Statement coverage information. If the reporter does not provide statement
16587
+ * coverage information, this can instead be used to represent line coverage.
16588
+ */
16589
+ statementCoverage: TestCoverageCount;
16590
+
16591
+ /**
16592
+ * Branch coverage information.
16593
+ */
16594
+ branchCoverage?: TestCoverageCount;
16595
+
16596
+ /**
16597
+ * Declaration coverage information. Depending on the reporter and
16598
+ * language, this may be types such as functions, methods, or namespaces.
16599
+ */
16600
+ declarationCoverage?: TestCoverageCount;
16601
+
16602
+ /**
16603
+ * Creates a {@link FileCoverage} instance with counts filled in from
16604
+ * the coverage details.
16605
+ * @param uri Covered file URI
16606
+ * @param detailed Detailed coverage information
16607
+ */
16608
+ static fromDetails(uri: Uri, details: readonly FileCoverageDetail[]): FileCoverage;
16609
+
16610
+ /**
16611
+ * @param uri Covered file URI
16612
+ * @param statementCoverage Statement coverage information. If the reporter
16613
+ * does not provide statement coverage information, this can instead be
16614
+ * used to represent line coverage.
16615
+ * @param branchCoverage Branch coverage information
16616
+ * @param declarationCoverage Declaration coverage information
16617
+ */
16618
+ constructor(
16619
+ uri: Uri,
16620
+ statementCoverage: TestCoverageCount,
16621
+ branchCoverage?: TestCoverageCount,
16622
+ declarationCoverage?: TestCoverageCount,
16623
+ );
16624
+ }
16625
+
16626
+ /**
16627
+ * Contains coverage information for a single statement or line.
16628
+ */
16629
+ export class StatementCoverage {
16630
+ /**
16631
+ * The number of times this statement was executed, or a boolean indicating
16632
+ * whether it was executed if the exact count is unknown. If zero or false,
16633
+ * the statement will be marked as un-covered.
16634
+ */
16635
+ executed: number | boolean;
16636
+
16637
+ /**
16638
+ * Statement location.
16639
+ */
16640
+ location: Position | Range;
16641
+
16642
+ /**
16643
+ * Coverage from branches of this line or statement. If it's not a
16644
+ * conditional, this will be empty.
16645
+ */
16646
+ branches: BranchCoverage[];
16647
+
16648
+ /**
16649
+ * @param location The statement position.
16650
+ * @param executed The number of times this statement was executed, or a
16651
+ * boolean indicating whether it was executed if the exact count is
16652
+ * unknown. If zero or false, the statement will be marked as un-covered.
16653
+ * @param branches Coverage from branches of this line. If it's not a
16654
+ * conditional, this should be omitted.
16655
+ */
16656
+ constructor(executed: number | boolean, location: Position | Range, branches?: BranchCoverage[]);
16657
+ }
16658
+
16659
+ /**
16660
+ * Contains coverage information for a branch of a {@link StatementCoverage}.
16661
+ */
16662
+ export class BranchCoverage {
16663
+ /**
16664
+ * The number of times this branch was executed, or a boolean indicating
16665
+ * whether it was executed if the exact count is unknown. If zero or false,
16666
+ * the branch will be marked as un-covered.
16667
+ */
16668
+ executed: number | boolean;
16669
+
16670
+ /**
16671
+ * Branch location.
16672
+ */
16673
+ location?: Position | Range;
16674
+
16675
+ /**
16676
+ * Label for the branch, used in the context of "the ${label} branch was
16677
+ * not taken," for example.
16678
+ */
16679
+ label?: string;
16680
+
16681
+ /**
16682
+ * @param executed The number of times this branch was executed, or a
16683
+ * boolean indicating whether it was executed if the exact count is
16684
+ * unknown. If zero or false, the branch will be marked as un-covered.
16685
+ * @param location The branch position.
16686
+ */
16687
+ constructor(executed: number | boolean, location?: Position | Range, label?: string);
16688
+ }
16689
+
16690
+ /**
16691
+ * Contains coverage information for a declaration. Depending on the reporter
16692
+ * and language, this may be types such as functions, methods, or namespaces.
16693
+ */
16694
+ export class DeclarationCoverage {
16695
+ /**
16696
+ * Name of the declaration.
16697
+ */
16698
+ name: string;
16699
+
16700
+ /**
16701
+ * The number of times this declaration was executed, or a boolean
16702
+ * indicating whether it was executed if the exact count is unknown. If
16703
+ * zero or false, the declaration will be marked as un-covered.
16704
+ */
16705
+ executed: number | boolean;
16706
+
16707
+ /**
16708
+ * Declaration location.
16709
+ */
16710
+ location: Position | Range;
16711
+
16712
+ /**
16713
+ * @param executed The number of times this declaration was executed, or a
16714
+ * boolean indicating whether it was executed if the exact count is
16715
+ * unknown. If zero or false, the declaration will be marked as un-covered.
16716
+ * @param location The declaration position.
16717
+ */
16718
+ constructor(name: string, executed: number | boolean, location: Position | Range);
16719
+ }
16720
+
16721
+ /**
16722
+ * Coverage details returned from {@link TestRunProfile.loadDetailedCoverage}.
16723
+ */
16724
+ export type FileCoverageDetail = StatementCoverage | DeclarationCoverage;
16725
+
16530
16726
  /**
16531
16727
  * Thenable is a common denominator between ES6 promises, Q, jquery.Deferred, WinJS.Promise,
16532
16728
  * 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.