in src/explorer.ts [69:132]
static getDirItems(spec: PontSpec, element = null) {
const dirs = element?.children || spec?.ext?.directories || [];
const results = dirs.map((dir) => {
const apiName = dir;
const api = spec?.apis?.[apiName];
if (typeof dir === "string" && spec?.name && api) {
return {
specName: spec?.name,
modName: "",
apiName: dir,
contextValue: "API",
resourceUri: vscode.Uri.parse(`pontx-manager://spec/${spec.name}/apis/${dir}`),
label: `${apiName}`,
iconPath: api.deprecated
? vscode.Uri.joinPath(alicloudAPIMessageService.context.extensionUri, "resources/deprecated.svg")
: vscode.Uri.joinPath(alicloudAPIMessageService.context.extensionUri, "resources/api-outline.svg"),
description: ` ${api?.title || api?.summary || ""}`,
tooltip: `${api.deprecated ? `@deprecated\n\n` : ""}${api?.description || api?.summary || api.name}`,
collapsibleState: vscode.TreeItemCollapsibleState.None,
command: {
command: "alicloud.api.openDocument",
title: "open",
arguments: [
{
specName: spec.name,
modName: "",
spec: api,
name: api?.name,
pageType: "document",
schemaType: "api",
},
],
},
};
}
return {
specName: spec.name,
isDir: dir?.children?.length,
children: dir?.children,
dirPath: dir.id,
label: `${dir.title}(${dir.children?.length || 0})`,
contextValue: "Dir",
resourceUri: vscode.Uri.parse(`pontx-manager://spec/${spec.name}/dir/${dir.title}`),
collapsibleState: vscode.TreeItemCollapsibleState.Expanded,
} as PontAPITreeItem;
});
if (spec?.definitions && !element && Object.keys(spec.definitions).length) {
const defs = {
specName: spec.name,
isDefs: true,
contextValue: "Definitions",
label: `definitions`,
resourceUri: vscode.Uri.parse(`pontx-manager://spec/${spec.name}/definitions`),
description: I18N.src.explorer.struct,
tooltip: I18N.src.explorer.struct,
collapsibleState: vscode.TreeItemCollapsibleState.Collapsed,
};
return [defs, ...results];
}
return results;
}