Skip to content

Commit 6194c81

Browse files
committed
Implement ProjectController as Disposable
1 parent 5c4660a commit 6194c81

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

src/controllers/projectController.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,20 @@
33

44
import * as fse from "fs-extra";
55
import * as path from "path";
6-
import { commands, ExtensionContext, Uri, window, workspace } from "vscode";
6+
import { commands, Disposable, ExtensionContext, Uri, window } from "vscode";
7+
import { instrumentOperation } from "vscode-extension-telemetry-wrapper";
78
import * as xml2js from "xml2js";
9+
import { Commands } from "../commands";
810
import { Utility } from "../utility";
911

10-
export class ProjectController {
11-
constructor(public readonly context: ExtensionContext) {
12+
export class ProjectController implements Disposable {
13+
public constructor(public readonly context: ExtensionContext) {
14+
context.subscriptions.push(commands.registerCommand(Commands.JAVA_PROJECT_CREATE,
15+
instrumentOperation(Commands.JAVA_PROJECT_CREATE, () => this.createJavaProject())));
1216
}
1317

18+
public dispose() {}
19+
1420
public async createJavaProject() {
1521
const javaVersion: number = await this.getJavaVersion();
1622
if (!javaVersion) {

src/extension.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,7 @@ function activateExtension(operationId: string, context: ExtensionContext) {
2020
Services.initialize(context);
2121
Settings.initialize(context);
2222

23-
const projectController: ProjectController = new ProjectController(context);
24-
const instrumented = instrumentOperation(Commands.JAVA_PROJECT_CREATE, () => projectController.createJavaProject());
25-
context.subscriptions.push(commands.registerCommand(Commands.JAVA_PROJECT_CREATE, instrumented));
26-
23+
context.subscriptions.push(new ProjectController(context));
2724
context.subscriptions.push(new DependencyExplorer(context));
2825
}
2926

0 commit comments

Comments
 (0)