|
4 | 4 | *--------------------------------------------------------------------------------------------*/
|
5 | 5 | import * as editorRange from 'vs/editor/common/core/range';
|
6 | 6 | import { createPrivateApiFor, getPrivateApiFor, IExtHostTestItemApi } from 'vs/workbench/api/common/extHostTestingPrivateApi';
|
7 |
| -import { TestIdPathParts } from 'vs/workbench/contrib/testing/common/testId'; |
| 7 | +import { TestId, TestIdPathParts } from 'vs/workbench/contrib/testing/common/testId'; |
8 | 8 | import { createTestItemChildren, ExtHostTestItemEvent, ITestChildrenLike, ITestItemApi, ITestItemChildren, TestItemCollection, TestItemEventOp } from 'vs/workbench/contrib/testing/common/testItemCollection';
|
9 |
| -import { ITestItem } from 'vs/workbench/contrib/testing/common/testTypes'; |
| 9 | +import { denamespaceTestTag, ITestItem, ITestItemContext } from 'vs/workbench/contrib/testing/common/testTypes'; |
10 | 10 | import type * as vscode from 'vscode';
|
11 | 11 | import * as Convert from 'vs/workbench/api/common/extHostTypeConverters';
|
| 12 | +import { URI } from 'vs/base/common/uri'; |
12 | 13 |
|
13 | 14 | const testItemPropAccessor = <K extends keyof vscode.TestItem>(
|
14 | 15 | api: IExtHostTestItemApi,
|
@@ -83,6 +84,27 @@ const makePropDescriptors = (api: IExtHostTestItemApi, label: string): { [K in k
|
83 | 84 | })),
|
84 | 85 | });
|
85 | 86 |
|
| 87 | +const toItemFromPlain = (item: ITestItem.Serialized): TestItemImpl => { |
| 88 | + const testId = TestId.fromString(item.extId); |
| 89 | + const testItem = new TestItemImpl(testId.controllerId, testId.localId, item.label, URI.revive(item.uri) || undefined); |
| 90 | + testItem.range = Convert.Range.to(item.range || undefined); |
| 91 | + testItem.description = item.description || undefined; |
| 92 | + testItem.sortText = item.sortText || undefined; |
| 93 | + testItem.tags = item.tags.map(t => Convert.TestTag.to({ id: denamespaceTestTag(t).tagId })); |
| 94 | + return testItem; |
| 95 | +}; |
| 96 | + |
| 97 | +export const toItemFromContext = (context: ITestItemContext): TestItemImpl => { |
| 98 | + let node: TestItemImpl | undefined; |
| 99 | + for (const test of context.tests) { |
| 100 | + const next = toItemFromPlain(test.item); |
| 101 | + getPrivateApiFor(next).parent = node; |
| 102 | + node = next; |
| 103 | + } |
| 104 | + |
| 105 | + return node!; |
| 106 | +}; |
| 107 | + |
86 | 108 | export class TestItemImpl implements vscode.TestItem {
|
87 | 109 | public readonly id!: string;
|
88 | 110 | public readonly uri!: vscode.Uri | undefined;
|
|
0 commit comments