UNPKG

ui5plugin-parser

Version:
102 lines (101 loc) 3.98 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.SAPNode = void 0; class SAPNode { constructor(node, metadataDAO) { this.nodes = []; this.node = node; this.metadataDAO = metadataDAO; this._fillNodes(); } _fillNodes() { if (this.node.nodes) { for (const node of this.node.nodes) { const newNode = new SAPNode(node, this.metadataDAO); this.nodes.push(newNode); } } } getName() { return this.node.name.replace("module:", "").replace(/\//g, "."); } getLib() { return this.node.lib; } getKind() { return this.node.kind; } getDisplayName() { return this.node.displayName || this.node.name.split(".")[this.node.name.split(".").length - 1]; } getIsDeprecated() { return this.node.bIsDeprecated || this.node.deprecated; } getFields() { const metadata = this.getMetadata(); const rawMetadata = metadata?.getRawMetadata(); const fields = rawMetadata?.properties?.filter((field) => field.visibility === "public" || field.visibility === "protected") || []; fields.forEach((field) => { field.name = field.name.replace(rawMetadata?.name + "." || "", ""); }); const nodes = this.node.nodes; if (nodes) { const nodeFields = nodes.map((node) => { const field = { ...node }; field.type = node.name || "string"; field.name = node.name.replace(`${this.node.type || this.node.name}.`, ""); field.description = node.description || ""; field.deprecated = node.deprecated || node.bIsDeprecated || false; return field; }); fields.push(...nodeFields); } return fields; } getProperties() { const metadata = this.getMetadata(); const properties = []; const nodeProperties = metadata ?.getUI5Metadata() ?.properties?.filter((property) => !property.deprecatedText && (property.visibility === "public" || property.visibility === "protected")); if (nodeProperties) { properties.push(...nodeProperties); } return properties; } getAggregations() { const metadata = this.getMetadata(); const UI5Metadata = metadata?.getUI5Metadata(); return (UI5Metadata?.aggregations?.filter((aggregation) => !aggregation.deprecated && (aggregation.visibility === "public" || aggregation.visibility === "protected")) || []); } getSpecialSettings() { const metadata = this.getMetadata(); const UI5Metadata = metadata?.getUI5Metadata(); return (UI5Metadata?.specialSettings?.filter((specialSetting) => !specialSetting.deprecated && (specialSetting.visibility === "public" || specialSetting.visibility === "protected")) || []); } getEvents() { const metadata = this.getMetadata(); const UI5Metadata = metadata?.getRawMetadata(); return UI5Metadata?.events?.filter((event) => !event.deprecated && event.visibility === "public") || []; } getAssociations() { const metadata = this.getMetadata(); const UI5Metadata = metadata?.getUI5Metadata(); return (UI5Metadata?.associations?.filter((association) => !association.deprecated && association.visibility === "public") || []); } getMethods() { const metadata = this.getMetadata(); const rawMetadata = metadata?.getRawMetadata(); return rawMetadata?.methods?.filter((method) => ["public", "protected"].includes(method.visibility)) || []; } getMetadata() { if (!this.metadata) { this.metadata = this.metadataDAO.getPreloadedMetadataForNode(this); } return this.metadata; } } exports.SAPNode = SAPNode;