mirror of
https://github.com/microsoft/vscode-extension-samples.git
synced 2026-04-27 16:55:44 +08:00
24 lines
939 B
TypeScript
24 lines
939 B
TypeScript
'use strict';
|
|
|
|
import * as vscode from 'vscode';
|
|
|
|
import { DepNodeProvider } from './nodeDependencies'
|
|
import { JsonOutlineProvider } from './jsonOutline'
|
|
|
|
export function activate(context: vscode.ExtensionContext) {
|
|
const rootPath = vscode.workspace.rootPath;
|
|
const jsonOutlineProvider = new JsonOutlineProvider(context);
|
|
|
|
// The `providerId` here must be identical to `contributes.explorer.treeExplorerNodeProviderId` in package.json.
|
|
vscode.window.registerTreeDataProvider('nodeDependencies', new DepNodeProvider(rootPath));
|
|
vscode.window.registerTreeDataProvider('jsonOutline', jsonOutlineProvider);
|
|
|
|
vscode.commands.registerCommand('extension.openPackageOnNpm', (node: vscode.TreeItem) => {
|
|
vscode.commands.executeCommand('vscode.open', vscode.Uri.parse(`https://www.npmjs.com/package/${node.label}`));
|
|
});
|
|
|
|
vscode.commands.registerCommand('extension.openJsonSelection', node => {
|
|
jsonOutlineProvider.select(node);
|
|
});
|
|
}
|