forked from microsoft/vscode-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommandHandler.ts
More file actions
56 lines (53 loc) · 2.15 KB
/
commandHandler.ts
File metadata and controls
56 lines (53 loc) · 2.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
'use strict';
import { inject, injectable, named } from 'inversify';
import { ICommandManager } from '../../common/application/types';
import { Commands } from '../../common/constants';
import { IDisposable, IDisposableRegistry } from '../../common/types';
import { ITestCodeNavigator, ITestCodeNavigatorCommandHandler, NavigableItemType } from './types';
@injectable()
export class TestCodeNavigatorCommandHandler implements ITestCodeNavigatorCommandHandler {
private disposables: IDisposable[] = [];
constructor(
@inject(ICommandManager) private readonly commandManager: ICommandManager,
@inject(ITestCodeNavigator)
@named(NavigableItemType.testFile)
private readonly testFileNavigator: ITestCodeNavigator,
@inject(ITestCodeNavigator)
@named(NavigableItemType.testFunction)
private readonly testFunctionNavigator: ITestCodeNavigator,
@inject(ITestCodeNavigator)
@named(NavigableItemType.testSuite)
private readonly testSuiteNavigator: ITestCodeNavigator,
@inject(IDisposableRegistry) disposableRegistry: IDisposableRegistry
) {
disposableRegistry.push(this);
}
public dispose() {
this.disposables.forEach((item) => item.dispose());
}
public register(): void {
if (this.disposables.length > 0) {
return;
}
let disposable = this.commandManager.registerCommand(
Commands.navigateToTestFile,
this.testFileNavigator.navigateTo,
this.testFileNavigator
);
this.disposables.push(disposable);
disposable = this.commandManager.registerCommand(
Commands.navigateToTestFunction,
this.testFunctionNavigator.navigateTo,
this.testFunctionNavigator
);
this.disposables.push(disposable);
disposable = this.commandManager.registerCommand(
Commands.navigateToTestSuite,
this.testSuiteNavigator.navigateTo,
this.testSuiteNavigator
);
this.disposables.push(disposable);
}
}