DataTree
The app data: every table, with its row count; a table opens in the table viewer.
import { running, session } from "#codebase/tcmts/vscode/extension"; import type { TableEntry } from "#codebase/tcmts/vscode/extension"; import * as vscode from "vscode"; export class DataTree implements vscode.TreeDataProvider<TableEntry> { changed = new vscode.EventEmitter<TableEntry | undefined | void>(); onDidChangeTreeData = this.changed.event; refresh() { this.changed.fire(); } async getChildren(element?: TableEntry): Promise<TableEntry[]> { if (!running() || element) return []; return session.client!.sendRequest("tcm/data", {}); } getTreeItem(e: TableEntry): vscode.TreeItem { const item = new vscode.TreeItem(e.table, vscode.TreeItemCollapsibleState.None); item.id = `table:${e.table}`; item.description = `${e.rows} row${e.rows === 1 ? "" : "s"}${e.older ? ` · ${e.older} older` : ""}${e.path ? "" : " · not declared"}`; item.iconPath = new vscode.ThemeIcon("database", e.older ? new vscode.ThemeColor("list.warningForeground") : undefined); item.tooltip = new vscode.MarkdownString( `**${e.table}**${e.path ? ` — declared by \`${e.path}\`` : " — no definition declares it now"}\n\n${e.rows} row(s)` + (e.older ? `; ${e.older} stored as an older row type (they go through \`migrate\` when read, or all now with **Migrate rows**)` : ""), ); item.contextValue = e.older ? "table.older" : "table"; item.command = { command: "tcm.showTable", title: "Open table", arguments: [e] }; return item; } }