import { Event , EventEmitter , TreeDataProvider , TreeItem } from 'vscode' ; import { TreeNode } from '../nodes/treeNode' ; /**
 * Defines tree view data provider base class for all GitOps tree views.
 */ export class DataProvider implements TreeDataProvider < TreeItem > { private treeItems : TreeItem [ ] | null = null ; private _onDidChangeTreeData : EventEmitter < TreeItem | undefined > = new EventEmitter < TreeItem | undefined > ( ) ; readonly onDidChangeTreeData : Event < TreeItem | undefined > = this . _onDidChangeTreeData . event ; param treeItem public refresh ( treeItem ? ) { if ( ! treeItem ) { this . treeItems = null ; } this . _onDidChangeTreeData . fire ( treeItem ) ; } param element returns public getTreeItem ( element ) { return element ; } param element returns public getParent ( element ) { if ( element instanceof TreeNode && element . parent ) { return element . parent ; } return null ; } param element returns public async getChildren ( element ? ) { if ( ! this . treeItems ) { this . treeItems = await this . buildTree ( ) ; } if ( element instanceof TreeNode ) { return element . children ; } if ( ! element ) { if ( this . treeItems ) { return this . treeItems ; } } return [ ] ; } returns buildTree ( ) { return Promise . resolve ( [ ] ) ; } }