src/vs/workbench/api/common/extHostTreeViews.ts/ExtHostTreeViews/createTreeView
class ExtHostTreeViews:	createTreeView<T>(viewId: string, options: vscode.TreeViewOptions<T>, extension: IExtensionDescription): vscode.TreeView<T> {
		if (!options || !options.treeDataProvider) {
			throw new Error('Options with treeDataProvider is mandatory');
		}
		const dropMimeTypes = options.dragAndDropController?.dropMimeTypes ?? [];
		const dragMimeTypes = options.dragAndDropController?.dragMimeTypes ?? [];
		const hasHandleDrag = !!options.dragAndDropController?.handleDrag;
		const hasHandleDrop = !!options.dragAndDropController?.handleDrop;
		const treeView = this.createExtHostTreeView(viewId, options, extension);
		const registerPromise = this._proxy.$registerTreeViewDataProvider(viewId, { showCollapseAll: !!options.showCollapseAll, canSelectMany: !!options.canSelectMany, dropMimeTypes, dragMimeTypes, hasHandleDrag, hasHandleDrop });
		return {
			get onDidCollapseElement() { return treeView.onDidCollapseElement; },
			get onDidExpandElement() { return treeView.onDidExpandElement; },
			get selection() { return treeView.selectedElements; },
			get onDidChangeSelection() { return treeView.onDidChangeSelection; },
			get visible() { return treeView.visible; },
			get onDidChangeVisibility() { return treeView.onDidChangeVisibility; },
			get onDidChangeCheckboxState() {
				checkProposedApiEnabled(extension, 'treeItemCheckbox');
				return treeView.onDidChangeCheckboxState;
			},
			get message() { return treeView.message; },
			set message(message: string) {
				treeView.message = message;
			},
			get title() { return treeView.title; },
			set title(title: string) {
				treeView.title = title;
			},
			get description() {
				return treeView.description;
			},
			set description(description: string | undefined) {
				treeView.description = description;
			},
			get badge() {
				return treeView.badge;
			},
			set badge(badge: vscode.ViewBadge | undefined) {
				if ((badge !== undefined) && ExtHostViewBadge.isViewBadge(badge)) {
					treeView.badge = {
						value: Math.floor(Math.abs(badge.value)),
						tooltip: badge.tooltip
					};
				} else if (badge === undefined) {
					treeView.badge = undefined;
				}
			},
			reveal: (element: T, options?: IRevealOptions): Promise<void> => {
				return treeView.reveal(element, options);
			},
			dispose: async () => {
				// Wait for the registration promise to finish before doing the dispose.
				await registerPromise;
				this.treeViews.delete(viewId);
				treeView.dispose();
			}
		};
	}