@theia/plugin 1.31.0-next.33 → 1.31.0-next.34

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.
Files changed (2) hide show
  1. package/package.json +2 -2
  2. package/src/theia.d.ts +583 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theia/plugin",
3
- "version": "1.31.0-next.33+16c88a584",
3
+ "version": "1.31.0-next.34+7e753f459",
4
4
  "description": "Theia - Plugin API",
5
5
  "types": "./src/theia.d.ts",
6
6
  "publishConfig": {
@@ -32,5 +32,5 @@
32
32
  "nyc": {
33
33
  "extends": "../../configs/nyc.json"
34
34
  },
35
- "gitHead": "16c88a584bac37f5cf3cc5eb92ffdaa541bda5be"
35
+ "gitHead": "7e753f459e46a6c25695c9f80647d028c9d44af6"
36
36
  }
package/src/theia.d.ts CHANGED
@@ -12713,6 +12713,589 @@ export module '@theia/plugin' {
12713
12713
  }
12714
12714
  }
12715
12715
 
12716
+ /**
12717
+ * Namespace for testing functionality. Tests are published by registering
12718
+ * {@link TestController} instances, then adding {@link TestItem TestItems}.
12719
+ * Controllers may also describe how to run tests by creating one or more
12720
+ * {@link TestRunProfile} instances.
12721
+ */
12722
+ export namespace tests {
12723
+ /**
12724
+ * Creates a new test controller.
12725
+ *
12726
+ * @param id Identifier for the controller, must be globally unique.
12727
+ * @param label A human-readable label for the controller.
12728
+ * @returns An instance of the {@link TestController}.
12729
+ * @stubbed
12730
+ */
12731
+ export function createTestController(id: string, label: string): TestController;
12732
+ }
12733
+
12734
+ /**
12735
+ * The kind of executions that {@link TestRunProfile TestRunProfiles} control.
12736
+ */
12737
+ export enum TestRunProfileKind {
12738
+ Run = 1,
12739
+ Debug = 2,
12740
+ Coverage = 3,
12741
+ }
12742
+
12743
+ /**
12744
+ * Tags can be associated with {@link TestItem TestItems} and
12745
+ * {@link TestRunProfile TestRunProfiles}. A profile with a tag can only
12746
+ * execute tests that include that tag in their {@link TestItem.tags} array.
12747
+ */
12748
+ export class TestTag {
12749
+ /**
12750
+ * ID of the test tag. `TestTag` instances with the same ID are considered
12751
+ * to be identical.
12752
+ */
12753
+ readonly id: string;
12754
+
12755
+ /**
12756
+ * Creates a new TestTag instance.
12757
+ * @param id ID of the test tag.
12758
+ */
12759
+ constructor(id: string);
12760
+ }
12761
+
12762
+ /**
12763
+ * A TestRunProfile describes one way to execute tests in a {@link TestController}.
12764
+ */
12765
+ export interface TestRunProfile {
12766
+ /**
12767
+ * Label shown to the user in the UI.
12768
+ *
12769
+ * Note that the label has some significance if the user requests that
12770
+ * tests be re-run in a certain way. For example, if tests were run
12771
+ * normally and the user requests to re-run them in debug mode, the editor
12772
+ * will attempt use a configuration with the same label of the `Debug`
12773
+ * kind. If there is no such configuration, the default will be used.
12774
+ * @stubbed
12775
+ */
12776
+ label: string;
12777
+
12778
+ /**
12779
+ * Configures what kind of execution this profile controls. If there
12780
+ * are no profiles for a kind, it will not be available in the UI.
12781
+ * @stubbed
12782
+ */
12783
+ readonly kind: TestRunProfileKind;
12784
+
12785
+ /**
12786
+ * Controls whether this profile is the default action that will
12787
+ * be taken when its kind is actioned. For example, if the user clicks
12788
+ * the generic "run all" button, then the default profile for
12789
+ * {@link TestRunProfileKind.Run} will be executed, although the
12790
+ * user can configure this.
12791
+ * @stubbed
12792
+ */
12793
+ isDefault: boolean;
12794
+
12795
+ /**
12796
+ * Associated tag for the profile. If this is set, only {@link TestItem}
12797
+ * instances with the same tag will be eligible to execute in this profile.
12798
+ * @stubbed
12799
+ */
12800
+ tag: TestTag | undefined;
12801
+
12802
+ /**
12803
+ * If this method is present, a configuration gear will be present in the
12804
+ * UI, and this method will be invoked when it's clicked. When called,
12805
+ * you can take other editor actions, such as showing a quick pick or
12806
+ * opening a configuration file.
12807
+ * @stubbed
12808
+ */
12809
+ configureHandler: (() => void) | undefined;
12810
+
12811
+ /**
12812
+ * Handler called to start a test run. When invoked, the function should call
12813
+ * {@link TestController.createTestRun} at least once, and all test runs
12814
+ * associated with the request should be created before the function returns
12815
+ * or the returned promise is resolved.
12816
+ *
12817
+ * @param request Request information for the test run.
12818
+ * @param cancellationToken Token that signals the used asked to abort the
12819
+ * test run. If cancellation is requested on this token, all {@link TestRun}
12820
+ * instances associated with the request will be
12821
+ * automatically cancelled as well.
12822
+ * @stubbed
12823
+ */
12824
+ runHandler: (request: TestRunRequest, token: CancellationToken) => Thenable<void> | void;
12825
+
12826
+ /**
12827
+ * Deletes the run profile.
12828
+ * @stubbed
12829
+ */
12830
+ dispose(): void;
12831
+ }
12832
+
12833
+ /**
12834
+ * Entry point to discover and execute tests. It contains {@link TestController.items} which
12835
+ * are used to populate the editor UI, and is associated with
12836
+ * {@link TestController.createRunProfile run profiles} to allow
12837
+ * for tests to be executed.
12838
+ */
12839
+ export interface TestController {
12840
+ /**
12841
+ * The id of the controller passed in {@link vscode.tests.createTestController}.
12842
+ * This must be globally unique.
12843
+ * @stubbed
12844
+ */
12845
+ readonly id: string;
12846
+
12847
+ /**
12848
+ * Human-readable label for the test controller.
12849
+ * @stubbed
12850
+ */
12851
+ label: string;
12852
+
12853
+ /**
12854
+ * A collection of "top-level" {@link TestItem} instances, which can in
12855
+ * turn have their own {@link TestItem.children children} to form the
12856
+ * "test tree."
12857
+ *
12858
+ * The extension controls when to add tests. For example, extensions should
12859
+ * add tests for a file when {@link vscode.workspace.onDidOpenTextDocument}
12860
+ * fires in order for decorations for tests within a file to be visible.
12861
+ *
12862
+ * However, the editor may sometimes explicitly request children using the
12863
+ * {@link resolveHandler} See the documentation on that method for more details.
12864
+ * @stubbed
12865
+ */
12866
+ readonly items: TestItemCollection;
12867
+
12868
+ /**
12869
+ * Creates a profile used for running tests. Extensions must create
12870
+ * at least one profile in order for tests to be run.
12871
+ * @param label A human-readable label for this profile.
12872
+ * @param kind Configures what kind of execution this profile manages.
12873
+ * @param runHandler Function called to start a test run.
12874
+ * @param isDefault Whether this is the default action for its kind.
12875
+ * @param tag Profile test tag.
12876
+ * @returns An instance of a {@link TestRunProfile}, which is automatically
12877
+ * associated with this controller.
12878
+ * @stubbed
12879
+ */
12880
+ createRunProfile(label: string, kind: TestRunProfileKind, runHandler: (request: TestRunRequest, token: CancellationToken) => Thenable<void> | void, isDefault?: boolean, tag?: TestTag): TestRunProfile;
12881
+
12882
+ /**
12883
+ * A function provided by the extension that the editor may call to request
12884
+ * children of a test item, if the {@link TestItem.canResolveChildren} is
12885
+ * `true`. When called, the item should discover children and call
12886
+ * {@link vscode.tests.createTestItem} as children are discovered.
12887
+ *
12888
+ * Generally the extension manages the lifecycle of test items, but under
12889
+ * certain conditions the editor may request the children of a specific
12890
+ * item to be loaded. For example, if the user requests to re-run tests
12891
+ * after reloading the editor, the editor may need to call this method
12892
+ * to resolve the previously-run tests.
12893
+ *
12894
+ * The item in the explorer will automatically be marked as "busy" until
12895
+ * the function returns or the returned thenable resolves.
12896
+ *
12897
+ * @param item An unresolved test item for which children are being
12898
+ * requested, or `undefined` to resolve the controller's initial {@link TestController.items items}.
12899
+ * @stubbed
12900
+ */
12901
+ resolveHandler?: (item: TestItem | undefined) => Thenable<void> | void;
12902
+
12903
+ /**
12904
+ * If this method is present, a refresh button will be present in the
12905
+ * UI, and this method will be invoked when it's clicked. When called,
12906
+ * the extension should scan the workspace for any new, changed, or
12907
+ * removed tests.
12908
+ *
12909
+ * It's recommended that extensions try to update tests in realtime, using
12910
+ * a {@link FileSystemWatcher} for example, and use this method as a fallback.
12911
+ *
12912
+ * @returns A thenable that resolves when tests have been refreshed.
12913
+ * @stubbed
12914
+ */
12915
+ refreshHandler: ((token: CancellationToken) => Thenable<void> | void) | undefined;
12916
+
12917
+ /**
12918
+ * Creates a {@link TestRun}. This should be called by the
12919
+ * {@link TestRunProfile} when a request is made to execute tests, and may
12920
+ * also be called if a test run is detected externally. Once created, tests
12921
+ * that are included in the request will be moved into the queued state.
12922
+ *
12923
+ * All runs created using the same `request` instance will be grouped
12924
+ * together. This is useful if, for example, a single suite of tests is
12925
+ * run on multiple platforms.
12926
+ *
12927
+ * @param request Test run request. Only tests inside the `include` may be
12928
+ * modified, and tests in its `exclude` are ignored.
12929
+ * @param name The human-readable name of the run. This can be used to
12930
+ * disambiguate multiple sets of results in a test run. It is useful if
12931
+ * tests are run across multiple platforms, for example.
12932
+ * @param persist Whether the results created by the run should be
12933
+ * persisted in the editor. This may be false if the results are coming from
12934
+ * a file already saved externally, such as a coverage information file.
12935
+ * @returns An instance of the {@link TestRun}. It will be considered "running"
12936
+ * from the moment this method is invoked until {@link TestRun.end} is called.
12937
+ * @stubbed
12938
+ */
12939
+ createTestRun(request: TestRunRequest, name?: string, persist?: boolean): TestRun;
12940
+
12941
+ /**
12942
+ * Creates a new managed {@link TestItem} instance. It can be added into
12943
+ * the {@link TestItem.children} of an existing item, or into the
12944
+ * {@link TestController.items}.
12945
+ *
12946
+ * @param id Identifier for the TestItem. The test item's ID must be unique
12947
+ * in the {@link TestItemCollection} it's added to.
12948
+ * @param label Human-readable label of the test item.
12949
+ * @param uri URI this TestItem is associated with. May be a file or directory.
12950
+ * @stubbed
12951
+ */
12952
+ createTestItem(id: string, label: string, uri?: Uri): TestItem;
12953
+
12954
+ /**
12955
+ * Unregisters the test controller, disposing of its associated tests
12956
+ * and unpersisted results.
12957
+ * @stubbed
12958
+ */
12959
+ dispose(): void;
12960
+ }
12961
+
12962
+ /**
12963
+ * A TestRunRequest is a precursor to a {@link TestRun}, which in turn is
12964
+ * created by passing a request to {@link tests.runTests}. The TestRunRequest
12965
+ * contains information about which tests should be run, which should not be
12966
+ * run, and how they are run (via the {@link TestRunRequest.profile profile}).
12967
+ *
12968
+ * In general, TestRunRequests are created by the editor and pass to
12969
+ * {@link TestRunProfile.runHandler}, however you can also create test
12970
+ * requests and runs outside of the `runHandler`.
12971
+ */
12972
+ export class TestRunRequest {
12973
+ /**
12974
+ * A filter for specific tests to run. If given, the extension should run
12975
+ * all of the included tests and all their children, excluding any tests
12976
+ * that appear in {@link TestRunRequest.exclude}. If this property is
12977
+ * undefined, then the extension should simply run all tests.
12978
+ *
12979
+ * The process of running tests should resolve the children of any test
12980
+ * items who have not yet been resolved.
12981
+ */
12982
+ readonly include: readonly TestItem[] | undefined;
12983
+
12984
+ /**
12985
+ * An array of tests the user has marked as excluded from the test included
12986
+ * in this run; exclusions should apply after inclusions.
12987
+ *
12988
+ * May be omitted if no exclusions were requested. Test controllers should
12989
+ * not run excluded tests or any children of excluded tests.
12990
+ */
12991
+ readonly exclude: readonly TestItem[] | undefined;
12992
+
12993
+ /**
12994
+ * The profile used for this request. This will always be defined
12995
+ * for requests issued from the editor UI, though extensions may
12996
+ * programmatically create requests not associated with any profile.
12997
+ */
12998
+ readonly profile: TestRunProfile | undefined;
12999
+
13000
+ /**
13001
+ * @param include Array of specific tests to run, or undefined to run all tests
13002
+ * @param exclude An array of tests to exclude from the run.
13003
+ * @param profile The run profile used for this request.
13004
+ */
13005
+ constructor(include?: readonly TestItem[], exclude?: readonly TestItem[], profile?: TestRunProfile);
13006
+ }
13007
+
13008
+ /**
13009
+ * Options given to {@link TestController.runTests}
13010
+ */
13011
+ export interface TestRun {
13012
+ /**
13013
+ * The human-readable name of the run. This can be used to
13014
+ * disambiguate multiple sets of results in a test run. It is useful if
13015
+ * tests are run across multiple platforms, for example.
13016
+ * @stubbed
13017
+ */
13018
+ readonly name: string | undefined;
13019
+
13020
+ /**
13021
+ * A cancellation token which will be triggered when the test run is
13022
+ * canceled from the UI.
13023
+ * @stubbed
13024
+ */
13025
+ readonly token: CancellationToken;
13026
+
13027
+ /**
13028
+ * Whether the test run will be persisted across reloads by the editor.
13029
+ * @stubbed
13030
+ */
13031
+ readonly isPersisted: boolean;
13032
+
13033
+ /**
13034
+ * Indicates a test is queued for later execution.
13035
+ * @param test Test item to update.
13036
+ * @stubbed
13037
+ */
13038
+ enqueued(test: TestItem): void;
13039
+
13040
+ /**
13041
+ * Indicates a test has started running.
13042
+ * @param test Test item to update.
13043
+ * @stubbed
13044
+ */
13045
+ started(test: TestItem): void;
13046
+
13047
+ /**
13048
+ * Indicates a test has been skipped.
13049
+ * @param test Test item to update.
13050
+ * @stubbed
13051
+ */
13052
+ skipped(test: TestItem): void;
13053
+
13054
+ /**
13055
+ * Indicates a test has failed. You should pass one or more
13056
+ * {@link TestMessage TestMessages} to describe the failure.
13057
+ * @param test Test item to update.
13058
+ * @param message Messages associated with the test failure.
13059
+ * @param duration How long the test took to execute, in milliseconds.
13060
+ * @stubbed
13061
+ */
13062
+ failed(test: TestItem, message: TestMessage | readonly TestMessage[], duration?: number): void;
13063
+
13064
+ /**
13065
+ * Indicates a test has errored. You should pass one or more
13066
+ * {@link TestMessage TestMessages} to describe the failure. This differs
13067
+ * from the "failed" state in that it indicates a test that couldn't be
13068
+ * executed at all, from a compilation error for example.
13069
+ * @param test Test item to update.
13070
+ * @param message Messages associated with the test failure.
13071
+ * @param duration How long the test took to execute, in milliseconds.
13072
+ * @stubbed
13073
+ */
13074
+ errored(test: TestItem, message: TestMessage | readonly TestMessage[], duration?: number): void;
13075
+
13076
+ /**
13077
+ * Indicates a test has passed.
13078
+ * @param test Test item to update.
13079
+ * @param duration How long the test took to execute, in milliseconds.
13080
+ * @stubbed
13081
+ */
13082
+ passed(test: TestItem, duration?: number): void;
13083
+
13084
+ /**
13085
+ * Appends raw output from the test runner. On the user's request, the
13086
+ * output will be displayed in a terminal. ANSI escape sequences,
13087
+ * such as colors and text styles, are supported.
13088
+ *
13089
+ * @param output Output text to append.
13090
+ * @param location Indicate that the output was logged at the given
13091
+ * location.
13092
+ * @param test Test item to associate the output with.
13093
+ * @stubbed
13094
+ */
13095
+ appendOutput(output: string, location?: Location, test?: TestItem): void;
13096
+
13097
+ /**
13098
+ * Signals that the end of the test run. Any tests included in the run whose
13099
+ * states have not been updated will have their state reset.
13100
+ * @stubbed
13101
+ */
13102
+ end(): void;
13103
+ }
13104
+
13105
+ /**
13106
+ * Collection of test items, found in {@link TestItem.children} and
13107
+ * {@link TestController.items}.
13108
+ */
13109
+ export interface TestItemCollection extends Iterable<[id: string, testItem: TestItem]> {
13110
+ /**
13111
+ * Gets the number of items in the collection.
13112
+ * @stubbed
13113
+ */
13114
+ readonly size: number;
13115
+
13116
+ /**
13117
+ * Replaces the items stored by the collection.
13118
+ * @param items Items to store.
13119
+ * @stubbed
13120
+ */
13121
+ replace(items: readonly TestItem[]): void;
13122
+
13123
+ /**
13124
+ * Iterate over each entry in this collection.
13125
+ *
13126
+ * @param callback Function to execute for each entry.
13127
+ * @param thisArg The `this` context used when invoking the handler function.
13128
+ * @stubbed
13129
+ */
13130
+ forEach(callback: (item: TestItem, collection: TestItemCollection) => unknown, thisArg?: any): void;
13131
+
13132
+ /**
13133
+ * Adds the test item to the children. If an item with the same ID already
13134
+ * exists, it'll be replaced.
13135
+ * @param item Item to add.
13136
+ * @stubbed
13137
+ */
13138
+ add(item: TestItem): void;
13139
+
13140
+ /**
13141
+ * Removes a single test item from the collection.
13142
+ * @param itemId Item ID to delete.
13143
+ * @stubbed
13144
+ */
13145
+ delete(itemId: string): void;
13146
+
13147
+ /**
13148
+ * Efficiently gets a test item by ID, if it exists, in the children.
13149
+ * @param itemId Item ID to get.
13150
+ * @returns The found item or undefined if it does not exist.
13151
+ * @stubbed
13152
+ */
13153
+ get(itemId: string): TestItem | undefined;
13154
+ }
13155
+
13156
+ /**
13157
+ * An item shown in the "test explorer" view.
13158
+ *
13159
+ * A `TestItem` can represent either a test suite or a test itself, since
13160
+ * they both have similar capabilities.
13161
+ */
13162
+ export interface TestItem {
13163
+ /**
13164
+ * Identifier for the `TestItem`. This is used to correlate
13165
+ * test results and tests in the document with those in the workspace
13166
+ * (test explorer). This cannot change for the lifetime of the `TestItem`,
13167
+ * and must be unique among its parent's direct children.
13168
+ * @stubbed
13169
+ */
13170
+ readonly id: string;
13171
+
13172
+ /**
13173
+ * URI this `TestItem` is associated with. May be a file or directory.
13174
+ * @stubbed
13175
+ */
13176
+ readonly uri: Uri | undefined;
13177
+
13178
+ /**
13179
+ * The children of this test item. For a test suite, this may contain the
13180
+ * individual test cases or nested suites.
13181
+ * @stubbed
13182
+ */
13183
+ readonly children: TestItemCollection;
13184
+
13185
+ /**
13186
+ * The parent of this item. It's set automatically, and is undefined
13187
+ * top-level items in the {@link TestController.items} and for items that
13188
+ * aren't yet included in another item's {@link TestItem.children children}.
13189
+ * @stubbed
13190
+ */
13191
+ readonly parent: TestItem | undefined;
13192
+
13193
+ /**
13194
+ * Tags associated with this test item. May be used in combination with
13195
+ * {@link TestRunProfile.tags}, or simply as an organizational feature.
13196
+ * @stubbed
13197
+ */
13198
+ tags: readonly TestTag[];
13199
+
13200
+ /**
13201
+ * Indicates whether this test item may have children discovered by resolving.
13202
+ *
13203
+ * If true, this item is shown as expandable in the Test Explorer view and
13204
+ * expanding the item will cause {@link TestController.resolveHandler}
13205
+ * to be invoked with the item.
13206
+ *
13207
+ * Default to `false`.
13208
+ * @stubbed
13209
+ */
13210
+ canResolveChildren: boolean;
13211
+
13212
+ /**
13213
+ * Controls whether the item is shown as "busy" in the Test Explorer view.
13214
+ * This is useful for showing status while discovering children.
13215
+ *
13216
+ * Defaults to `false`.
13217
+ * @stubbed
13218
+ */
13219
+ busy: boolean;
13220
+
13221
+ /**
13222
+ * Display name describing the test case.
13223
+ * @stubbed
13224
+ */
13225
+ label: string;
13226
+
13227
+ /**
13228
+ * Optional description that appears next to the label.
13229
+ * @stubbed
13230
+ */
13231
+ description?: string;
13232
+
13233
+ /**
13234
+ * A string that should be used when comparing this item
13235
+ * with other items. When `falsy` the {@link TestItem.label label}
13236
+ * is used.
13237
+ * @stubbed
13238
+ */
13239
+ sortText?: string | undefined;
13240
+
13241
+ /**
13242
+ * Location of the test item in its {@link TestItem.uri uri}.
13243
+ *
13244
+ * This is only meaningful if the `uri` points to a file.
13245
+ * @stubbed
13246
+ */
13247
+ range: Range | undefined;
13248
+
13249
+ /**
13250
+ * Optional error encountered while loading the test.
13251
+ *
13252
+ * Note that this is not a test result and should only be used to represent errors in
13253
+ * test discovery, such as syntax errors.
13254
+ * @stubbed
13255
+ */
13256
+ error: string | MarkdownString | undefined;
13257
+ }
13258
+
13259
+ /**
13260
+ * Message associated with the test state. Can be linked to a specific
13261
+ * source range -- useful for assertion failures, for example.
13262
+ */
13263
+ export class TestMessage {
13264
+ /**
13265
+ * Human-readable message text to display.
13266
+ */
13267
+ message: string | MarkdownString;
13268
+
13269
+ /**
13270
+ * Expected test output. If given with {@link TestMessage.actualOutput actualOutput }, a diff view will be shown.
13271
+ */
13272
+ expectedOutput?: string;
13273
+
13274
+ /**
13275
+ * Actual test output. If given with {@link TestMessage.expectedOutput expectedOutput }, a diff view will be shown.
13276
+ */
13277
+ actualOutput?: string;
13278
+
13279
+ /**
13280
+ * Associated file location.
13281
+ */
13282
+ location?: Location;
13283
+
13284
+ /**
13285
+ * Creates a new TestMessage that will present as a diff in the editor.
13286
+ * @param message Message to display to the user.
13287
+ * @param expected Expected output.
13288
+ * @param actual Actual output.
13289
+ */
13290
+ static diff(message: string | MarkdownString, expected: string, actual: string): TestMessage;
13291
+
13292
+ /**
13293
+ * Creates a new TestMessage instance.
13294
+ * @param message The message to show to the user.
13295
+ */
13296
+ constructor(message: string | MarkdownString);
13297
+ }
13298
+
12716
13299
  /**
12717
13300
  * Thenable is a common denominator between ES6 promises, Q, jquery.Deferred, WinJS.Promise,
12718
13301
  * and others. This API makes no assumption about what promise library is being used which