Files
vscode/src/vscode-dts/vscode.proposed.testRelatedCode.d.ts
Connor Peet 642700c7ef testing: implement related code (#222252)
* wip

* testing: implement related code

This implements a simple provider-based related code feature, and
adopts it in the selfhost test extension.

It's surfaced to users via automatic delegation in the "run tests at
cursor" command, which I feel like it very natural. I also add two
commands which reuse the `SymbolNavigationAction` to implement
go to/peek views using the references infrastructure. The upstream
change involved in this is the addition of the "go to" preference
for tests.

cc @jrieken @mjbvz

* bump distro for API enablement
2024-07-22 10:52:40 -07:00

37 lines
1.4 KiB
TypeScript

/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
declare module 'vscode' {
export interface TestController {
/**
* A provider used for associating code location with tests.
*/
relatedCodeProvider?: TestRelatedCodeProvider;
}
export interface TestRelatedCodeProvider {
/**
* Returns the tests related to the given code location. This may be called
* by the user either explicitly via a "go to test" action, or implicitly
* when running tests at a cursor position.
*
* @param document The document in which the code location is located.
* @param position The position in the document.
* @param token A cancellation token.
* @returns A list of tests related to the position in the code.
*/
provideRelatedTests?(document: TextDocument, position: Position, token: CancellationToken): ProviderResult<TestItem[]>;
/**
* Returns the code related to the given test case.
*
* @param test The test for which to provide related code.
* @param token A cancellation token.
* @returns A list of locations related to the test.
*/
provideRelatedCode?(test: TestItem, token: CancellationToken): ProviderResult<Location[]>;
}
}