All files / views/trees/workspace-tree workspace-tree.ts

100% Statements 8/8
50% Branches 1/2
100% Functions 2/2
100% Lines 8/8

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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                    5x         5x               5x         5x   5x     1x         5x 5x    
import * as vscode from 'vscode';
import { container } from 'tsyringe';
import { ServiceToken } from '@src/services/tokens';
import { TreeView } from '@src/views/trees/tree-view';
import { WorkspaceNodeProvider } from './workspace-node-provider';
 
export class WorkspaceTree implements TreeView {
	/**
	 * The ID which is used to register the view and make it visible in VS Code.
	 */
	readonly id = "mentor.view.workspaceTree";
 
	/**
	 * The tree node provider.
	 */
	readonly treeDataProvider = new WorkspaceNodeProvider();
 
	/**
	 * The tree view.
	 */
	readonly treeView: vscode.TreeView<string>;
 
	constructor() {
		this.treeView = vscode.window.createTreeView(this.id, {
			treeDataProvider: this.treeDataProvider,
			showCollapseAll: true
		});
 
		this.treeView.title = vscode.workspace.name ?? "Workspace";
 
		const disposables = [
			this.treeView,
			vscode.commands.registerCommand('mentor.command.refreshWorkspaceTree', async () => {
				this.treeDataProvider.refresh();
			})
		];
 
		// Self-register with the extension context for automatic disposal
		const context = container.resolve<vscode.ExtensionContext>(ServiceToken.ExtensionContext);
		context.subscriptions.push(...disposables);
	}
}