mirror of
https://github.com/microsoft/vscode-extension-samples.git
synced 2026-06-13 07:10:26 +08:00
Adopt to api changes
This commit is contained in:
@ -10,8 +10,8 @@ export function activate(context: vscode.ExtensionContext) {
|
||||
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.window.registerTreeDataProviderForView('nodeDependencies', new DepNodeProvider(rootPath));
|
||||
vscode.window.registerTreeDataProviderForView('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}`));
|
||||
|
||||
@ -4,8 +4,8 @@ import * as path from 'path';
|
||||
|
||||
export class JsonOutlineProvider implements vscode.TreeDataProvider<json.Node> {
|
||||
|
||||
private _onDidChange: vscode.EventEmitter<json.Node | null> = new vscode.EventEmitter<json.Node | null>();
|
||||
readonly onDidChange: vscode.Event<json.Node | null> = this._onDidChange.event;
|
||||
private _onDidChangeTreeData: vscode.EventEmitter<json.Node | null> = new vscode.EventEmitter<json.Node | null>();
|
||||
readonly onDidChangeTreeData: vscode.Event<json.Node | null> = this._onDidChangeTreeData.event;
|
||||
|
||||
private tree: json.Node;
|
||||
private editor: vscode.TextEditor;
|
||||
@ -13,7 +13,7 @@ export class JsonOutlineProvider implements vscode.TreeDataProvider<json.Node> {
|
||||
constructor(private context: vscode.ExtensionContext) {
|
||||
vscode.window.onDidChangeActiveTextEditor(editor => {
|
||||
this.parseTree();
|
||||
this._onDidChange.fire();
|
||||
this._onDidChangeTreeData.fire();
|
||||
});
|
||||
this.parseTree();
|
||||
}
|
||||
|
||||
@ -15,10 +15,10 @@ declare module 'vscode' {
|
||||
export namespace window {
|
||||
/**
|
||||
* Register a [TreeDataProvider](#TreeDataProvider) for the registered view `id`.
|
||||
* @param id View id.
|
||||
* @param viewId View id.
|
||||
* @param treeDataProvider A [TreeDataProvider](#TreeDataProvider) that provides tree data for the view
|
||||
*/
|
||||
export function registerTreeDataProvider<T>(id: string, treeDataProvider: TreeDataProvider<T>): Disposable;
|
||||
export function registerTreeDataProviderForView<T>(viewId: string, treeDataProvider: TreeDataProvider<T>): Disposable;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -28,7 +28,7 @@ declare module 'vscode' {
|
||||
/**
|
||||
* An optional event to signal that an element or root has changed.
|
||||
*/
|
||||
onDidChange?: Event<T | undefined | null>;
|
||||
onDidChangeTreeData?: Event<T | undefined | null>;
|
||||
|
||||
/**
|
||||
* get [TreeItem](#TreeItem) representation of the `element`
|
||||
@ -51,29 +51,29 @@ declare module 'vscode' {
|
||||
/**
|
||||
* Label of the tree item
|
||||
*/
|
||||
label: string;
|
||||
readonly label: string;
|
||||
|
||||
/**
|
||||
* The icon path for the tree item
|
||||
*/
|
||||
iconPath?: string | Uri | { light: string | Uri; dark: string | Uri };
|
||||
readonly iconPath?: string | Uri | { light: string | Uri; dark: string | Uri };
|
||||
|
||||
/**
|
||||
* The [command](#Command) which should be run when the tree item
|
||||
* is open in the Source Control viewlet.
|
||||
*/
|
||||
command?: Command;
|
||||
readonly command?: Command;
|
||||
|
||||
/**
|
||||
* Context value of the tree node
|
||||
*/
|
||||
contextValue?: string;
|
||||
readonly contextValue?: string;
|
||||
|
||||
/**
|
||||
* Collapsible state of the tree item.
|
||||
* Required only when item has children.
|
||||
*/
|
||||
collapsibleState?: TreeItemCollapsibleState;
|
||||
readonly collapsibleState?: TreeItemCollapsibleState;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user