Как запрограммировать TreeDataProvider для расширения VsCode

1

обратитесь к официальному Примеру, я заархивировал провайдера и реализую класс и все методы. Но он не работает.
см. файловую структуру исходного кода

class JsonOutlineProvider {

constructor(context) {

    this._onDidChangeTreeData = new vscode.EventEmitter();
    this.onDidChangeTreeData = this._onDidChangeTreeData.event;
    this.editor = null;
    this.tree = null;
    vscode.window.onDidChangeActiveTextEditor(editor => {
        this.parseTree();
        this._onDidChangeTreeData.fire();
    });
    vscode.workspace.onDidChangeTextDocument(e => {
        console.log("text changed !")
    });
    this.parseTree();
}
parseTree() {
    this.tree = null;
    this.editor = vscode.window.activeTextEditor;
    if (this.editor && this.editor.document && this.editor.document.languageId === 'json') {
        this.tree = json.parseTree(this.editor.document.getText());
    }
    console.log("Tree", this.tree);
}

getChildren(node) {
}
getTreeItem(node) {
}

}

module.exports = JsonOutlineProvider;
Теги:
visual-studio-code
vscode-extensions

1 ответ

0

Вы также создали представление в package.json?

Ещё вопросы

Сообщество Overcoder
Наверх
Меню