1
0
forked from Rowland/EG
EG/Cesium-1.132/node_modules/tsd-jsdoc/dist/PropTree.js
2025-08-25 17:48:13 +08:00

50 lines
1.7 KiB
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const logger_1 = require("./logger");
class PropTree {
constructor(props) {
this.roots = [];
this.nodes = {};
for (let i = 0; i < props.length; ++i) {
const prop = props[i];
if (!prop || !prop.name) {
logger_1.warn('Encountered a property with no name, this is likely due to invalid JSDoc. Skipping.');
continue;
}
const parts = prop.name.split('.');
this.nodes[prop.name] = {
prop,
name: parts[parts.length - 1],
children: [],
};
}
for (let i = 0; i < props.length; ++i) {
const prop = props[i];
if (!prop || !prop.name)
continue;
const parts = prop.name.split('.');
const obj = this.nodes[prop.name];
if (!obj) {
logger_1.warn('Failed to find dot-notation property in map. This is likely a bug.');
continue;
}
if (parts.length > 1) {
parts.pop();
let parentName = parts.join('.');
if (parentName.endsWith('[]')) {
parentName = parentName.substring(0, parentName.length - '[]'.length);
}
const parent = this.nodes[parentName];
if (!parent) {
continue;
}
parent.children.push(obj);
}
else {
this.roots.push(obj);
}
}
}
}
exports.PropTree = PropTree;
//# sourceMappingURL=PropTree.js.map