From 97172b89d1dfc58604ca9a00173f7eae0362f0fc Mon Sep 17 00:00:00 2001 From: Yavor Ivanov Date: Wed, 3 Aug 2022 09:50:47 +0300 Subject: [PATCH 01/69] ES6 destructuring of UI5 enums - Use escope to go up through the chain - Cover destructuring and build up a fully quantified name up to the imported module name - Cover renaming - Cover multiple destructuring --- lib/processors/jsdoc/lib/ui5/plugin.cjs | 179 +++++++++++++++++++++++- 1 file changed, 172 insertions(+), 7 deletions(-) diff --git a/lib/processors/jsdoc/lib/ui5/plugin.cjs b/lib/processors/jsdoc/lib/ui5/plugin.cjs index 8c7647bd0..4ab0c0e80 100644 --- a/lib/processors/jsdoc/lib/ui5/plugin.cjs +++ b/lib/processors/jsdoc/lib/ui5/plugin.cjs @@ -66,6 +66,7 @@ const fs = require('jsdoc/fs'); const path = require('jsdoc/path'); const logger = require('jsdoc/util/logger'); const pluginConfig = (env.conf && env.conf.templates && env.conf.templates.ui5) || env.opts.sapui5 || {}; +const escope = require("escope"); /* ---- logging ---- */ @@ -694,6 +695,119 @@ function getResolvedObjectName(node) { return name; } +/** + * Gets enclosing scope + * + * @param {Node} node + * @returns {Scope} + */ +function getEnclosingVariableScope (node) { + // Get to the nearest upper scope + let nearestScopeableNode = node; + while ( + nearestScopeableNode.type !== Syntax.FunctionDeclaration && + nearestScopeableNode.type !== Syntax.FunctionExpression + ) { + nearestScopeableNode = nearestScopeableNode.parent; + } + + const scopeManager = escope.analyze(currentProgram); + // Get the scope of the nearest scopeable node + return scopeManager.acquire(nearestScopeableNode); +}; + +/** + * Builds the fully qunatified name when there's a destrcturing of a variable + * + * @param {Node} node + * @param {String} varName + * @returns + */ +function getVarDestructuringChain (node){ + // The missing part is on the left side. The right side is clear. + // We would eiter ways would resolve to the same leftmost token. + let leftMostName = getLeftmostName(node); + let name = getObjectName(node); + let originalName = name; + const currentScope = getEnclosingVariableScope(node); + + if (!currentScope) { + return []; + } + + const checkVarRenaming = (variable) => { + // variable.defs[0].node.id.type === Syntax.ObjectPattern -> Renaming + // variable.defs[0].node.id.properties[0].key.name === variable.name; // Original + // variable.defs[0].node.id.properties[0].value.name === variable.name; // Renamed + + return variable.defs + .filter( + (def) => + def.node && + def.node.id && + def.node.id.type === Syntax.ObjectPattern + ) // Filter on object patterns => Detructure renamig + .map((def) => def.node.id) // Drill down to the ObjectPattern Node + .filter((objPatternNode) => + objPatternNode.properties.some( + (prop) => prop.value.name === variable.name + ) + ) // Filter on ObjectPattern nodes that contain the variable + .reduce((acc, objPatternNode) => { + return acc.concat( + objPatternNode.properties.filter( + (prop) => prop.value.name === variable.name + ) + ); + }, []) + .map((prop) => { + return { original: prop.key.name, renamed: prop.value.name }; + })[0]; + }; + + // TODO: Check for hierarchical destructuring + // i.e. let {Foo} = myObject; let {Bar} = Foo; --> Bar + while (leftMostName) { + let potentialChunk = currentScope.variables + .filter((curVar) => curVar.name === leftMostName) + .reduce((acc, curVar) => { + const potentialRenaming = checkVarRenaming(curVar); + const filteredValues = curVar.references + .filter((ref) => ref.writeExpr) + .map((ref) => ref.writeExpr.name); + + acc.push({ + ref: filteredValues[0], + original: potentialRenaming + ? potentialRenaming.original + : curVar.name, + renamed: potentialRenaming + ? potentialRenaming.renamed + : null, + }); + return acc; + }, [])[0]; + + leftMostName = potentialChunk.ref; + name = leftMostName ? leftMostName + "." + name : name; + originalName = leftMostName + ? leftMostName + "." + originalName + : originalName; + + if (potentialChunk.renamed) { + originalName = originalName.replace( + "." + potentialChunk.renamed + ".", + "." + potentialChunk.original + "." + ); + } + } + + return { + renamedChain: name.split("."), + originalChain: originalName.split("."), + }; +}; + /* * Analyzes the given AST node that represents a value and returns an object * with two properties: @@ -734,13 +848,64 @@ function convertValueWithRaw(node, type, propertyName) { // enum value (a.b.c) value = getResolvedObjectName(node); - if ( value.indexOf(type + ".") === 0 ) { - // starts with fully qualified enum name -> cut off name - value = value.slice(type.length + 1); - return { - value: value, - raw: value - }; + + const checkEnumsFromExternalModules = (varsDestructuringStack) => { + const localName = varsDestructuringStack[0]; + const potentialEnumKey = varsDestructuringStack[varsDestructuringStack.length - 1]; + + const localModule = + currentModule.localNames[localName].module || + currentModule.localNames[localName].class; + + // Find if there are enums defined for that module + return Object.keys(enumValues) + .filter((curEnumKey) => { + const [enums, resource] = curEnumKey.split("||"); + + // Check the resource + if (resource.indexOf(localModule) === -1) { + return false; + } + + // Check if the key is in the enums + if (enums.split("|").indexOf(potentialEnumKey) === -1) { + return false; + } + + return true; + }) + .map((curEnumKey) => { + return { + raw: potentialEnumKey, + value: potentialEnumKey, + // value: enumValues[curEnumKey][potentialEnumKey], // If needed, the Runtime value could be accessed like this + }; + })[0]; + }; + + const resolvePotemtialEnum = (nodeToResolve) => { + const varsDestructuringStack = getVarDestructuringChain(nodeToResolve); + + if (!varsDestructuringStack && !varsDestructuringStack.originalChain.length) { + return getObjectName(nodeToResolve); + } + + // TODO: After we've been through the chain up to the top of the module, + // now we need to get the namespace from the external file if such exists. + const fullyQualifiedLocalName = varsDestructuringStack.originalChain.join("."); + const localName = varsDestructuringStack.originalChain[0]; + + if (!currentModule.localNames[localName]) { + return fullyQualifiedLocalName; + } + + return checkEnumsFromExternalModules(varsDestructuringStack.originalChain); + }; + + const resolvedEnum = resolvePotemtialEnum(node); + + if ( resolvedEnum ) { + return resolvedEnum; // } else if ( value.indexOf(type.split(".").slice(-1)[0] + ".") === 0 ) { // // unqualified name might be a local name (just a guess - would need static code analysis for proper solution) // return value.slice(type.split(".").slice(-1)[0].length + 1); From 6934989af3607f360da784445013d315c8a6b66a Mon Sep 17 00:00:00 2001 From: Yavor Ivanov Date: Wed, 3 Aug 2022 15:31:15 +0300 Subject: [PATCH 02/69] Refactor plugin.js and reorder code --- lib/processors/jsdoc/lib/ui5/plugin.cjs | 251 ++++++++++++------------ 1 file changed, 130 insertions(+), 121 deletions(-) diff --git a/lib/processors/jsdoc/lib/ui5/plugin.cjs b/lib/processors/jsdoc/lib/ui5/plugin.cjs index 4ab0c0e80..f62ec84ea 100644 --- a/lib/processors/jsdoc/lib/ui5/plugin.cjs +++ b/lib/processors/jsdoc/lib/ui5/plugin.cjs @@ -643,78 +643,66 @@ function isPotentialEnum(node) { return node.properties.every((prop) => isCompileTimeConstant(prop.value)); } -function isCompileTimeConstant(node) { - return node && node.type === Syntax.Literal; -} +// ---- ES6+ Destructuring --------------------------------------------------------- +function checkEnumsFromExternalModules(varsDestructuringStack) { + const localName = varsDestructuringStack[0]; + const potentialEnumKey = + varsDestructuringStack[varsDestructuringStack.length - 1]; -function getObjectName(node) { - if ( isMemberExpression(node) && !node.computed && node.property.type === Syntax.Identifier ) { - const prefix = getObjectName(node.object); - return prefix ? prefix + "." + node.property.name : null; - } else if ( node.type === Syntax.Identifier ) { - return /* scope[node.name] ? scope[node.name] : */ node.name; - } else { - return null; - } -} -/* - * Checks whether the node is a qualified name (a.b.c) and if so, - * returns the leftmost identifier a - */ -function getLeftmostName(node) { - while ( isMemberExpression(node) ) { - node = node.object; - } - if ( node.type === Syntax.Identifier ) { - return node.name; - } - // return undefined; -} + const localModule = + currentModule.localNames[localName].module || + currentModule.localNames[localName].class; -function getResolvedObjectName(node) { - const name = getObjectName(node); - const _import = getLeftmostName(node); - const local = _import && currentModule.localNames[_import]; - if ( name && local && (local.class || local.module) ) { - let resolvedName; - if ( local.class ) { - resolvedName = local.class; - } else { - resolvedName = local.module.replace(/\//g, ".").replace(/\.library$/, ""); - if ( local.path ) { - resolvedName = resolvedName + "." + local.path; + // Find if there are enums defined for that module + return Object.keys(enumValues) + .filter((curEnumKey) => { + const [enums, resource] = curEnumKey.split("||"); + + // Check the resource + if (resource.indexOf(localModule) === -1) { + return false; } - } - if ( name.indexOf('.') > 0 ) { - resolvedName = resolvedName + name.slice(name.indexOf('.')); - } - debug(`resolved ${name} to ${resolvedName}`); - return resolvedName; - } - return name; + + // Check if the key is in the enums + if (enums.split("|").indexOf(potentialEnumKey) === -1) { + return false; + } + + return true; + }) + .map((curEnumKey) => { + return { + raw: potentialEnumKey, + value: potentialEnumKey, + // value: enumValues[curEnumKey][potentialEnumKey], // If needed, the Runtime value could be accessed like this + }; + })[0]; } -/** - * Gets enclosing scope - * - * @param {Node} node - * @returns {Scope} - */ -function getEnclosingVariableScope (node) { - // Get to the nearest upper scope - let nearestScopeableNode = node; - while ( - nearestScopeableNode.type !== Syntax.FunctionDeclaration && - nearestScopeableNode.type !== Syntax.FunctionExpression +function resolvePotemtialEnum(node) { + const varsDestructuringStack = getVarDestructuringChain(node); + + if ( + !varsDestructuringStack || + !varsDestructuringStack.originalChain || + !varsDestructuringStack.originalChain.length ) { - nearestScopeableNode = nearestScopeableNode.parent; + return getObjectName(node); } - const scopeManager = escope.analyze(currentProgram); - // Get the scope of the nearest scopeable node - return scopeManager.acquire(nearestScopeableNode); -}; + // TODO: After we've been through the chain up to the top of the module, + // now we need to get the namespace from the external file if such exists. + const fullyQualifiedLocalName = + varsDestructuringStack.originalChain.join("."); + const localName = varsDestructuringStack.originalChain[0]; + + if (!currentModule.localNames[localName]) { + return fullyQualifiedLocalName; + } + + return checkEnumsFromExternalModules(varsDestructuringStack.originalChain); +} /** * Builds the fully qunatified name when there's a destrcturing of a variable @@ -723,18 +711,19 @@ function getEnclosingVariableScope (node) { * @param {String} varName * @returns */ -function getVarDestructuringChain (node){ +function getVarDestructuringChain(node) { // The missing part is on the left side. The right side is clear. // We would eiter ways would resolve to the same leftmost token. let leftMostName = getLeftmostName(node); - let name = getObjectName(node); + let name = getObjectName(node) || ""; let originalName = name; const currentScope = getEnclosingVariableScope(node); if (!currentScope) { - return []; + return null; } + // Checks whether a var has been renamed while destructuring i.e. {A: b} = SomeObject const checkVarRenaming = (variable) => { // variable.defs[0].node.id.type === Syntax.ObjectPattern -> Renaming // variable.defs[0].node.id.properties[0].key.name === variable.name; // Original @@ -806,8 +795,82 @@ function getVarDestructuringChain (node){ renamedChain: name.split("."), originalChain: originalName.split("."), }; +} + +/** + * Gets enclosing scope + * + * @param {Node} node + * @returns {Scope} + */ + function getEnclosingVariableScope (node) { + // Get to the nearest upper scope + let nearestScopeableNode = node; + while ( + nearestScopeableNode && nearestScopeableNode.type && + nearestScopeableNode.type !== Syntax.FunctionDeclaration && + nearestScopeableNode.type !== Syntax.FunctionExpression + ) { + nearestScopeableNode = nearestScopeableNode.parent; + } + + const scopeManager = escope.analyze(currentProgram); + // Get the scope of the nearest scopeable node + return scopeManager.acquire(nearestScopeableNode); }; +function isCompileTimeConstant(node) { + return node && node.type === Syntax.Literal; +} + +function getObjectName(node) { + if ( isMemberExpression(node) && !node.computed && node.property.type === Syntax.Identifier ) { + const prefix = getObjectName(node.object); + return prefix ? prefix + "." + node.property.name : null; + } else if ( node.type === Syntax.Identifier ) { + return /* scope[node.name] ? scope[node.name] : */ node.name; + } else { + return null; + } +} + +/* + * Checks whether the node is a qualified name (a.b.c) and if so, + * returns the leftmost identifier a + */ +function getLeftmostName(node) { + while ( isMemberExpression(node) ) { + node = node.object; + } + if ( node.type === Syntax.Identifier ) { + return node.name; + } + // return undefined; +} + +function getResolvedObjectName(node) { + const name = getObjectName(node); + const _import = getLeftmostName(node); + const local = _import && currentModule.localNames[_import]; + if ( name && local && (local.class || local.module) ) { + let resolvedName; + if ( local.class ) { + resolvedName = local.class; + } else { + resolvedName = local.module.replace(/\//g, ".").replace(/\.library$/, ""); + if ( local.path ) { + resolvedName = resolvedName + "." + local.path; + } + } + if ( name.indexOf('.') > 0 ) { + resolvedName = resolvedName + name.slice(name.indexOf('.')); + } + debug(`resolved ${name} to ${resolvedName}`); + return resolvedName; + } + return name; +} + /* * Analyzes the given AST node that represents a value and returns an object * with two properties: @@ -847,61 +910,6 @@ function convertValueWithRaw(node, type, propertyName) { } else if ( isMemberExpression(node) && type ) { // enum value (a.b.c) - value = getResolvedObjectName(node); - - const checkEnumsFromExternalModules = (varsDestructuringStack) => { - const localName = varsDestructuringStack[0]; - const potentialEnumKey = varsDestructuringStack[varsDestructuringStack.length - 1]; - - const localModule = - currentModule.localNames[localName].module || - currentModule.localNames[localName].class; - - // Find if there are enums defined for that module - return Object.keys(enumValues) - .filter((curEnumKey) => { - const [enums, resource] = curEnumKey.split("||"); - - // Check the resource - if (resource.indexOf(localModule) === -1) { - return false; - } - - // Check if the key is in the enums - if (enums.split("|").indexOf(potentialEnumKey) === -1) { - return false; - } - - return true; - }) - .map((curEnumKey) => { - return { - raw: potentialEnumKey, - value: potentialEnumKey, - // value: enumValues[curEnumKey][potentialEnumKey], // If needed, the Runtime value could be accessed like this - }; - })[0]; - }; - - const resolvePotemtialEnum = (nodeToResolve) => { - const varsDestructuringStack = getVarDestructuringChain(nodeToResolve); - - if (!varsDestructuringStack && !varsDestructuringStack.originalChain.length) { - return getObjectName(nodeToResolve); - } - - // TODO: After we've been through the chain up to the top of the module, - // now we need to get the namespace from the external file if such exists. - const fullyQualifiedLocalName = varsDestructuringStack.originalChain.join("."); - const localName = varsDestructuringStack.originalChain[0]; - - if (!currentModule.localNames[localName]) { - return fullyQualifiedLocalName; - } - - return checkEnumsFromExternalModules(varsDestructuringStack.originalChain); - }; - const resolvedEnum = resolvePotemtialEnum(node); if ( resolvedEnum ) { @@ -910,6 +918,7 @@ function convertValueWithRaw(node, type, propertyName) { // // unqualified name might be a local name (just a guess - would need static code analysis for proper solution) // return value.slice(type.split(".").slice(-1)[0].length + 1); } else { + value = getResolvedObjectName(node); warning(`did not understand default value '${value}'${propertyName ? " of property '" + propertyName + "'" : ""}, falling back to source`); let raw = value; if ( currentSource && node.range ) { From a1cce383e1490df80bf1a87d3a15967f25d35e4d Mon Sep 17 00:00:00 2001 From: Yavor Ivanov Date: Wed, 3 Aug 2022 15:32:13 +0300 Subject: [PATCH 03/69] Modify fixtres with destructuring cases --- .../main/src/library/j/dependency.js | 31 +++++++ .../main/src/library/j/dependency2.js | 31 +++++++ .../library.j/main/src/library/j/some.js | 92 ++++++++++++++++--- 3 files changed, 139 insertions(+), 15 deletions(-) create mode 100644 test/fixtures/library.j/main/src/library/j/dependency.js create mode 100644 test/fixtures/library.j/main/src/library/j/dependency2.js diff --git a/test/fixtures/library.j/main/src/library/j/dependency.js b/test/fixtures/library.j/main/src/library/j/dependency.js new file mode 100644 index 000000000..d575885c8 --- /dev/null +++ b/test/fixtures/library.j/main/src/library/j/dependency.js @@ -0,0 +1,31 @@ +sap.ui.define([], function () { + sap.ui.getCore().initLibrary({ + name: "testlib", + version: "${version}", + dependencies: ["sap.ui.core"], + designtime: "testlib/designtime/library.designtime", + types: ["testlib.MyValidEnum"], + }); + + /** + * MyValidEnum + * + * @enum {string} + * @public + * @ui5-metamodel This enumeration also will be described in the UI5 (legacy) designtime metamodel + */ + testlib.MyValidEnum = { + /** + * Foo + * @public + */ + Foo: "Foo", + /** + * Bar + * @public + */ + Bar: "Bar", + }; + + return testlib; +}); diff --git a/test/fixtures/library.j/main/src/library/j/dependency2.js b/test/fixtures/library.j/main/src/library/j/dependency2.js new file mode 100644 index 000000000..b0220c021 --- /dev/null +++ b/test/fixtures/library.j/main/src/library/j/dependency2.js @@ -0,0 +1,31 @@ +sap.ui.define([], function () { + sap.ui.getCore().initLibrary({ + name: "testlib", + version: "${version}", + dependencies: ["sap.ui.core"], + designtime: "testlib/designtime/library.designtime", + types: ["testlib.AnotherValidEnum"], + }); + + /** + * AnotherValidEnum + * + * @enum {string} + * @public + * @ui5-metamodel This enumeration also will be described in the UI5 (legacy) designtime metamodel + */ + testlib.AnotherValidEnum = { + /** + * Fizz + * @public + */ + Fizz: "Fizz", + /** + * Bar + * @public + */ + Buzz: "Buzz", + }; + + return testlib; +}); diff --git a/test/fixtures/library.j/main/src/library/j/some.js b/test/fixtures/library.j/main/src/library/j/some.js index 4d7f5afce..ac9d596c3 100644 --- a/test/fixtures/library.j/main/src/library/j/some.js +++ b/test/fixtures/library.j/main/src/library/j/some.js @@ -1,20 +1,82 @@ /*! * ${copyright} */ +sap.ui.define([ + "sap/ui/core/Control", + "./dependency", + "./dependency2", + "./dependency-es6-1", + "./dependency-es6-2", + "./dependency-es6-3" +], function (Control, coreLib, library, es6_1, es6_2, es6_3) { + "use strict"; -sap.ui.define( - ["./dependency-es6-1"], - ["./dependency-es6-2"], - ["./dependency-es6-3"], - function (dep1, dep2, dep3) { - "use strict"; + const { AnotherValidEnum: Zzz } = library; + const { AnotherValidEnum } = library; + const { Buzz } = AnotherValidEnum; + const { TitleLevel } = sap.ui.core; - /** - * @alias library.j - * @namespace - * @public - */ - var SomeFunction = function () {}; - }, - /* bExport= */ true -); + /** + * @class + * My super documentation of this class + * + * @extends sap.ui.core.Control + * + * @author SAP SE + * @version ${version} + * + * @public + * @alias testlib.ValidPropertyDefaultValue + * @ui5-metamodel text + */ + var ValidPropertyDefaultValue = Control.extend( + "testlib.ValidPropertyDefaultValue", + { + metadata: { + properties: { + /** + * validPropertyDefaultValueEnumViaDestructuringInArrowFn + */ + validPropertyDefaultValueEnumViaDestructuringInArrowFn: + { + type: "testlib.MyValidEnum", + group: "Misc", + defaultValue: coreLib.MyValidEnum.Foo, + }, + + /** + * validPropertyDefaultValueEnumViaDestructuringWithRename + */ + validPropertyDefaultValueEnumViaDestructuringWithRename: + { + type: "testlib.AnotherValidEnum", + group: "Misc", + defaultValue: Zzz.Fizz, + }, + + /** + * validPropertyDefaultValueEnumViaHierarchicalDestructuring + */ + validPropertyDefaultValueEnumViaHierarchicalDestructuring: + { + type: "testlib.AnotherValidEnum", + group: "Misc", + defaultValue: Buzz, + }, + + /** + * validPropertyDefaultValueEnumViaDestructuringGlobal + */ + validPropertyDefaultValueEnumViaDestructuringGlobal: { + type: "sap.ui.core", + group: "Misc", + defaultValue: TitleLevel, + }, + }, + }, + renderer: function () {}, + } + ); + + return ValidPropertyDefaultValue; +}, /* bExport= */ true); From c2ddb96812e761c20ef19f819267236ebc2d7332 Mon Sep 17 00:00:00 2001 From: Yavor Ivanov Date: Wed, 3 Aug 2022 15:56:53 +0300 Subject: [PATCH 04/69] Bugfix: Add arrow functions into the scope --- lib/processors/jsdoc/lib/ui5/plugin.cjs | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/processors/jsdoc/lib/ui5/plugin.cjs b/lib/processors/jsdoc/lib/ui5/plugin.cjs index f62ec84ea..fccdfeb10 100644 --- a/lib/processors/jsdoc/lib/ui5/plugin.cjs +++ b/lib/processors/jsdoc/lib/ui5/plugin.cjs @@ -808,6 +808,7 @@ function getVarDestructuringChain(node) { let nearestScopeableNode = node; while ( nearestScopeableNode && nearestScopeableNode.type && + nearestScopeableNode.type !== Syntax.ArrowFunctionExpression && nearestScopeableNode.type !== Syntax.FunctionDeclaration && nearestScopeableNode.type !== Syntax.FunctionExpression ) { From 8160672223c0b1f009576e99b39b23ba3e31feb3 Mon Sep 17 00:00:00 2001 From: Yavor Ivanov Date: Wed, 3 Aug 2022 15:57:39 +0300 Subject: [PATCH 05/69] Tests: Modify expectations to cover destructuring cases --- .../dest/resources/library/j/dependency.js | 31 +++++++ .../dest/resources/library/j/dependency2.js | 31 +++++++ .../dest/resources/library/j/some.js | 92 ++++++++++++++++--- 3 files changed, 139 insertions(+), 15 deletions(-) create mode 100644 test/expected/build/library.j/dest/resources/library/j/dependency.js create mode 100644 test/expected/build/library.j/dest/resources/library/j/dependency2.js diff --git a/test/expected/build/library.j/dest/resources/library/j/dependency.js b/test/expected/build/library.j/dest/resources/library/j/dependency.js new file mode 100644 index 000000000..d575885c8 --- /dev/null +++ b/test/expected/build/library.j/dest/resources/library/j/dependency.js @@ -0,0 +1,31 @@ +sap.ui.define([], function () { + sap.ui.getCore().initLibrary({ + name: "testlib", + version: "${version}", + dependencies: ["sap.ui.core"], + designtime: "testlib/designtime/library.designtime", + types: ["testlib.MyValidEnum"], + }); + + /** + * MyValidEnum + * + * @enum {string} + * @public + * @ui5-metamodel This enumeration also will be described in the UI5 (legacy) designtime metamodel + */ + testlib.MyValidEnum = { + /** + * Foo + * @public + */ + Foo: "Foo", + /** + * Bar + * @public + */ + Bar: "Bar", + }; + + return testlib; +}); diff --git a/test/expected/build/library.j/dest/resources/library/j/dependency2.js b/test/expected/build/library.j/dest/resources/library/j/dependency2.js new file mode 100644 index 000000000..b0220c021 --- /dev/null +++ b/test/expected/build/library.j/dest/resources/library/j/dependency2.js @@ -0,0 +1,31 @@ +sap.ui.define([], function () { + sap.ui.getCore().initLibrary({ + name: "testlib", + version: "${version}", + dependencies: ["sap.ui.core"], + designtime: "testlib/designtime/library.designtime", + types: ["testlib.AnotherValidEnum"], + }); + + /** + * AnotherValidEnum + * + * @enum {string} + * @public + * @ui5-metamodel This enumeration also will be described in the UI5 (legacy) designtime metamodel + */ + testlib.AnotherValidEnum = { + /** + * Fizz + * @public + */ + Fizz: "Fizz", + /** + * Bar + * @public + */ + Buzz: "Buzz", + }; + + return testlib; +}); diff --git a/test/expected/build/library.j/dest/resources/library/j/some.js b/test/expected/build/library.j/dest/resources/library/j/some.js index 4d7f5afce..07a1ccba9 100644 --- a/test/expected/build/library.j/dest/resources/library/j/some.js +++ b/test/expected/build/library.j/dest/resources/library/j/some.js @@ -1,20 +1,82 @@ /*! * ${copyright} */ +sap.ui.define([ + "sap/ui/core/Control", + "./dependency", + "./dependency2", + "./dependency-es6-1", + "./dependency-es6-2", + "./dependency-es6-3" +], function (Control, coreLib, library, es6_1, , es6_2, , es6_3) { + "use strict"; -sap.ui.define( - ["./dependency-es6-1"], - ["./dependency-es6-2"], - ["./dependency-es6-3"], - function (dep1, dep2, dep3) { - "use strict"; + const { AnotherValidEnum: Zzz } = library; + const { AnotherValidEnum } = library; + const { Buzz } = AnotherValidEnum; + const { TitleLevel } = sap.ui.core; - /** - * @alias library.j - * @namespace - * @public - */ - var SomeFunction = function () {}; - }, - /* bExport= */ true -); + /** + * @class + * My super documentation of this class + * + * @extends sap.ui.core.Control + * + * @author SAP SE + * @version ${version} + * + * @public + * @alias testlib.ValidPropertyDefaultValue + * @ui5-metamodel text + */ + var ValidPropertyDefaultValue = Control.extend( + "testlib.ValidPropertyDefaultValue", + { + metadata: { + properties: { + /** + * validPropertyDefaultValueEnumViaDestructuringInArrowFn + */ + validPropertyDefaultValueEnumViaDestructuringInArrowFn: + { + type: "testlib.MyValidEnum", + group: "Misc", + defaultValue: coreLib.MyValidEnum.Foo, + }, + + /** + * validPropertyDefaultValueEnumViaDestructuringWithRename + */ + validPropertyDefaultValueEnumViaDestructuringWithRename: + { + type: "testlib.AnotherValidEnum", + group: "Misc", + defaultValue: Zzz.Fizz, + }, + + /** + * validPropertyDefaultValueEnumViaHierarchicalDestructuring + */ + validPropertyDefaultValueEnumViaHierarchicalDestructuring: + { + type: "testlib.AnotherValidEnum", + group: "Misc", + defaultValue: Buzz, + }, + + /** + * validPropertyDefaultValueEnumViaDestructuringGlobal + */ + validPropertyDefaultValueEnumViaDestructuringGlobal: { + type: "sap.ui.core", + group: "Misc", + defaultValue: TitleLevel, + }, + }, + }, + renderer: function () {}, + } + ); + + return ValidPropertyDefaultValue; +}, /* bExport= */ true); From d0bd9b6b2fd8b95ea356b312c206417a90ac3784 Mon Sep 17 00:00:00 2001 From: Yavor Ivanov Date: Thu, 4 Aug 2022 10:15:14 +0300 Subject: [PATCH 06/69] Add copyright for the dependencies --- test/fixtures/library.j/main/src/library/j/dependency.js | 3 +++ test/fixtures/library.j/main/src/library/j/dependency2.js | 3 +++ 2 files changed, 6 insertions(+) diff --git a/test/fixtures/library.j/main/src/library/j/dependency.js b/test/fixtures/library.j/main/src/library/j/dependency.js index d575885c8..e17972dae 100644 --- a/test/fixtures/library.j/main/src/library/j/dependency.js +++ b/test/fixtures/library.j/main/src/library/j/dependency.js @@ -1,3 +1,6 @@ +/*! + * ${copyright} + */ sap.ui.define([], function () { sap.ui.getCore().initLibrary({ name: "testlib", diff --git a/test/fixtures/library.j/main/src/library/j/dependency2.js b/test/fixtures/library.j/main/src/library/j/dependency2.js index b0220c021..aff06f291 100644 --- a/test/fixtures/library.j/main/src/library/j/dependency2.js +++ b/test/fixtures/library.j/main/src/library/j/dependency2.js @@ -1,3 +1,6 @@ +/*! + * ${copyright} + */ sap.ui.define([], function () { sap.ui.getCore().initLibrary({ name: "testlib", From c67bed675f56e6a05509e4d5378f713a31b1598b Mon Sep 17 00:00:00 2001 From: Yavor Ivanov Date: Thu, 4 Aug 2022 10:39:57 +0300 Subject: [PATCH 07/69] Tests: Align expectations w/ fixtures --- .../build/library.j/dest/resources/library/j/dependency.js | 3 +++ .../build/library.j/dest/resources/library/j/dependency2.js | 3 +++ 2 files changed, 6 insertions(+) diff --git a/test/expected/build/library.j/dest/resources/library/j/dependency.js b/test/expected/build/library.j/dest/resources/library/j/dependency.js index d575885c8..e17972dae 100644 --- a/test/expected/build/library.j/dest/resources/library/j/dependency.js +++ b/test/expected/build/library.j/dest/resources/library/j/dependency.js @@ -1,3 +1,6 @@ +/*! + * ${copyright} + */ sap.ui.define([], function () { sap.ui.getCore().initLibrary({ name: "testlib", diff --git a/test/expected/build/library.j/dest/resources/library/j/dependency2.js b/test/expected/build/library.j/dest/resources/library/j/dependency2.js index b0220c021..aff06f291 100644 --- a/test/expected/build/library.j/dest/resources/library/j/dependency2.js +++ b/test/expected/build/library.j/dest/resources/library/j/dependency2.js @@ -1,3 +1,6 @@ +/*! + * ${copyright} + */ sap.ui.define([], function () { sap.ui.getCore().initLibrary({ name: "testlib", From f1e2ce447269495575899bf934f080d60eda179e Mon Sep 17 00:00:00 2001 From: Yavor Ivanov Date: Thu, 4 Aug 2022 10:40:39 +0300 Subject: [PATCH 08/69] Bugfixing for destructuring --- lib/processors/jsdoc/lib/ui5/plugin.cjs | 33 ++++++++++++------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/lib/processors/jsdoc/lib/ui5/plugin.cjs b/lib/processors/jsdoc/lib/ui5/plugin.cjs index fccdfeb10..f4bd16fd4 100644 --- a/lib/processors/jsdoc/lib/ui5/plugin.cjs +++ b/lib/processors/jsdoc/lib/ui5/plugin.cjs @@ -649,10 +649,8 @@ function checkEnumsFromExternalModules(varsDestructuringStack) { const potentialEnumKey = varsDestructuringStack[varsDestructuringStack.length - 1]; - - const localModule = - currentModule.localNames[localName].module || - currentModule.localNames[localName].class; + const curModuleNames = currentModule.localNames[localName] || {}; + const localModule = curModuleNames.module || curModuleNames.class; // Find if there are enums defined for that module return Object.keys(enumValues) @@ -688,18 +686,9 @@ function resolvePotemtialEnum(node) { !varsDestructuringStack.originalChain || !varsDestructuringStack.originalChain.length ) { - return getObjectName(node); + return null; } - // TODO: After we've been through the chain up to the top of the module, - // now we need to get the namespace from the external file if such exists. - const fullyQualifiedLocalName = - varsDestructuringStack.originalChain.join("."); - const localName = varsDestructuringStack.originalChain[0]; - - if (!currentModule.localNames[localName]) { - return fullyQualifiedLocalName; - } return checkEnumsFromExternalModules(varsDestructuringStack.originalChain); } @@ -911,10 +900,20 @@ function convertValueWithRaw(node, type, propertyName) { } else if ( isMemberExpression(node) && type ) { // enum value (a.b.c) - const resolvedEnum = resolvePotemtialEnum(node); + const potentialEnum = resolvePotemtialEnum(node); + + // enum value (a.b.c) + value = getResolvedObjectName(node); + if ( value.indexOf(type + ".") === 0 ) { + // starts with fully qualified enum name -> cut off name + value = value.slice(type.length + 1); + return { + value: value, + raw: value + }; - if ( resolvedEnum ) { - return resolvedEnum; + } else if ( potentialEnum ) { + return potentialEnum; // } else if ( value.indexOf(type.split(".").slice(-1)[0] + ".") === 0 ) { // // unqualified name might be a local name (just a guess - would need static code analysis for proper solution) // return value.slice(type.split(".").slice(-1)[0].length + 1); From 584ad5e155a5ea9cf04b43bb0113d33ca25fabea Mon Sep 17 00:00:00 2001 From: Yavor Ivanov Date: Thu, 4 Aug 2022 16:23:01 +0300 Subject: [PATCH 09/69] Destructuring at function paramers --- lib/processors/jsdoc/lib/ui5/plugin.cjs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/lib/processors/jsdoc/lib/ui5/plugin.cjs b/lib/processors/jsdoc/lib/ui5/plugin.cjs index f4bd16fd4..43ff149d2 100644 --- a/lib/processors/jsdoc/lib/ui5/plugin.cjs +++ b/lib/processors/jsdoc/lib/ui5/plugin.cjs @@ -663,11 +663,7 @@ function checkEnumsFromExternalModules(varsDestructuringStack) { } // Check if the key is in the enums - if (enums.split("|").indexOf(potentialEnumKey) === -1) { - return false; - } - - return true; + return enums.split("|").includes(potentialEnumKey); }) .map((curEnumKey) => { return { From 6ef9ac966940cfc05f78821b8ad832ea40187168 Mon Sep 17 00:00:00 2001 From: Yavor Ivanov Date: Thu, 4 Aug 2022 16:53:52 +0300 Subject: [PATCH 10/69] Update documentation --- lib/processors/jsdoc/lib/ui5/plugin.cjs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/processors/jsdoc/lib/ui5/plugin.cjs b/lib/processors/jsdoc/lib/ui5/plugin.cjs index 43ff149d2..888bdd26e 100644 --- a/lib/processors/jsdoc/lib/ui5/plugin.cjs +++ b/lib/processors/jsdoc/lib/ui5/plugin.cjs @@ -644,6 +644,12 @@ function isPotentialEnum(node) { } // ---- ES6+ Destructuring --------------------------------------------------------- +/** + * Checks against currentModule.localNames to verify an enum imported from an external module + * + * @param {Array} varsDestructuringStack + * @returns {Object} + */ function checkEnumsFromExternalModules(varsDestructuringStack) { const localName = varsDestructuringStack[0]; const potentialEnumKey = @@ -674,6 +680,12 @@ function checkEnumsFromExternalModules(varsDestructuringStack) { })[0]; } +/** + * Tries to resolve an ENUM, regardless where it is defined and being destructured. + * + * @param {Node} node + * @returns {Object} + */ function resolvePotemtialEnum(node) { const varsDestructuringStack = getVarDestructuringChain(node); @@ -694,7 +706,7 @@ function resolvePotemtialEnum(node) { * * @param {Node} node * @param {String} varName - * @returns + * @returns {Object} */ function getVarDestructuringChain(node) { // The missing part is on the left side. The right side is clear. From eb4aa0ec5f7d9c4f48c67839188623c875bd1cb0 Mon Sep 17 00:00:00 2001 From: Yavor Ivanov Date: Fri, 5 Aug 2022 11:48:30 +0300 Subject: [PATCH 11/69] Cover cases where the var after destructuring does not look like an ENUM --- lib/processors/jsdoc/lib/ui5/plugin.cjs | 40 +++++++++++++++---------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/lib/processors/jsdoc/lib/ui5/plugin.cjs b/lib/processors/jsdoc/lib/ui5/plugin.cjs index 888bdd26e..a9e976fc2 100644 --- a/lib/processors/jsdoc/lib/ui5/plugin.cjs +++ b/lib/processors/jsdoc/lib/ui5/plugin.cjs @@ -684,9 +684,10 @@ function checkEnumsFromExternalModules(varsDestructuringStack) { * Tries to resolve an ENUM, regardless where it is defined and being destructured. * * @param {Node} node + * @param {String} type * @returns {Object} */ -function resolvePotemtialEnum(node) { +function resolvePotemtialEnum(node, type) { const varsDestructuringStack = getVarDestructuringChain(node); if ( @@ -697,7 +698,19 @@ function resolvePotemtialEnum(node) { return null; } + // When the fully qunatified name gets resolved, we could try the "old" approach by checking + // the type + key + let value = varsDestructuringStack.originalChain.join("."); + if ( value.indexOf(type + ".") === 0 ) { + // starts with fully qualified enum name -> cut off name + value = value.slice(type.length + 1); + return { + value: value, + raw: value + }; + } + // Otherwise look into the imported modules to check for potential enum definitions there return checkEnumsFromExternalModules(varsDestructuringStack.originalChain); } @@ -760,7 +773,7 @@ function getVarDestructuringChain(node) { const potentialRenaming = checkVarRenaming(curVar); const filteredValues = curVar.references .filter((ref) => ref.writeExpr) - .map((ref) => ref.writeExpr.name); + .map((ref) => getObjectName(ref.writeExpr)); acc.push({ ref: filteredValues[0], @@ -774,13 +787,13 @@ function getVarDestructuringChain(node) { return acc; }, [])[0]; - leftMostName = potentialChunk.ref; + leftMostName = potentialChunk && potentialChunk.ref; name = leftMostName ? leftMostName + "." + name : name; originalName = leftMostName ? leftMostName + "." + originalName : originalName; - if (potentialChunk.renamed) { + if (potentialChunk && potentialChunk.renamed) { originalName = originalName.replace( "." + potentialChunk.renamed + ".", "." + potentialChunk.original + "." @@ -908,19 +921,9 @@ function convertValueWithRaw(node, type, propertyName) { } else if ( isMemberExpression(node) && type ) { // enum value (a.b.c) - const potentialEnum = resolvePotemtialEnum(node); + const potentialEnum = resolvePotemtialEnum(node, type); - // enum value (a.b.c) - value = getResolvedObjectName(node); - if ( value.indexOf(type + ".") === 0 ) { - // starts with fully qualified enum name -> cut off name - value = value.slice(type.length + 1); - return { - value: value, - raw: value - }; - - } else if ( potentialEnum ) { + if ( potentialEnum ) { return potentialEnum; // } else if ( value.indexOf(type.split(".").slice(-1)[0] + ".") === 0 ) { // // unqualified name might be a local name (just a guess - would need static code analysis for proper solution) @@ -954,6 +957,11 @@ function convertValueWithRaw(node, type, propertyName) { raw: local.raw }; } + + const potentialEnum = resolvePotemtialEnum(node, type); + if ( potentialEnum ) { + return potentialEnum; + } } else if ( node.type === Syntax.ArrayExpression ) { if ( node.elements.length === 0 ) { From 95603bbd919de9036339978ba3c2855dd7e2f45e Mon Sep 17 00:00:00 2001 From: Yavor Ivanov Date: Fri, 5 Aug 2022 11:49:13 +0300 Subject: [PATCH 12/69] Enable the known test cases --- .../library.j/main/src/library/j/some.js | 53 ++++++++++--------- 1 file changed, 29 insertions(+), 24 deletions(-) diff --git a/test/fixtures/library.j/main/src/library/j/some.js b/test/fixtures/library.j/main/src/library/j/some.js index ac9d596c3..f13a0e977 100644 --- a/test/fixtures/library.j/main/src/library/j/some.js +++ b/test/fixtures/library.j/main/src/library/j/some.js @@ -8,12 +8,11 @@ sap.ui.define([ "./dependency-es6-1", "./dependency-es6-2", "./dependency-es6-3" -], function (Control, coreLib, library, es6_1, es6_2, es6_3) { - "use strict"; +], (Control, { MyValidEnum }, library, es6_1, es6_2, es6_3) => { - const { AnotherValidEnum: Zzz } = library; const { AnotherValidEnum } = library; const { Buzz } = AnotherValidEnum; + const { AnotherValidEnum: Zzz } = library; const { TitleLevel } = sap.ui.core; /** @@ -35,34 +34,40 @@ sap.ui.define([ metadata: { properties: { /** - * validPropertyDefaultValueEnumViaDestructuringInArrowFn + * validPropertyDefaultValueEnumSimpleDestructuring */ - validPropertyDefaultValueEnumViaDestructuringInArrowFn: - { - type: "testlib.MyValidEnum", - group: "Misc", - defaultValue: coreLib.MyValidEnum.Foo, - }, + validPropertyDefaultValueEnumSimpleDestructuring: { + type: "testlib.AnotherValidEnum", + group: "Misc", + defaultValue: AnotherValidEnum.Buzz, + }, /** - * validPropertyDefaultValueEnumViaDestructuringWithRename + * validPropertyDefaultValueEnumChainedDestructuring */ - validPropertyDefaultValueEnumViaDestructuringWithRename: - { - type: "testlib.AnotherValidEnum", - group: "Misc", - defaultValue: Zzz.Fizz, - }, + validPropertyDefaultValueEnumChainedDestructuring: { + type: "testlib.AnotherValidEnum", + group: "Misc", + defaultValue: Buzz, + }, /** - * validPropertyDefaultValueEnumViaHierarchicalDestructuring + * validPropertyDefaultValueEnumDestructuringWithRename */ - validPropertyDefaultValueEnumViaHierarchicalDestructuring: - { - type: "testlib.AnotherValidEnum", - group: "Misc", - defaultValue: Buzz, - }, + validPropertyDefaultValueEnumDestructuringWithRename: { + type: "testlib.AnotherValidEnum", + group: "Misc", + defaultValue: Zzz.Fizz, + }, + + /** + * validPropertyDefaultValueEnumViaDestructuringInArrowFn + */ + validPropertyDefaultValueEnumViaDestructuringInArrowFn: { + type: "testlib.MyValidEnum", + group: "Misc", + defaultValue: MyValidEnum.Foo, + }, /** * validPropertyDefaultValueEnumViaDestructuringGlobal From 1914d0517a11907188d57d16f573c8701ed10a86 Mon Sep 17 00:00:00 2001 From: Yavor Ivanov Date: Fri, 5 Aug 2022 14:50:11 +0300 Subject: [PATCH 13/69] Test: Align expectations with fixtures --- .../dest/resources/library/j/some.js | 53 ++++++++++--------- .../library/j/designtime/api.json | 2 +- 2 files changed, 30 insertions(+), 25 deletions(-) diff --git a/test/expected/build/library.j/dest/resources/library/j/some.js b/test/expected/build/library.j/dest/resources/library/j/some.js index 07a1ccba9..0addbc383 100644 --- a/test/expected/build/library.j/dest/resources/library/j/some.js +++ b/test/expected/build/library.j/dest/resources/library/j/some.js @@ -8,12 +8,11 @@ sap.ui.define([ "./dependency-es6-1", "./dependency-es6-2", "./dependency-es6-3" -], function (Control, coreLib, library, es6_1, , es6_2, , es6_3) { - "use strict"; +], (Control, { MyValidEnum }, library, es6_1, , es6_2, , es6_3) => { - const { AnotherValidEnum: Zzz } = library; const { AnotherValidEnum } = library; const { Buzz } = AnotherValidEnum; + const { AnotherValidEnum: Zzz } = library; const { TitleLevel } = sap.ui.core; /** @@ -35,34 +34,40 @@ sap.ui.define([ metadata: { properties: { /** - * validPropertyDefaultValueEnumViaDestructuringInArrowFn + * validPropertyDefaultValueEnumSimpleDestructuring */ - validPropertyDefaultValueEnumViaDestructuringInArrowFn: - { - type: "testlib.MyValidEnum", - group: "Misc", - defaultValue: coreLib.MyValidEnum.Foo, - }, + validPropertyDefaultValueEnumSimpleDestructuring: { + type: "testlib.AnotherValidEnum", + group: "Misc", + defaultValue: AnotherValidEnum.Buzz, + }, /** - * validPropertyDefaultValueEnumViaDestructuringWithRename + * validPropertyDefaultValueEnumChainedDestructuring */ - validPropertyDefaultValueEnumViaDestructuringWithRename: - { - type: "testlib.AnotherValidEnum", - group: "Misc", - defaultValue: Zzz.Fizz, - }, + validPropertyDefaultValueEnumChainedDestructuring: { + type: "testlib.AnotherValidEnum", + group: "Misc", + defaultValue: Buzz, + }, /** - * validPropertyDefaultValueEnumViaHierarchicalDestructuring + * validPropertyDefaultValueEnumDestructuringWithRename */ - validPropertyDefaultValueEnumViaHierarchicalDestructuring: - { - type: "testlib.AnotherValidEnum", - group: "Misc", - defaultValue: Buzz, - }, + validPropertyDefaultValueEnumDestructuringWithRename: { + type: "testlib.AnotherValidEnum", + group: "Misc", + defaultValue: Zzz.Fizz, + }, + + /** + * validPropertyDefaultValueEnumViaDestructuringInArrowFn + */ + validPropertyDefaultValueEnumViaDestructuringInArrowFn: { + type: "testlib.MyValidEnum", + group: "Misc", + defaultValue: MyValidEnum.Foo, + }, /** * validPropertyDefaultValueEnumViaDestructuringGlobal diff --git a/test/expected/build/library.j/dest/test-resources/library/j/designtime/api.json b/test/expected/build/library.j/dest/test-resources/library/j/designtime/api.json index 0bf0fd3a6..e88c0d538 100644 --- a/test/expected/build/library.j/dest/test-resources/library/j/designtime/api.json +++ b/test/expected/build/library.j/dest/test-resources/library/j/designtime/api.json @@ -1 +1 @@ -{"$schema-ref":"http://schemas.sap.com/sapui5/designtime/api.json/1.0","version":"1.0.0","library":"library.j","symbols":[{"kind":"namespace","name":"library.j","basename":"j","resource":"library/j/some.js","module":"library/j/some","static":true,"visibility":"public"},{"kind":"class","name":"library.j.aaa","basename":"aaa","resource":"library/j/dependency-es6-2.js","module":"library/j/dependency-es6-2","export":"","static":true,"visibility":"public","since":"1.22","extends":"library.j.a","ui5-metamodel":true,"ui5-metadata":{"properties":[{"name":"MyProp","type":"boolean","defaultValue":false,"group":"undefined","visibility":"public","since":"1.46","description":"MyProp property","methods":["getMyProp","setMyProp"]}]},"constructor":{"visibility":"public","parameters":[{"name":"sId","type":"string","optional":true,"description":"ID for the new control, generated automatically if no ID is given"},{"name":"mSettings","type":"object","optional":true,"description":"Initial settings for the new control"}],"description":"Constructor for a new library.j.aaa."},"methods":[{"name":"extend","visibility":"public","static":true,"returnValue":{"type":"function","description":"Created class / constructor function"},"parameters":[{"name":"sClassName","type":"string","optional":false,"description":"Name of the class being created"},{"name":"oClassInfo","type":"object","optional":true,"description":"Object literal with information about the class"},{"name":"FNMetaImpl","type":"function","optional":true,"description":"Constructor function for the metadata object; if not given, it defaults to the metadata implementation used by this class"}],"description":"Creates a new subclass of class library.j.aaa with name sClassName and enriches it with the information contained in oClassInfo.\n\noClassInfo might contain the same kind of information as described in {@link library.j.a.extend}."},{"name":"getMetadata","visibility":"public","static":true,"returnValue":{"type":"sap.ui.base.Metadata","description":"Metadata object describing this class"},"description":"Returns a metadata object for class library.j.aaa."},{"name":"getMyProp","visibility":"public","since":"1.46","returnValue":{"type":"boolean","description":"Value of property MyProp"},"description":"Gets current value of property {@link #getMyProp MyProp}.\n\nMyProp property\n\nDefault value is false."},{"name":"setMyProp","visibility":"public","since":"1.46","returnValue":{"type":"this","description":"Reference to this in order to allow method chaining"},"parameters":[{"name":"bMyProp","type":"boolean","optional":true,"defaultValue":false,"description":"New value for property MyProp"}],"description":"Sets a new value for property {@link #getMyProp MyProp}.\n\nMyProp property\n\nWhen called with a value of null or undefined, the default value of the property will be restored.\n\nDefault value is false."}]},{"kind":"class","name":"library.j.Foo","basename":"Foo","resource":"library/j/dependency-es6-1.js","module":"library/j/dependency-es6-1","static":true,"visibility":"public","extends":"library.j.Bar","description":"My super documentation of this class","constructor":{"visibility":"public"}}]} \ No newline at end of file +{"$schema-ref":"http://schemas.sap.com/sapui5/designtime/api.json/1.0","version":"1.0.0","library":"library.j","symbols":[{"kind":"enum","name":"testlib.AnotherValidEnum","basename":"AnotherValidEnum","resource":"library/j/dependency2.js","module":"library/j/dependency2","static":true,"visibility":"public","description":"AnotherValidEnum","ui5-metamodel":true,"ui5-metadata":{"stereotype":"enum"},"properties":[{"name":"Buzz","visibility":"public","static":true,"type":"string","description":"Bar"},{"name":"Fizz","visibility":"public","static":true,"type":"string","description":"Fizz"}]},{"kind":"enum","name":"testlib.MyValidEnum","basename":"MyValidEnum","resource":"library/j/dependency.js","module":"library/j/dependency","static":true,"visibility":"public","description":"MyValidEnum","ui5-metamodel":true,"ui5-metadata":{"stereotype":"enum"},"properties":[{"name":"Bar","visibility":"public","static":true,"type":"string","description":"Bar"},{"name":"Foo","visibility":"public","static":true,"type":"string","description":"Foo"}]},{"kind":"class","name":"testlib.ValidPropertyDefaultValue","basename":"ValidPropertyDefaultValue","resource":"library/j/some.js","module":"library/j/some","export":"","static":true,"visibility":"public","extends":"sap.ui.core.Control","description":"My super documentation of this class","ui5-metamodel":true,"ui5-metadata":{"stereotype":"control","properties":[{"name":"validPropertyDefaultValueEnumSimpleDestructuring","type":"testlib.AnotherValidEnum","defaultValue":"Buzz","group":"Misc","visibility":"public","description":"validPropertyDefaultValueEnumSimpleDestructuring","methods":["getValidPropertyDefaultValueEnumSimpleDestructuring","setValidPropertyDefaultValueEnumSimpleDestructuring"]},{"name":"validPropertyDefaultValueEnumChainedDestructuring","type":"testlib.AnotherValidEnum","defaultValue":"Buzz","group":"Misc","visibility":"public","description":"validPropertyDefaultValueEnumChainedDestructuring","methods":["getValidPropertyDefaultValueEnumChainedDestructuring","setValidPropertyDefaultValueEnumChainedDestructuring"]},{"name":"validPropertyDefaultValueEnumDestructuringWithRename","type":"testlib.AnotherValidEnum","defaultValue":"Fizz","group":"Misc","visibility":"public","description":"validPropertyDefaultValueEnumDestructuringWithRename","methods":["getValidPropertyDefaultValueEnumDestructuringWithRename","setValidPropertyDefaultValueEnumDestructuringWithRename"]},{"name":"validPropertyDefaultValueEnumViaDestructuringInArrowFn","type":"testlib.MyValidEnum","defaultValue":"Foo","group":"Misc","visibility":"public","description":"validPropertyDefaultValueEnumViaDestructuringInArrowFn","methods":["getValidPropertyDefaultValueEnumViaDestructuringInArrowFn","setValidPropertyDefaultValueEnumViaDestructuringInArrowFn"]},{"name":"validPropertyDefaultValueEnumViaDestructuringGlobal","type":"sap.ui.core","defaultValue":"TitleLevel","group":"Misc","visibility":"public","description":"validPropertyDefaultValueEnumViaDestructuringGlobal","methods":["getValidPropertyDefaultValueEnumViaDestructuringGlobal","setValidPropertyDefaultValueEnumViaDestructuringGlobal"]}]},"constructor":{"visibility":"public","description":"Accepts an object literal mSettings that defines initial property values, aggregated and associated objects as well as event handlers. See {@link sap.ui.base.ManagedObject#constructor} for a general description of the syntax of the settings object."},"methods":[{"name":"extend","visibility":"public","static":true,"returnValue":{"type":"function","description":"Created class / constructor function"},"parameters":[{"name":"sClassName","type":"string","optional":false,"description":"Name of the class being created"},{"name":"oClassInfo","type":"object","optional":true,"description":"Object literal with information about the class"},{"name":"FNMetaImpl","type":"function","optional":true,"description":"Constructor function for the metadata object; if not given, it defaults to the metadata implementation used by this class"}],"description":"Creates a new subclass of class testlib.ValidPropertyDefaultValue with name sClassName and enriches it with the information contained in oClassInfo.\n\noClassInfo might contain the same kind of information as described in {@link sap.ui.core.Control.extend}."},{"name":"getMetadata","visibility":"public","static":true,"returnValue":{"type":"sap.ui.base.Metadata","description":"Metadata object describing this class"},"description":"Returns a metadata object for class testlib.ValidPropertyDefaultValue."},{"name":"getValidPropertyDefaultValueEnumChainedDestructuring","visibility":"public","returnValue":{"type":"testlib.AnotherValidEnum","description":"Value of property validPropertyDefaultValueEnumChainedDestructuring"},"description":"Gets current value of property {@link #getValidPropertyDefaultValueEnumChainedDestructuring validPropertyDefaultValueEnumChainedDestructuring}.\n\nvalidPropertyDefaultValueEnumChainedDestructuring\n\nDefault value is Buzz."},{"name":"getValidPropertyDefaultValueEnumDestructuringWithRename","visibility":"public","returnValue":{"type":"testlib.AnotherValidEnum","description":"Value of property validPropertyDefaultValueEnumDestructuringWithRename"},"description":"Gets current value of property {@link #getValidPropertyDefaultValueEnumDestructuringWithRename validPropertyDefaultValueEnumDestructuringWithRename}.\n\nvalidPropertyDefaultValueEnumDestructuringWithRename\n\nDefault value is Fizz."},{"name":"getValidPropertyDefaultValueEnumSimpleDestructuring","visibility":"public","returnValue":{"type":"testlib.AnotherValidEnum","description":"Value of property validPropertyDefaultValueEnumSimpleDestructuring"},"description":"Gets current value of property {@link #getValidPropertyDefaultValueEnumSimpleDestructuring validPropertyDefaultValueEnumSimpleDestructuring}.\n\nvalidPropertyDefaultValueEnumSimpleDestructuring\n\nDefault value is Buzz."},{"name":"getValidPropertyDefaultValueEnumViaDestructuringGlobal","visibility":"public","returnValue":{"type":"sap.ui.core","description":"Value of property validPropertyDefaultValueEnumViaDestructuringGlobal"},"description":"Gets current value of property {@link #getValidPropertyDefaultValueEnumViaDestructuringGlobal validPropertyDefaultValueEnumViaDestructuringGlobal}.\n\nvalidPropertyDefaultValueEnumViaDestructuringGlobal\n\nDefault value is TitleLevel."},{"name":"getValidPropertyDefaultValueEnumViaDestructuringInArrowFn","visibility":"public","returnValue":{"type":"testlib.MyValidEnum","description":"Value of property validPropertyDefaultValueEnumViaDestructuringInArrowFn"},"description":"Gets current value of property {@link #getValidPropertyDefaultValueEnumViaDestructuringInArrowFn validPropertyDefaultValueEnumViaDestructuringInArrowFn}.\n\nvalidPropertyDefaultValueEnumViaDestructuringInArrowFn\n\nDefault value is Foo."},{"name":"setValidPropertyDefaultValueEnumChainedDestructuring","visibility":"public","returnValue":{"type":"this","description":"Reference to this in order to allow method chaining"},"parameters":[{"name":"sValidPropertyDefaultValueEnumChainedDestructuring","type":"testlib.AnotherValidEnum","optional":true,"defaultValue":"Buzz","description":"New value for property validPropertyDefaultValueEnumChainedDestructuring"}],"description":"Sets a new value for property {@link #getValidPropertyDefaultValueEnumChainedDestructuring validPropertyDefaultValueEnumChainedDestructuring}.\n\nvalidPropertyDefaultValueEnumChainedDestructuring\n\nWhen called with a value of null or undefined, the default value of the property will be restored.\n\nDefault value is Buzz."},{"name":"setValidPropertyDefaultValueEnumDestructuringWithRename","visibility":"public","returnValue":{"type":"this","description":"Reference to this in order to allow method chaining"},"parameters":[{"name":"sValidPropertyDefaultValueEnumDestructuringWithRename","type":"testlib.AnotherValidEnum","optional":true,"defaultValue":"Fizz","description":"New value for property validPropertyDefaultValueEnumDestructuringWithRename"}],"description":"Sets a new value for property {@link #getValidPropertyDefaultValueEnumDestructuringWithRename validPropertyDefaultValueEnumDestructuringWithRename}.\n\nvalidPropertyDefaultValueEnumDestructuringWithRename\n\nWhen called with a value of null or undefined, the default value of the property will be restored.\n\nDefault value is Fizz."},{"name":"setValidPropertyDefaultValueEnumSimpleDestructuring","visibility":"public","returnValue":{"type":"this","description":"Reference to this in order to allow method chaining"},"parameters":[{"name":"sValidPropertyDefaultValueEnumSimpleDestructuring","type":"testlib.AnotherValidEnum","optional":true,"defaultValue":"Buzz","description":"New value for property validPropertyDefaultValueEnumSimpleDestructuring"}],"description":"Sets a new value for property {@link #getValidPropertyDefaultValueEnumSimpleDestructuring validPropertyDefaultValueEnumSimpleDestructuring}.\n\nvalidPropertyDefaultValueEnumSimpleDestructuring\n\nWhen called with a value of null or undefined, the default value of the property will be restored.\n\nDefault value is Buzz."},{"name":"setValidPropertyDefaultValueEnumViaDestructuringGlobal","visibility":"public","returnValue":{"type":"this","description":"Reference to this in order to allow method chaining"},"parameters":[{"name":"sValidPropertyDefaultValueEnumViaDestructuringGlobal","type":"sap.ui.core","optional":true,"defaultValue":"TitleLevel","description":"New value for property validPropertyDefaultValueEnumViaDestructuringGlobal"}],"description":"Sets a new value for property {@link #getValidPropertyDefaultValueEnumViaDestructuringGlobal validPropertyDefaultValueEnumViaDestructuringGlobal}.\n\nvalidPropertyDefaultValueEnumViaDestructuringGlobal\n\nWhen called with a value of null or undefined, the default value of the property will be restored.\n\nDefault value is TitleLevel."},{"name":"setValidPropertyDefaultValueEnumViaDestructuringInArrowFn","visibility":"public","returnValue":{"type":"this","description":"Reference to this in order to allow method chaining"},"parameters":[{"name":"sValidPropertyDefaultValueEnumViaDestructuringInArrowFn","type":"testlib.MyValidEnum","optional":true,"defaultValue":"Foo","description":"New value for property validPropertyDefaultValueEnumViaDestructuringInArrowFn"}],"description":"Sets a new value for property {@link #getValidPropertyDefaultValueEnumViaDestructuringInArrowFn validPropertyDefaultValueEnumViaDestructuringInArrowFn}.\n\nvalidPropertyDefaultValueEnumViaDestructuringInArrowFn\n\nWhen called with a value of null or undefined, the default value of the property will be restored.\n\nDefault value is Foo."}]}]} \ No newline at end of file From b0f7ad0d0fe403832c299f768e4303ade05cbdb1 Mon Sep 17 00:00:00 2001 From: Yavor Ivanov Date: Fri, 5 Aug 2022 15:01:37 +0300 Subject: [PATCH 14/69] Refactoring --- lib/processors/jsdoc/lib/ui5/plugin.cjs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/processors/jsdoc/lib/ui5/plugin.cjs b/lib/processors/jsdoc/lib/ui5/plugin.cjs index a9e976fc2..68db90673 100644 --- a/lib/processors/jsdoc/lib/ui5/plugin.cjs +++ b/lib/processors/jsdoc/lib/ui5/plugin.cjs @@ -688,7 +688,7 @@ function checkEnumsFromExternalModules(varsDestructuringStack) { * @returns {Object} */ function resolvePotemtialEnum(node, type) { - const varsDestructuringStack = getVarDestructuringChain(node); + const varsDestructuringStack = resolveFullyQunatifiedName(node); if ( !varsDestructuringStack || @@ -718,10 +718,9 @@ function resolvePotemtialEnum(node, type) { * Builds the fully qunatified name when there's a destrcturing of a variable * * @param {Node} node - * @param {String} varName * @returns {Object} */ -function getVarDestructuringChain(node) { +function resolveFullyQunatifiedName(node) { // The missing part is on the left side. The right side is clear. // We would eiter ways would resolve to the same leftmost token. let leftMostName = getLeftmostName(node); From 27f44dad49017fd9364a70c0d49925408a40109d Mon Sep 17 00:00:00 2001 From: Yavor Ivanov Date: Thu, 11 Aug 2022 16:14:31 +0300 Subject: [PATCH 15/69] Refactor: Cover cases from MVN plugin + cleanup --- lib/processors/jsdoc/lib/ui5/plugin.cjs | 126 ++++++++++++------------ 1 file changed, 62 insertions(+), 64 deletions(-) diff --git a/lib/processors/jsdoc/lib/ui5/plugin.cjs b/lib/processors/jsdoc/lib/ui5/plugin.cjs index 68db90673..25171a06c 100644 --- a/lib/processors/jsdoc/lib/ui5/plugin.cjs +++ b/lib/processors/jsdoc/lib/ui5/plugin.cjs @@ -644,42 +644,6 @@ function isPotentialEnum(node) { } // ---- ES6+ Destructuring --------------------------------------------------------- -/** - * Checks against currentModule.localNames to verify an enum imported from an external module - * - * @param {Array} varsDestructuringStack - * @returns {Object} - */ -function checkEnumsFromExternalModules(varsDestructuringStack) { - const localName = varsDestructuringStack[0]; - const potentialEnumKey = - varsDestructuringStack[varsDestructuringStack.length - 1]; - - const curModuleNames = currentModule.localNames[localName] || {}; - const localModule = curModuleNames.module || curModuleNames.class; - - // Find if there are enums defined for that module - return Object.keys(enumValues) - .filter((curEnumKey) => { - const [enums, resource] = curEnumKey.split("||"); - - // Check the resource - if (resource.indexOf(localModule) === -1) { - return false; - } - - // Check if the key is in the enums - return enums.split("|").includes(potentialEnumKey); - }) - .map((curEnumKey) => { - return { - raw: potentialEnumKey, - value: potentialEnumKey, - // value: enumValues[curEnumKey][potentialEnumKey], // If needed, the Runtime value could be accessed like this - }; - })[0]; -} - /** * Tries to resolve an ENUM, regardless where it is defined and being destructured. * @@ -688,19 +652,16 @@ function checkEnumsFromExternalModules(varsDestructuringStack) { * @returns {Object} */ function resolvePotemtialEnum(node, type) { - const varsDestructuringStack = resolveFullyQunatifiedName(node); + const varsDestructuringStack = resolveFullyQunatifiedName(node, type); - if ( - !varsDestructuringStack || - !varsDestructuringStack.originalChain || - !varsDestructuringStack.originalChain.length - ) { + if (!varsDestructuringStack || !varsDestructuringStack.length) { return null; } // When the fully qunatified name gets resolved, we could try the "old" approach by checking // the type + key - let value = varsDestructuringStack.originalChain.join("."); + let value = varsDestructuringStack.join("."); + if ( value.indexOf(type + ".") === 0 ) { // starts with fully qualified enum name -> cut off name value = value.slice(type.length + 1); @@ -709,23 +670,20 @@ function resolvePotemtialEnum(node, type) { raw: value }; } - - // Otherwise look into the imported modules to check for potential enum definitions there - return checkEnumsFromExternalModules(varsDestructuringStack.originalChain); } /** * Builds the fully qunatified name when there's a destrcturing of a variable * * @param {Node} node + * @param {String} type * @returns {Object} */ -function resolveFullyQunatifiedName(node) { +function resolveFullyQunatifiedName(node, type) { // The missing part is on the left side. The right side is clear. // We would eiter ways would resolve to the same leftmost token. let leftMostName = getLeftmostName(node); - let name = getObjectName(node) || ""; - let originalName = name; + let originalName = getObjectName(node) || ""; const currentScope = getEnclosingVariableScope(node); if (!currentScope) { @@ -738,7 +696,7 @@ function resolveFullyQunatifiedName(node) { // variable.defs[0].node.id.properties[0].key.name === variable.name; // Original // variable.defs[0].node.id.properties[0].value.name === variable.name; // Renamed - return variable.defs + let potentialRename = variable.defs .filter( (def) => def.node && @@ -761,6 +719,22 @@ function resolveFullyQunatifiedName(node) { .map((prop) => { return { original: prop.key.name, renamed: prop.value.name }; })[0]; + + if (potentialRename) { + return potentialRename; + } + + // var AriaHasPopup = sap.ui.core.aria.HasPopup; -> AriaHasPopup.None + potentialRename = + variable.defs.filter( + (def) => + def.node && def.node.id && def.node.id.type === Syntax.Identifier + ) + .map((def) => { + return { original: getResolvedObjectName(def.name), replaced: def.name.name }; + })[0]; + + return potentialRename; }; // TODO: Check for hierarchical destructuring @@ -772,38 +746,62 @@ function resolveFullyQunatifiedName(node) { const potentialRenaming = checkVarRenaming(curVar); const filteredValues = curVar.references .filter((ref) => ref.writeExpr) - .map((ref) => getObjectName(ref.writeExpr)); + .map((ref) => { + const curNode = ref.writeExpr; + if ( curNode.type === Syntax.MemberExpression && !curNode.computed && curNode.object.type === Syntax.Identifier ) { + return curNode.object.name; + } else if (curNode.type === Syntax.MemberExpression && curNode.object.type === Syntax.MemberExpression) { // Standalone variable without leading dot notation namespace + return getResolvedObjectName(curNode); + } + + return (curNode && curNode.name) || ""; + }); acc.push({ ref: filteredValues[0], original: potentialRenaming ? potentialRenaming.original : curVar.name, - renamed: potentialRenaming - ? potentialRenaming.renamed - : null, + renamed: potentialRenaming ? potentialRenaming.renamed : null, + replaced: potentialRenaming ? potentialRenaming.replaced : null, }); return acc; }, [])[0]; leftMostName = potentialChunk && potentialChunk.ref; - name = leftMostName ? leftMostName + "." + name : name; - originalName = leftMostName - ? leftMostName + "." + originalName - : originalName; + + if (potentialChunk && potentialChunk.replaced) { + originalName = originalName.replace(potentialChunk.replaced, potentialChunk.original); + } else { + originalName = leftMostName + ? leftMostName + "." + originalName + : originalName; + } if (potentialChunk && potentialChunk.renamed) { originalName = originalName.replace( - "." + potentialChunk.renamed + ".", - "." + potentialChunk.original + "." + potentialChunk.renamed + ".", + potentialChunk.original + "." ); } } - return { - renamedChain: name.split("."), - originalChain: originalName.split("."), - }; + // When an enum is defined in an external module, we cannot rely that this module is loaded and we could + // read from enumValues variable. Therefore we need to resolve the enum name from the type. + // The imported dependency name would be replaced by the type i.e. IF type: "sap.ui.core" THEN coreLibrary -> sap.ui.core + // The leftMostChunk is the (eventual) dependency name i.e. coreLibrary + let originalNameChunks = originalName.split("."); + let typeChunks = type.split(".") + const firstMatchedChunkIndex = originalNameChunks.findIndex((chunk) => typeChunks.indexOf(chunk) !== -1); + + if (firstMatchedChunkIndex !== -1) { + originalNameChunks = originalNameChunks.slice(firstMatchedChunkIndex); + const typeIndex = typeChunks.indexOf(originalNameChunks[0]); + typeChunks = typeChunks.slice(0, typeIndex); + originalNameChunks = typeChunks.concat(originalNameChunks); + } + + return originalNameChunks; } /** From 116de020b9dfac495552f3d131117713914242a9 Mon Sep 17 00:00:00 2001 From: Yavor Ivanov Date: Fri, 12 Aug 2022 14:52:38 +0300 Subject: [PATCH 16/69] Refactor getEnclosingVariableScope to be more generic --- lib/processors/jsdoc/lib/ui5/plugin.cjs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/processors/jsdoc/lib/ui5/plugin.cjs b/lib/processors/jsdoc/lib/ui5/plugin.cjs index 25171a06c..ca9c6261a 100644 --- a/lib/processors/jsdoc/lib/ui5/plugin.cjs +++ b/lib/processors/jsdoc/lib/ui5/plugin.cjs @@ -116,6 +116,9 @@ let docletUid = 0; let currentProgram; +// Scope Manager +let scopeManager; + /** * Information about the current module. * @@ -813,18 +816,18 @@ function resolveFullyQunatifiedName(node, type) { function getEnclosingVariableScope (node) { // Get to the nearest upper scope let nearestScopeableNode = node; + let neatestScope = scopeManager.acquire(nearestScopeableNode); while ( - nearestScopeableNode && nearestScopeableNode.type && - nearestScopeableNode.type !== Syntax.ArrowFunctionExpression && - nearestScopeableNode.type !== Syntax.FunctionDeclaration && - nearestScopeableNode.type !== Syntax.FunctionExpression + !neatestScope && + nearestScopeableNode && + nearestScopeableNode.parent ) { nearestScopeableNode = nearestScopeableNode.parent; + neatestScope = scopeManager.acquire(nearestScopeableNode); } - const scopeManager = escope.analyze(currentProgram); // Get the scope of the nearest scopeable node - return scopeManager.acquire(nearestScopeableNode); + return neatestScope; }; function isCompileTimeConstant(node) { @@ -2881,6 +2884,7 @@ exports.astNodeVisitor = { if ( node.type === Syntax.Program ) { currentProgram = node; + scopeManager = escope.analyze(currentProgram); } function processExtendCall(extendCall, comment, commentAlreadyProcessed) { From 3d69b1d91776eb7e128ee88de5ac92c802b5521d Mon Sep 17 00:00:00 2001 From: Yavor Ivanov Date: Tue, 16 Aug 2022 13:31:56 +0300 Subject: [PATCH 17/69] Fix typos --- lib/processors/jsdoc/lib/ui5/plugin.cjs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/processors/jsdoc/lib/ui5/plugin.cjs b/lib/processors/jsdoc/lib/ui5/plugin.cjs index ca9c6261a..5df068187 100644 --- a/lib/processors/jsdoc/lib/ui5/plugin.cjs +++ b/lib/processors/jsdoc/lib/ui5/plugin.cjs @@ -654,14 +654,14 @@ function isPotentialEnum(node) { * @param {String} type * @returns {Object} */ -function resolvePotemtialEnum(node, type) { - const varsDestructuringStack = resolveFullyQunatifiedName(node, type); +function resolvePotentialEnum(node, type) { + const varsDestructuringStack = resolveFullyQuantifiedName(node, type); if (!varsDestructuringStack || !varsDestructuringStack.length) { return null; } - // When the fully qunatified name gets resolved, we could try the "old" approach by checking + // When the fully quantified name gets resolved, we could try the "old" approach by checking // the type + key let value = varsDestructuringStack.join("."); @@ -676,13 +676,13 @@ function resolvePotemtialEnum(node, type) { } /** - * Builds the fully qunatified name when there's a destrcturing of a variable + * Builds the fully quantified name when there's a destructuring of a variable * * @param {Node} node * @param {String} type * @returns {Object} */ -function resolveFullyQunatifiedName(node, type) { +function resolveFullyQuantifiedName(node, type) { // The missing part is on the left side. The right side is clear. // We would eiter ways would resolve to the same leftmost token. let leftMostName = getLeftmostName(node); @@ -921,7 +921,7 @@ function convertValueWithRaw(node, type, propertyName) { } else if ( isMemberExpression(node) && type ) { // enum value (a.b.c) - const potentialEnum = resolvePotemtialEnum(node, type); + const potentialEnum = resolvePotentialEnum(node, type); if ( potentialEnum ) { return potentialEnum; @@ -958,7 +958,7 @@ function convertValueWithRaw(node, type, propertyName) { }; } - const potentialEnum = resolvePotemtialEnum(node, type); + const potentialEnum = resolvePotentialEnum(node, type); if ( potentialEnum ) { return potentialEnum; } From 44d3fbe4527e334d120000ca678533799ed8c7da Mon Sep 17 00:00:00 2001 From: Yavor Ivanov Date: Wed, 17 Aug 2022 12:53:52 +0300 Subject: [PATCH 18/69] Fix test cases --- .../build/library.j/dest/resources/library/j/some.js | 6 +++--- .../dest/test-resources/library/j/designtime/api.json | 2 +- test/fixtures/library.j/main/src/library/j/some.js | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/test/expected/build/library.j/dest/resources/library/j/some.js b/test/expected/build/library.j/dest/resources/library/j/some.js index 0addbc383..28f318d95 100644 --- a/test/expected/build/library.j/dest/resources/library/j/some.js +++ b/test/expected/build/library.j/dest/resources/library/j/some.js @@ -13,7 +13,7 @@ sap.ui.define([ const { AnotherValidEnum } = library; const { Buzz } = AnotherValidEnum; const { AnotherValidEnum: Zzz } = library; - const { TitleLevel } = sap.ui.core; + const { H1 } = sap.ui.core.TitleLevel; /** * @class @@ -73,9 +73,9 @@ sap.ui.define([ * validPropertyDefaultValueEnumViaDestructuringGlobal */ validPropertyDefaultValueEnumViaDestructuringGlobal: { - type: "sap.ui.core", + type: "sap.ui.core.TitleLevel", group: "Misc", - defaultValue: TitleLevel, + defaultValue: H1, }, }, }, diff --git a/test/expected/build/library.j/dest/test-resources/library/j/designtime/api.json b/test/expected/build/library.j/dest/test-resources/library/j/designtime/api.json index e88c0d538..1078c4932 100644 --- a/test/expected/build/library.j/dest/test-resources/library/j/designtime/api.json +++ b/test/expected/build/library.j/dest/test-resources/library/j/designtime/api.json @@ -1 +1 @@ -{"$schema-ref":"http://schemas.sap.com/sapui5/designtime/api.json/1.0","version":"1.0.0","library":"library.j","symbols":[{"kind":"enum","name":"testlib.AnotherValidEnum","basename":"AnotherValidEnum","resource":"library/j/dependency2.js","module":"library/j/dependency2","static":true,"visibility":"public","description":"AnotherValidEnum","ui5-metamodel":true,"ui5-metadata":{"stereotype":"enum"},"properties":[{"name":"Buzz","visibility":"public","static":true,"type":"string","description":"Bar"},{"name":"Fizz","visibility":"public","static":true,"type":"string","description":"Fizz"}]},{"kind":"enum","name":"testlib.MyValidEnum","basename":"MyValidEnum","resource":"library/j/dependency.js","module":"library/j/dependency","static":true,"visibility":"public","description":"MyValidEnum","ui5-metamodel":true,"ui5-metadata":{"stereotype":"enum"},"properties":[{"name":"Bar","visibility":"public","static":true,"type":"string","description":"Bar"},{"name":"Foo","visibility":"public","static":true,"type":"string","description":"Foo"}]},{"kind":"class","name":"testlib.ValidPropertyDefaultValue","basename":"ValidPropertyDefaultValue","resource":"library/j/some.js","module":"library/j/some","export":"","static":true,"visibility":"public","extends":"sap.ui.core.Control","description":"My super documentation of this class","ui5-metamodel":true,"ui5-metadata":{"stereotype":"control","properties":[{"name":"validPropertyDefaultValueEnumSimpleDestructuring","type":"testlib.AnotherValidEnum","defaultValue":"Buzz","group":"Misc","visibility":"public","description":"validPropertyDefaultValueEnumSimpleDestructuring","methods":["getValidPropertyDefaultValueEnumSimpleDestructuring","setValidPropertyDefaultValueEnumSimpleDestructuring"]},{"name":"validPropertyDefaultValueEnumChainedDestructuring","type":"testlib.AnotherValidEnum","defaultValue":"Buzz","group":"Misc","visibility":"public","description":"validPropertyDefaultValueEnumChainedDestructuring","methods":["getValidPropertyDefaultValueEnumChainedDestructuring","setValidPropertyDefaultValueEnumChainedDestructuring"]},{"name":"validPropertyDefaultValueEnumDestructuringWithRename","type":"testlib.AnotherValidEnum","defaultValue":"Fizz","group":"Misc","visibility":"public","description":"validPropertyDefaultValueEnumDestructuringWithRename","methods":["getValidPropertyDefaultValueEnumDestructuringWithRename","setValidPropertyDefaultValueEnumDestructuringWithRename"]},{"name":"validPropertyDefaultValueEnumViaDestructuringInArrowFn","type":"testlib.MyValidEnum","defaultValue":"Foo","group":"Misc","visibility":"public","description":"validPropertyDefaultValueEnumViaDestructuringInArrowFn","methods":["getValidPropertyDefaultValueEnumViaDestructuringInArrowFn","setValidPropertyDefaultValueEnumViaDestructuringInArrowFn"]},{"name":"validPropertyDefaultValueEnumViaDestructuringGlobal","type":"sap.ui.core","defaultValue":"TitleLevel","group":"Misc","visibility":"public","description":"validPropertyDefaultValueEnumViaDestructuringGlobal","methods":["getValidPropertyDefaultValueEnumViaDestructuringGlobal","setValidPropertyDefaultValueEnumViaDestructuringGlobal"]}]},"constructor":{"visibility":"public","description":"Accepts an object literal mSettings that defines initial property values, aggregated and associated objects as well as event handlers. See {@link sap.ui.base.ManagedObject#constructor} for a general description of the syntax of the settings object."},"methods":[{"name":"extend","visibility":"public","static":true,"returnValue":{"type":"function","description":"Created class / constructor function"},"parameters":[{"name":"sClassName","type":"string","optional":false,"description":"Name of the class being created"},{"name":"oClassInfo","type":"object","optional":true,"description":"Object literal with information about the class"},{"name":"FNMetaImpl","type":"function","optional":true,"description":"Constructor function for the metadata object; if not given, it defaults to the metadata implementation used by this class"}],"description":"Creates a new subclass of class testlib.ValidPropertyDefaultValue with name sClassName and enriches it with the information contained in oClassInfo.\n\noClassInfo might contain the same kind of information as described in {@link sap.ui.core.Control.extend}."},{"name":"getMetadata","visibility":"public","static":true,"returnValue":{"type":"sap.ui.base.Metadata","description":"Metadata object describing this class"},"description":"Returns a metadata object for class testlib.ValidPropertyDefaultValue."},{"name":"getValidPropertyDefaultValueEnumChainedDestructuring","visibility":"public","returnValue":{"type":"testlib.AnotherValidEnum","description":"Value of property validPropertyDefaultValueEnumChainedDestructuring"},"description":"Gets current value of property {@link #getValidPropertyDefaultValueEnumChainedDestructuring validPropertyDefaultValueEnumChainedDestructuring}.\n\nvalidPropertyDefaultValueEnumChainedDestructuring\n\nDefault value is Buzz."},{"name":"getValidPropertyDefaultValueEnumDestructuringWithRename","visibility":"public","returnValue":{"type":"testlib.AnotherValidEnum","description":"Value of property validPropertyDefaultValueEnumDestructuringWithRename"},"description":"Gets current value of property {@link #getValidPropertyDefaultValueEnumDestructuringWithRename validPropertyDefaultValueEnumDestructuringWithRename}.\n\nvalidPropertyDefaultValueEnumDestructuringWithRename\n\nDefault value is Fizz."},{"name":"getValidPropertyDefaultValueEnumSimpleDestructuring","visibility":"public","returnValue":{"type":"testlib.AnotherValidEnum","description":"Value of property validPropertyDefaultValueEnumSimpleDestructuring"},"description":"Gets current value of property {@link #getValidPropertyDefaultValueEnumSimpleDestructuring validPropertyDefaultValueEnumSimpleDestructuring}.\n\nvalidPropertyDefaultValueEnumSimpleDestructuring\n\nDefault value is Buzz."},{"name":"getValidPropertyDefaultValueEnumViaDestructuringGlobal","visibility":"public","returnValue":{"type":"sap.ui.core","description":"Value of property validPropertyDefaultValueEnumViaDestructuringGlobal"},"description":"Gets current value of property {@link #getValidPropertyDefaultValueEnumViaDestructuringGlobal validPropertyDefaultValueEnumViaDestructuringGlobal}.\n\nvalidPropertyDefaultValueEnumViaDestructuringGlobal\n\nDefault value is TitleLevel."},{"name":"getValidPropertyDefaultValueEnumViaDestructuringInArrowFn","visibility":"public","returnValue":{"type":"testlib.MyValidEnum","description":"Value of property validPropertyDefaultValueEnumViaDestructuringInArrowFn"},"description":"Gets current value of property {@link #getValidPropertyDefaultValueEnumViaDestructuringInArrowFn validPropertyDefaultValueEnumViaDestructuringInArrowFn}.\n\nvalidPropertyDefaultValueEnumViaDestructuringInArrowFn\n\nDefault value is Foo."},{"name":"setValidPropertyDefaultValueEnumChainedDestructuring","visibility":"public","returnValue":{"type":"this","description":"Reference to this in order to allow method chaining"},"parameters":[{"name":"sValidPropertyDefaultValueEnumChainedDestructuring","type":"testlib.AnotherValidEnum","optional":true,"defaultValue":"Buzz","description":"New value for property validPropertyDefaultValueEnumChainedDestructuring"}],"description":"Sets a new value for property {@link #getValidPropertyDefaultValueEnumChainedDestructuring validPropertyDefaultValueEnumChainedDestructuring}.\n\nvalidPropertyDefaultValueEnumChainedDestructuring\n\nWhen called with a value of null or undefined, the default value of the property will be restored.\n\nDefault value is Buzz."},{"name":"setValidPropertyDefaultValueEnumDestructuringWithRename","visibility":"public","returnValue":{"type":"this","description":"Reference to this in order to allow method chaining"},"parameters":[{"name":"sValidPropertyDefaultValueEnumDestructuringWithRename","type":"testlib.AnotherValidEnum","optional":true,"defaultValue":"Fizz","description":"New value for property validPropertyDefaultValueEnumDestructuringWithRename"}],"description":"Sets a new value for property {@link #getValidPropertyDefaultValueEnumDestructuringWithRename validPropertyDefaultValueEnumDestructuringWithRename}.\n\nvalidPropertyDefaultValueEnumDestructuringWithRename\n\nWhen called with a value of null or undefined, the default value of the property will be restored.\n\nDefault value is Fizz."},{"name":"setValidPropertyDefaultValueEnumSimpleDestructuring","visibility":"public","returnValue":{"type":"this","description":"Reference to this in order to allow method chaining"},"parameters":[{"name":"sValidPropertyDefaultValueEnumSimpleDestructuring","type":"testlib.AnotherValidEnum","optional":true,"defaultValue":"Buzz","description":"New value for property validPropertyDefaultValueEnumSimpleDestructuring"}],"description":"Sets a new value for property {@link #getValidPropertyDefaultValueEnumSimpleDestructuring validPropertyDefaultValueEnumSimpleDestructuring}.\n\nvalidPropertyDefaultValueEnumSimpleDestructuring\n\nWhen called with a value of null or undefined, the default value of the property will be restored.\n\nDefault value is Buzz."},{"name":"setValidPropertyDefaultValueEnumViaDestructuringGlobal","visibility":"public","returnValue":{"type":"this","description":"Reference to this in order to allow method chaining"},"parameters":[{"name":"sValidPropertyDefaultValueEnumViaDestructuringGlobal","type":"sap.ui.core","optional":true,"defaultValue":"TitleLevel","description":"New value for property validPropertyDefaultValueEnumViaDestructuringGlobal"}],"description":"Sets a new value for property {@link #getValidPropertyDefaultValueEnumViaDestructuringGlobal validPropertyDefaultValueEnumViaDestructuringGlobal}.\n\nvalidPropertyDefaultValueEnumViaDestructuringGlobal\n\nWhen called with a value of null or undefined, the default value of the property will be restored.\n\nDefault value is TitleLevel."},{"name":"setValidPropertyDefaultValueEnumViaDestructuringInArrowFn","visibility":"public","returnValue":{"type":"this","description":"Reference to this in order to allow method chaining"},"parameters":[{"name":"sValidPropertyDefaultValueEnumViaDestructuringInArrowFn","type":"testlib.MyValidEnum","optional":true,"defaultValue":"Foo","description":"New value for property validPropertyDefaultValueEnumViaDestructuringInArrowFn"}],"description":"Sets a new value for property {@link #getValidPropertyDefaultValueEnumViaDestructuringInArrowFn validPropertyDefaultValueEnumViaDestructuringInArrowFn}.\n\nvalidPropertyDefaultValueEnumViaDestructuringInArrowFn\n\nWhen called with a value of null or undefined, the default value of the property will be restored.\n\nDefault value is Foo."}]}]} \ No newline at end of file +{"$schema-ref":"http://schemas.sap.com/sapui5/designtime/api.json/1.0","version":"1.0.0","library":"library.j","symbols":[{"kind":"enum","name":"testlib.AnotherValidEnum","basename":"AnotherValidEnum","resource":"library/j/dependency2.js","module":"library/j/dependency2","static":true,"visibility":"public","description":"AnotherValidEnum","ui5-metamodel":true,"ui5-metadata":{"stereotype":"enum"},"properties":[{"name":"Buzz","visibility":"public","static":true,"type":"string","description":"Bar"},{"name":"Fizz","visibility":"public","static":true,"type":"string","description":"Fizz"}]},{"kind":"enum","name":"testlib.MyValidEnum","basename":"MyValidEnum","resource":"library/j/dependency.js","module":"library/j/dependency","static":true,"visibility":"public","description":"MyValidEnum","ui5-metamodel":true,"ui5-metadata":{"stereotype":"enum"},"properties":[{"name":"Bar","visibility":"public","static":true,"type":"string","description":"Bar"},{"name":"Foo","visibility":"public","static":true,"type":"string","description":"Foo"}]},{"kind":"class","name":"testlib.ValidPropertyDefaultValue","basename":"ValidPropertyDefaultValue","resource":"library/j/some.js","module":"library/j/some","export":"","static":true,"visibility":"public","extends":"sap.ui.core.Control","description":"My super documentation of this class","ui5-metamodel":true,"ui5-metadata":{"stereotype":"control","properties":[{"name":"validPropertyDefaultValueEnumSimpleDestructuring","type":"testlib.AnotherValidEnum","defaultValue":"Buzz","group":"Misc","visibility":"public","description":"validPropertyDefaultValueEnumSimpleDestructuring","methods":["getValidPropertyDefaultValueEnumSimpleDestructuring","setValidPropertyDefaultValueEnumSimpleDestructuring"]},{"name":"validPropertyDefaultValueEnumChainedDestructuring","type":"testlib.AnotherValidEnum","defaultValue":"Buzz","group":"Misc","visibility":"public","description":"validPropertyDefaultValueEnumChainedDestructuring","methods":["getValidPropertyDefaultValueEnumChainedDestructuring","setValidPropertyDefaultValueEnumChainedDestructuring"]},{"name":"validPropertyDefaultValueEnumDestructuringWithRename","type":"testlib.AnotherValidEnum","defaultValue":"Fizz","group":"Misc","visibility":"public","description":"validPropertyDefaultValueEnumDestructuringWithRename","methods":["getValidPropertyDefaultValueEnumDestructuringWithRename","setValidPropertyDefaultValueEnumDestructuringWithRename"]},{"name":"validPropertyDefaultValueEnumViaDestructuringInArrowFn","type":"testlib.MyValidEnum","defaultValue":"Foo","group":"Misc","visibility":"public","description":"validPropertyDefaultValueEnumViaDestructuringInArrowFn","methods":["getValidPropertyDefaultValueEnumViaDestructuringInArrowFn","setValidPropertyDefaultValueEnumViaDestructuringInArrowFn"]},{"name":"validPropertyDefaultValueEnumViaDestructuringGlobal","type":"sap.ui.core.TitleLevel","defaultValue":"H1","group":"Misc","visibility":"public","description":"validPropertyDefaultValueEnumViaDestructuringGlobal","methods":["getValidPropertyDefaultValueEnumViaDestructuringGlobal","setValidPropertyDefaultValueEnumViaDestructuringGlobal"]}]},"constructor":{"visibility":"public","description":"Accepts an object literal mSettings that defines initial property values, aggregated and associated objects as well as event handlers. See {@link sap.ui.base.ManagedObject#constructor} for a general description of the syntax of the settings object."},"methods":[{"name":"extend","visibility":"public","static":true,"returnValue":{"type":"function","description":"Created class / constructor function"},"parameters":[{"name":"sClassName","type":"string","optional":false,"description":"Name of the class being created"},{"name":"oClassInfo","type":"object","optional":true,"description":"Object literal with information about the class"},{"name":"FNMetaImpl","type":"function","optional":true,"description":"Constructor function for the metadata object; if not given, it defaults to the metadata implementation used by this class"}],"description":"Creates a new subclass of class testlib.ValidPropertyDefaultValue with name sClassName and enriches it with the information contained in oClassInfo.\n\noClassInfo might contain the same kind of information as described in {@link sap.ui.core.Control.extend}."},{"name":"getMetadata","visibility":"public","static":true,"returnValue":{"type":"sap.ui.base.Metadata","description":"Metadata object describing this class"},"description":"Returns a metadata object for class testlib.ValidPropertyDefaultValue."},{"name":"getValidPropertyDefaultValueEnumChainedDestructuring","visibility":"public","returnValue":{"type":"testlib.AnotherValidEnum","description":"Value of property validPropertyDefaultValueEnumChainedDestructuring"},"description":"Gets current value of property {@link #getValidPropertyDefaultValueEnumChainedDestructuring validPropertyDefaultValueEnumChainedDestructuring}.\n\nvalidPropertyDefaultValueEnumChainedDestructuring\n\nDefault value is Buzz."},{"name":"getValidPropertyDefaultValueEnumDestructuringWithRename","visibility":"public","returnValue":{"type":"testlib.AnotherValidEnum","description":"Value of property validPropertyDefaultValueEnumDestructuringWithRename"},"description":"Gets current value of property {@link #getValidPropertyDefaultValueEnumDestructuringWithRename validPropertyDefaultValueEnumDestructuringWithRename}.\n\nvalidPropertyDefaultValueEnumDestructuringWithRename\n\nDefault value is Fizz."},{"name":"getValidPropertyDefaultValueEnumSimpleDestructuring","visibility":"public","returnValue":{"type":"testlib.AnotherValidEnum","description":"Value of property validPropertyDefaultValueEnumSimpleDestructuring"},"description":"Gets current value of property {@link #getValidPropertyDefaultValueEnumSimpleDestructuring validPropertyDefaultValueEnumSimpleDestructuring}.\n\nvalidPropertyDefaultValueEnumSimpleDestructuring\n\nDefault value is Buzz."},{"name":"getValidPropertyDefaultValueEnumViaDestructuringGlobal","visibility":"public","returnValue":{"type":"sap.ui.core.TitleLevel","description":"Value of property validPropertyDefaultValueEnumViaDestructuringGlobal"},"description":"Gets current value of property {@link #getValidPropertyDefaultValueEnumViaDestructuringGlobal validPropertyDefaultValueEnumViaDestructuringGlobal}.\n\nvalidPropertyDefaultValueEnumViaDestructuringGlobal\n\nDefault value is H1."},{"name":"getValidPropertyDefaultValueEnumViaDestructuringInArrowFn","visibility":"public","returnValue":{"type":"testlib.MyValidEnum","description":"Value of property validPropertyDefaultValueEnumViaDestructuringInArrowFn"},"description":"Gets current value of property {@link #getValidPropertyDefaultValueEnumViaDestructuringInArrowFn validPropertyDefaultValueEnumViaDestructuringInArrowFn}.\n\nvalidPropertyDefaultValueEnumViaDestructuringInArrowFn\n\nDefault value is Foo."},{"name":"setValidPropertyDefaultValueEnumChainedDestructuring","visibility":"public","returnValue":{"type":"this","description":"Reference to this in order to allow method chaining"},"parameters":[{"name":"sValidPropertyDefaultValueEnumChainedDestructuring","type":"testlib.AnotherValidEnum","optional":true,"defaultValue":"Buzz","description":"New value for property validPropertyDefaultValueEnumChainedDestructuring"}],"description":"Sets a new value for property {@link #getValidPropertyDefaultValueEnumChainedDestructuring validPropertyDefaultValueEnumChainedDestructuring}.\n\nvalidPropertyDefaultValueEnumChainedDestructuring\n\nWhen called with a value of null or undefined, the default value of the property will be restored.\n\nDefault value is Buzz."},{"name":"setValidPropertyDefaultValueEnumDestructuringWithRename","visibility":"public","returnValue":{"type":"this","description":"Reference to this in order to allow method chaining"},"parameters":[{"name":"sValidPropertyDefaultValueEnumDestructuringWithRename","type":"testlib.AnotherValidEnum","optional":true,"defaultValue":"Fizz","description":"New value for property validPropertyDefaultValueEnumDestructuringWithRename"}],"description":"Sets a new value for property {@link #getValidPropertyDefaultValueEnumDestructuringWithRename validPropertyDefaultValueEnumDestructuringWithRename}.\n\nvalidPropertyDefaultValueEnumDestructuringWithRename\n\nWhen called with a value of null or undefined, the default value of the property will be restored.\n\nDefault value is Fizz."},{"name":"setValidPropertyDefaultValueEnumSimpleDestructuring","visibility":"public","returnValue":{"type":"this","description":"Reference to this in order to allow method chaining"},"parameters":[{"name":"sValidPropertyDefaultValueEnumSimpleDestructuring","type":"testlib.AnotherValidEnum","optional":true,"defaultValue":"Buzz","description":"New value for property validPropertyDefaultValueEnumSimpleDestructuring"}],"description":"Sets a new value for property {@link #getValidPropertyDefaultValueEnumSimpleDestructuring validPropertyDefaultValueEnumSimpleDestructuring}.\n\nvalidPropertyDefaultValueEnumSimpleDestructuring\n\nWhen called with a value of null or undefined, the default value of the property will be restored.\n\nDefault value is Buzz."},{"name":"setValidPropertyDefaultValueEnumViaDestructuringGlobal","visibility":"public","returnValue":{"type":"this","description":"Reference to this in order to allow method chaining"},"parameters":[{"name":"sValidPropertyDefaultValueEnumViaDestructuringGlobal","type":"sap.ui.core.TitleLevel","optional":true,"defaultValue":"H1","description":"New value for property validPropertyDefaultValueEnumViaDestructuringGlobal"}],"description":"Sets a new value for property {@link #getValidPropertyDefaultValueEnumViaDestructuringGlobal validPropertyDefaultValueEnumViaDestructuringGlobal}.\n\nvalidPropertyDefaultValueEnumViaDestructuringGlobal\n\nWhen called with a value of null or undefined, the default value of the property will be restored.\n\nDefault value is H1."},{"name":"setValidPropertyDefaultValueEnumViaDestructuringInArrowFn","visibility":"public","returnValue":{"type":"this","description":"Reference to this in order to allow method chaining"},"parameters":[{"name":"sValidPropertyDefaultValueEnumViaDestructuringInArrowFn","type":"testlib.MyValidEnum","optional":true,"defaultValue":"Foo","description":"New value for property validPropertyDefaultValueEnumViaDestructuringInArrowFn"}],"description":"Sets a new value for property {@link #getValidPropertyDefaultValueEnumViaDestructuringInArrowFn validPropertyDefaultValueEnumViaDestructuringInArrowFn}.\n\nvalidPropertyDefaultValueEnumViaDestructuringInArrowFn\n\nWhen called with a value of null or undefined, the default value of the property will be restored.\n\nDefault value is Foo."}]}]} \ No newline at end of file diff --git a/test/fixtures/library.j/main/src/library/j/some.js b/test/fixtures/library.j/main/src/library/j/some.js index f13a0e977..ad30cc48d 100644 --- a/test/fixtures/library.j/main/src/library/j/some.js +++ b/test/fixtures/library.j/main/src/library/j/some.js @@ -13,7 +13,7 @@ sap.ui.define([ const { AnotherValidEnum } = library; const { Buzz } = AnotherValidEnum; const { AnotherValidEnum: Zzz } = library; - const { TitleLevel } = sap.ui.core; + const { H1 } = sap.ui.core.TitleLevel; /** * @class @@ -73,9 +73,9 @@ sap.ui.define([ * validPropertyDefaultValueEnumViaDestructuringGlobal */ validPropertyDefaultValueEnumViaDestructuringGlobal: { - type: "sap.ui.core", + type: "sap.ui.core.TitleLevel", group: "Misc", - defaultValue: TitleLevel, + defaultValue: H1, }, }, }, From 22c54ecf6cf028417b7a4a702775626d79809e82 Mon Sep 17 00:00:00 2001 From: Yavor Ivanov Date: Thu, 25 Aug 2022 18:00:14 +0300 Subject: [PATCH 19/69] Resolve destructuring in the parametter and consider var renaming --- lib/processors/jsdoc/lib/ui5/plugin.cjs | 136 ++++++++++++++---------- 1 file changed, 78 insertions(+), 58 deletions(-) diff --git a/lib/processors/jsdoc/lib/ui5/plugin.cjs b/lib/processors/jsdoc/lib/ui5/plugin.cjs index 5df068187..303fd962c 100644 --- a/lib/processors/jsdoc/lib/ui5/plugin.cjs +++ b/lib/processors/jsdoc/lib/ui5/plugin.cjs @@ -267,17 +267,25 @@ function analyzeModuleDefinition(node) { } if ( currentModule.dependencies && currentModule.factory ) { for ( let i = 0; i < currentModule.dependencies.length && i < currentModule.factory.params.length; i++ ) { - const name = + const names = (currentModule.factory.params[i].type === Syntax.ObjectPattern) - ? currentModule.factory.params[i].properties[0].value.name // ObjectPattern means destructuring of the parameter - : currentModule.factory.params[i].name; // simple Identifier - - const module = resolveModuleName(currentModule.module, currentModule.dependencies[i]); - debug(` import ${name} from '${module}'`); - currentModule.localNames[name] = { - module: module - // no (or empty) path - }; + ? currentModule.factory.params[i].properties.map(prop => { + const resolvedVar = getEnclosingVariableScope(prop) + .variables.filter((curVar) => prop.value.name === curVar.name)[0]; + const renamedVar = checkVarRenaming(resolvedVar); + + return renamedVar ? renamedVar.original : prop.value.name; + }) // ObjectPattern means destructuring of the parameter + : [currentModule.factory.params[i].name]; // simple Identifier + + names.forEach(name => { + const module = resolveModuleName(currentModule.module, currentModule.dependencies[i]); + debug(` import ${name} from '${module}'`); + currentModule.localNames[name] = { + module: module + // no (or empty) path + }; + }); } } if ( currentModule.factory ) { @@ -665,7 +673,7 @@ function resolvePotentialEnum(node, type) { // the type + key let value = varsDestructuringStack.join("."); - if ( value.indexOf(type + ".") === 0 ) { + if ( value.startsWith(type + ".") ) { // starts with fully qualified enum name -> cut off name value = value.slice(type.length + 1); return { @@ -675,6 +683,65 @@ function resolvePotentialEnum(node, type) { } } +/** + * Checks whether a var has been renamed while destructuring i.e. {A: b} = SomeObject + * + * @param {Variable} variable + * @returns {Object} + */ +function checkVarRenaming (variable) { + // variable.defs[0].node.id.type === Syntax.ObjectPattern -> Renaming + // variable.defs[0].node.id.properties[0].key.name === variable.name; // Original + // variable.defs[0].node.id.properties[0].value.name === variable.name; // Renamed + + let potentialRename = variable.defs + .reduce((acc, def) => { + if (def.node?.type === Syntax.ArrowFunctionExpression) { + acc = acc.concat(def.node.params); + } else { + acc.push(def.node?.id); + } + return acc; + }, []) + .filter((param) => param.type === Syntax.ObjectPattern) // Filter on object patterns => Detructure renamig + // .map( + // (def) => + // def.node.id /* ObjectPattern */ || + // def.node.params /* ArrowFunctionExpression */ + // ) // Drill down to the ObjectPattern Node + .filter((objPatternNode) => + objPatternNode.properties.some( + (prop) => prop.value.name === variable.name + ) + ) // Filter on ObjectPattern nodes that contain the variable + .reduce((acc, objPatternNode) => { + return acc.concat( + objPatternNode.properties.filter( + (prop) => prop.value.name === variable.name + ) + ); + }, []) + .map((prop) => { + return { original: prop.key.name, renamed: prop.value.name }; + })[0]; + + if (potentialRename) { + return potentialRename; + } + + // var AriaHasPopup = sap.ui.core.aria.HasPopup; -> AriaHasPopup.None + potentialRename = + variable.defs.filter( + (def) => + def.node && def.node.id && def.node.id.type === Syntax.Identifier + ) + .map((def) => { + return { original: getResolvedObjectName(def.name), replaced: def.name.name }; + })[0]; + + return potentialRename; +}; + /** * Builds the fully quantified name when there's a destructuring of a variable * @@ -693,53 +760,6 @@ function resolveFullyQuantifiedName(node, type) { return null; } - // Checks whether a var has been renamed while destructuring i.e. {A: b} = SomeObject - const checkVarRenaming = (variable) => { - // variable.defs[0].node.id.type === Syntax.ObjectPattern -> Renaming - // variable.defs[0].node.id.properties[0].key.name === variable.name; // Original - // variable.defs[0].node.id.properties[0].value.name === variable.name; // Renamed - - let potentialRename = variable.defs - .filter( - (def) => - def.node && - def.node.id && - def.node.id.type === Syntax.ObjectPattern - ) // Filter on object patterns => Detructure renamig - .map((def) => def.node.id) // Drill down to the ObjectPattern Node - .filter((objPatternNode) => - objPatternNode.properties.some( - (prop) => prop.value.name === variable.name - ) - ) // Filter on ObjectPattern nodes that contain the variable - .reduce((acc, objPatternNode) => { - return acc.concat( - objPatternNode.properties.filter( - (prop) => prop.value.name === variable.name - ) - ); - }, []) - .map((prop) => { - return { original: prop.key.name, renamed: prop.value.name }; - })[0]; - - if (potentialRename) { - return potentialRename; - } - - // var AriaHasPopup = sap.ui.core.aria.HasPopup; -> AriaHasPopup.None - potentialRename = - variable.defs.filter( - (def) => - def.node && def.node.id && def.node.id.type === Syntax.Identifier - ) - .map((def) => { - return { original: getResolvedObjectName(def.name), replaced: def.name.name }; - })[0]; - - return potentialRename; - }; - // TODO: Check for hierarchical destructuring // i.e. let {Foo} = myObject; let {Bar} = Foo; --> Bar while (leftMostName) { From 941fff626d3a24cd0f3e5a3d82592514f922e8d8 Mon Sep 17 00:00:00 2001 From: Yavor Ivanov Date: Fri, 26 Aug 2022 09:40:35 +0300 Subject: [PATCH 20/69] Update samples to support destructuring w/ rename as func argument --- test/expected/build/library.j/dest/resources/library/j/some.js | 2 +- test/fixtures/library.j/main/src/library/j/some.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/expected/build/library.j/dest/resources/library/j/some.js b/test/expected/build/library.j/dest/resources/library/j/some.js index 28f318d95..9fcbb242f 100644 --- a/test/expected/build/library.j/dest/resources/library/j/some.js +++ b/test/expected/build/library.j/dest/resources/library/j/some.js @@ -8,7 +8,7 @@ sap.ui.define([ "./dependency-es6-1", "./dependency-es6-2", "./dependency-es6-3" -], (Control, { MyValidEnum }, library, es6_1, , es6_2, , es6_3) => { +], (Control, { MyValidEnum, ThisIsEnumToo: RenamedEnum }, library, es6_1, , es6_2, , es6_3) => { const { AnotherValidEnum } = library; const { Buzz } = AnotherValidEnum; diff --git a/test/fixtures/library.j/main/src/library/j/some.js b/test/fixtures/library.j/main/src/library/j/some.js index ad30cc48d..cfff064d0 100644 --- a/test/fixtures/library.j/main/src/library/j/some.js +++ b/test/fixtures/library.j/main/src/library/j/some.js @@ -8,7 +8,7 @@ sap.ui.define([ "./dependency-es6-1", "./dependency-es6-2", "./dependency-es6-3" -], (Control, { MyValidEnum }, library, es6_1, es6_2, es6_3) => { +], (Control, { MyValidEnum, ThisIsEnumToo: RenamedEnum }, library, es6_1, es6_2, es6_3) => { const { AnotherValidEnum } = library; const { Buzz } = AnotherValidEnum; From 105952c48982b47bc4b2cd3707d89f8b1f02ce91 Mon Sep 17 00:00:00 2001 From: Matthias Osswald Date: Thu, 8 Sep 2022 11:03:01 +0200 Subject: [PATCH 21/69] Add failing rename test case --- .../dest/resources/library/j/dependency.js | 19 +++++++++++++++++ .../dest/resources/library/j/some.js | 21 ++++++++++++++++++- .../main/src/library/j/dependency.js | 19 +++++++++++++++++ .../library.j/main/src/library/j/some.js | 21 ++++++++++++++++++- 4 files changed, 78 insertions(+), 2 deletions(-) diff --git a/test/expected/build/library.j/dest/resources/library/j/dependency.js b/test/expected/build/library.j/dest/resources/library/j/dependency.js index e17972dae..ba161f274 100644 --- a/test/expected/build/library.j/dest/resources/library/j/dependency.js +++ b/test/expected/build/library.j/dest/resources/library/j/dependency.js @@ -30,5 +30,24 @@ sap.ui.define([], function () { Bar: "Bar", }; + /** + * ThisIsEnumToo + * + * @enum {string} + * @public + */ + testlib.ThisIsEnumToo = { + /** + * Foo + * @public + */ + Value1: "Value1", + /** + * Bar + * @public + */ + Value2: "Value2", + }; + return testlib; }); diff --git a/test/expected/build/library.j/dest/resources/library/j/some.js b/test/expected/build/library.j/dest/resources/library/j/some.js index 9fcbb242f..a0758c0e9 100644 --- a/test/expected/build/library.j/dest/resources/library/j/some.js +++ b/test/expected/build/library.j/dest/resources/library/j/some.js @@ -2,7 +2,7 @@ * ${copyright} */ sap.ui.define([ - "sap/ui/core/Control", + "sap/ui/core/Control", "./dependency", "./dependency2", "./dependency-es6-1", @@ -14,6 +14,7 @@ sap.ui.define([ const { Buzz } = AnotherValidEnum; const { AnotherValidEnum: Zzz } = library; const { H1 } = sap.ui.core.TitleLevel; + const { Value2: RenamedValue2 } = RenamedEnum; /** * @class @@ -60,6 +61,24 @@ sap.ui.define([ defaultValue: Zzz.Fizz, }, + /** + * validPropertyDefaultValueEnumDestructuringWithRenameInArguments + */ + validPropertyDefaultValueEnumDestructuringWithRenameInArguments: { + type: "testlib.ThisIsEnumToo", + group: "Misc", + defaultValue: RenamedEnum.Value1, + }, + + /** + * validPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar + */ + validPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar: { + type: "testlib.ThisIsEnumToo", + group: "Misc", + defaultValue: RenamedValue2, + }, + /** * validPropertyDefaultValueEnumViaDestructuringInArrowFn */ diff --git a/test/fixtures/library.j/main/src/library/j/dependency.js b/test/fixtures/library.j/main/src/library/j/dependency.js index e17972dae..ba161f274 100644 --- a/test/fixtures/library.j/main/src/library/j/dependency.js +++ b/test/fixtures/library.j/main/src/library/j/dependency.js @@ -30,5 +30,24 @@ sap.ui.define([], function () { Bar: "Bar", }; + /** + * ThisIsEnumToo + * + * @enum {string} + * @public + */ + testlib.ThisIsEnumToo = { + /** + * Foo + * @public + */ + Value1: "Value1", + /** + * Bar + * @public + */ + Value2: "Value2", + }; + return testlib; }); diff --git a/test/fixtures/library.j/main/src/library/j/some.js b/test/fixtures/library.j/main/src/library/j/some.js index cfff064d0..dad1fd304 100644 --- a/test/fixtures/library.j/main/src/library/j/some.js +++ b/test/fixtures/library.j/main/src/library/j/some.js @@ -2,7 +2,7 @@ * ${copyright} */ sap.ui.define([ - "sap/ui/core/Control", + "sap/ui/core/Control", "./dependency", "./dependency2", "./dependency-es6-1", @@ -14,6 +14,7 @@ sap.ui.define([ const { Buzz } = AnotherValidEnum; const { AnotherValidEnum: Zzz } = library; const { H1 } = sap.ui.core.TitleLevel; + const { Value2: RenamedValue2 } = RenamedEnum; /** * @class @@ -60,6 +61,24 @@ sap.ui.define([ defaultValue: Zzz.Fizz, }, + /** + * validPropertyDefaultValueEnumDestructuringWithRenameInArguments + */ + validPropertyDefaultValueEnumDestructuringWithRenameInArguments: { + type: "testlib.ThisIsEnumToo", + group: "Misc", + defaultValue: RenamedEnum.Value1, + }, + + /** + * validPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar + */ + validPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar: { + type: "testlib.ThisIsEnumToo", + group: "Misc", + defaultValue: RenamedValue2, + }, + /** * validPropertyDefaultValueEnumViaDestructuringInArrowFn */ From 6ded432b144127d13a9d56df973813700732a9b7 Mon Sep 17 00:00:00 2001 From: Yavor Ivanov Date: Fri, 9 Sep 2022 13:47:30 +0300 Subject: [PATCH 22/69] Var renaming while generating fully quantified name fixed --- lib/processors/jsdoc/lib/ui5/plugin.cjs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/processors/jsdoc/lib/ui5/plugin.cjs b/lib/processors/jsdoc/lib/ui5/plugin.cjs index 303fd962c..0c2bb7acb 100644 --- a/lib/processors/jsdoc/lib/ui5/plugin.cjs +++ b/lib/processors/jsdoc/lib/ui5/plugin.cjs @@ -281,6 +281,10 @@ function analyzeModuleDefinition(node) { names.forEach(name => { const module = resolveModuleName(currentModule.module, currentModule.dependencies[i]); debug(` import ${name} from '${module}'`); + + // TODO: localNames MUST have the renamed var as a key, but a property with the original name + // For example: {"MyVarRenamed": {module: "/dependency1.js", property: "myVarOriginal"}} + // In cases without a rename, MyVarRenamed === myVarOriginal currentModule.localNames[name] = { module: module // no (or empty) path @@ -803,8 +807,8 @@ function resolveFullyQuantifiedName(node, type) { if (potentialChunk && potentialChunk.renamed) { originalName = originalName.replace( - potentialChunk.renamed + ".", - potentialChunk.original + "." + new RegExp("(^|\.)" + potentialChunk.renamed + "($|\.)"), + "$1" + potentialChunk.original + "$2" ); } } From a575a4ba9c490642a4194bcdcde3378051cf913f Mon Sep 17 00:00:00 2001 From: Yavor Ivanov Date: Fri, 9 Sep 2022 13:49:07 +0300 Subject: [PATCH 23/69] Adjust tests --- .../library.j/dest/test-resources/library/j/designtime/api.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/expected/build/library.j/dest/test-resources/library/j/designtime/api.json b/test/expected/build/library.j/dest/test-resources/library/j/designtime/api.json index 1078c4932..4a701199d 100644 --- a/test/expected/build/library.j/dest/test-resources/library/j/designtime/api.json +++ b/test/expected/build/library.j/dest/test-resources/library/j/designtime/api.json @@ -1 +1 @@ -{"$schema-ref":"http://schemas.sap.com/sapui5/designtime/api.json/1.0","version":"1.0.0","library":"library.j","symbols":[{"kind":"enum","name":"testlib.AnotherValidEnum","basename":"AnotherValidEnum","resource":"library/j/dependency2.js","module":"library/j/dependency2","static":true,"visibility":"public","description":"AnotherValidEnum","ui5-metamodel":true,"ui5-metadata":{"stereotype":"enum"},"properties":[{"name":"Buzz","visibility":"public","static":true,"type":"string","description":"Bar"},{"name":"Fizz","visibility":"public","static":true,"type":"string","description":"Fizz"}]},{"kind":"enum","name":"testlib.MyValidEnum","basename":"MyValidEnum","resource":"library/j/dependency.js","module":"library/j/dependency","static":true,"visibility":"public","description":"MyValidEnum","ui5-metamodel":true,"ui5-metadata":{"stereotype":"enum"},"properties":[{"name":"Bar","visibility":"public","static":true,"type":"string","description":"Bar"},{"name":"Foo","visibility":"public","static":true,"type":"string","description":"Foo"}]},{"kind":"class","name":"testlib.ValidPropertyDefaultValue","basename":"ValidPropertyDefaultValue","resource":"library/j/some.js","module":"library/j/some","export":"","static":true,"visibility":"public","extends":"sap.ui.core.Control","description":"My super documentation of this class","ui5-metamodel":true,"ui5-metadata":{"stereotype":"control","properties":[{"name":"validPropertyDefaultValueEnumSimpleDestructuring","type":"testlib.AnotherValidEnum","defaultValue":"Buzz","group":"Misc","visibility":"public","description":"validPropertyDefaultValueEnumSimpleDestructuring","methods":["getValidPropertyDefaultValueEnumSimpleDestructuring","setValidPropertyDefaultValueEnumSimpleDestructuring"]},{"name":"validPropertyDefaultValueEnumChainedDestructuring","type":"testlib.AnotherValidEnum","defaultValue":"Buzz","group":"Misc","visibility":"public","description":"validPropertyDefaultValueEnumChainedDestructuring","methods":["getValidPropertyDefaultValueEnumChainedDestructuring","setValidPropertyDefaultValueEnumChainedDestructuring"]},{"name":"validPropertyDefaultValueEnumDestructuringWithRename","type":"testlib.AnotherValidEnum","defaultValue":"Fizz","group":"Misc","visibility":"public","description":"validPropertyDefaultValueEnumDestructuringWithRename","methods":["getValidPropertyDefaultValueEnumDestructuringWithRename","setValidPropertyDefaultValueEnumDestructuringWithRename"]},{"name":"validPropertyDefaultValueEnumViaDestructuringInArrowFn","type":"testlib.MyValidEnum","defaultValue":"Foo","group":"Misc","visibility":"public","description":"validPropertyDefaultValueEnumViaDestructuringInArrowFn","methods":["getValidPropertyDefaultValueEnumViaDestructuringInArrowFn","setValidPropertyDefaultValueEnumViaDestructuringInArrowFn"]},{"name":"validPropertyDefaultValueEnumViaDestructuringGlobal","type":"sap.ui.core.TitleLevel","defaultValue":"H1","group":"Misc","visibility":"public","description":"validPropertyDefaultValueEnumViaDestructuringGlobal","methods":["getValidPropertyDefaultValueEnumViaDestructuringGlobal","setValidPropertyDefaultValueEnumViaDestructuringGlobal"]}]},"constructor":{"visibility":"public","description":"Accepts an object literal mSettings that defines initial property values, aggregated and associated objects as well as event handlers. See {@link sap.ui.base.ManagedObject#constructor} for a general description of the syntax of the settings object."},"methods":[{"name":"extend","visibility":"public","static":true,"returnValue":{"type":"function","description":"Created class / constructor function"},"parameters":[{"name":"sClassName","type":"string","optional":false,"description":"Name of the class being created"},{"name":"oClassInfo","type":"object","optional":true,"description":"Object literal with information about the class"},{"name":"FNMetaImpl","type":"function","optional":true,"description":"Constructor function for the metadata object; if not given, it defaults to the metadata implementation used by this class"}],"description":"Creates a new subclass of class testlib.ValidPropertyDefaultValue with name sClassName and enriches it with the information contained in oClassInfo.\n\noClassInfo might contain the same kind of information as described in {@link sap.ui.core.Control.extend}."},{"name":"getMetadata","visibility":"public","static":true,"returnValue":{"type":"sap.ui.base.Metadata","description":"Metadata object describing this class"},"description":"Returns a metadata object for class testlib.ValidPropertyDefaultValue."},{"name":"getValidPropertyDefaultValueEnumChainedDestructuring","visibility":"public","returnValue":{"type":"testlib.AnotherValidEnum","description":"Value of property validPropertyDefaultValueEnumChainedDestructuring"},"description":"Gets current value of property {@link #getValidPropertyDefaultValueEnumChainedDestructuring validPropertyDefaultValueEnumChainedDestructuring}.\n\nvalidPropertyDefaultValueEnumChainedDestructuring\n\nDefault value is Buzz."},{"name":"getValidPropertyDefaultValueEnumDestructuringWithRename","visibility":"public","returnValue":{"type":"testlib.AnotherValidEnum","description":"Value of property validPropertyDefaultValueEnumDestructuringWithRename"},"description":"Gets current value of property {@link #getValidPropertyDefaultValueEnumDestructuringWithRename validPropertyDefaultValueEnumDestructuringWithRename}.\n\nvalidPropertyDefaultValueEnumDestructuringWithRename\n\nDefault value is Fizz."},{"name":"getValidPropertyDefaultValueEnumSimpleDestructuring","visibility":"public","returnValue":{"type":"testlib.AnotherValidEnum","description":"Value of property validPropertyDefaultValueEnumSimpleDestructuring"},"description":"Gets current value of property {@link #getValidPropertyDefaultValueEnumSimpleDestructuring validPropertyDefaultValueEnumSimpleDestructuring}.\n\nvalidPropertyDefaultValueEnumSimpleDestructuring\n\nDefault value is Buzz."},{"name":"getValidPropertyDefaultValueEnumViaDestructuringGlobal","visibility":"public","returnValue":{"type":"sap.ui.core.TitleLevel","description":"Value of property validPropertyDefaultValueEnumViaDestructuringGlobal"},"description":"Gets current value of property {@link #getValidPropertyDefaultValueEnumViaDestructuringGlobal validPropertyDefaultValueEnumViaDestructuringGlobal}.\n\nvalidPropertyDefaultValueEnumViaDestructuringGlobal\n\nDefault value is H1."},{"name":"getValidPropertyDefaultValueEnumViaDestructuringInArrowFn","visibility":"public","returnValue":{"type":"testlib.MyValidEnum","description":"Value of property validPropertyDefaultValueEnumViaDestructuringInArrowFn"},"description":"Gets current value of property {@link #getValidPropertyDefaultValueEnumViaDestructuringInArrowFn validPropertyDefaultValueEnumViaDestructuringInArrowFn}.\n\nvalidPropertyDefaultValueEnumViaDestructuringInArrowFn\n\nDefault value is Foo."},{"name":"setValidPropertyDefaultValueEnumChainedDestructuring","visibility":"public","returnValue":{"type":"this","description":"Reference to this in order to allow method chaining"},"parameters":[{"name":"sValidPropertyDefaultValueEnumChainedDestructuring","type":"testlib.AnotherValidEnum","optional":true,"defaultValue":"Buzz","description":"New value for property validPropertyDefaultValueEnumChainedDestructuring"}],"description":"Sets a new value for property {@link #getValidPropertyDefaultValueEnumChainedDestructuring validPropertyDefaultValueEnumChainedDestructuring}.\n\nvalidPropertyDefaultValueEnumChainedDestructuring\n\nWhen called with a value of null or undefined, the default value of the property will be restored.\n\nDefault value is Buzz."},{"name":"setValidPropertyDefaultValueEnumDestructuringWithRename","visibility":"public","returnValue":{"type":"this","description":"Reference to this in order to allow method chaining"},"parameters":[{"name":"sValidPropertyDefaultValueEnumDestructuringWithRename","type":"testlib.AnotherValidEnum","optional":true,"defaultValue":"Fizz","description":"New value for property validPropertyDefaultValueEnumDestructuringWithRename"}],"description":"Sets a new value for property {@link #getValidPropertyDefaultValueEnumDestructuringWithRename validPropertyDefaultValueEnumDestructuringWithRename}.\n\nvalidPropertyDefaultValueEnumDestructuringWithRename\n\nWhen called with a value of null or undefined, the default value of the property will be restored.\n\nDefault value is Fizz."},{"name":"setValidPropertyDefaultValueEnumSimpleDestructuring","visibility":"public","returnValue":{"type":"this","description":"Reference to this in order to allow method chaining"},"parameters":[{"name":"sValidPropertyDefaultValueEnumSimpleDestructuring","type":"testlib.AnotherValidEnum","optional":true,"defaultValue":"Buzz","description":"New value for property validPropertyDefaultValueEnumSimpleDestructuring"}],"description":"Sets a new value for property {@link #getValidPropertyDefaultValueEnumSimpleDestructuring validPropertyDefaultValueEnumSimpleDestructuring}.\n\nvalidPropertyDefaultValueEnumSimpleDestructuring\n\nWhen called with a value of null or undefined, the default value of the property will be restored.\n\nDefault value is Buzz."},{"name":"setValidPropertyDefaultValueEnumViaDestructuringGlobal","visibility":"public","returnValue":{"type":"this","description":"Reference to this in order to allow method chaining"},"parameters":[{"name":"sValidPropertyDefaultValueEnumViaDestructuringGlobal","type":"sap.ui.core.TitleLevel","optional":true,"defaultValue":"H1","description":"New value for property validPropertyDefaultValueEnumViaDestructuringGlobal"}],"description":"Sets a new value for property {@link #getValidPropertyDefaultValueEnumViaDestructuringGlobal validPropertyDefaultValueEnumViaDestructuringGlobal}.\n\nvalidPropertyDefaultValueEnumViaDestructuringGlobal\n\nWhen called with a value of null or undefined, the default value of the property will be restored.\n\nDefault value is H1."},{"name":"setValidPropertyDefaultValueEnumViaDestructuringInArrowFn","visibility":"public","returnValue":{"type":"this","description":"Reference to this in order to allow method chaining"},"parameters":[{"name":"sValidPropertyDefaultValueEnumViaDestructuringInArrowFn","type":"testlib.MyValidEnum","optional":true,"defaultValue":"Foo","description":"New value for property validPropertyDefaultValueEnumViaDestructuringInArrowFn"}],"description":"Sets a new value for property {@link #getValidPropertyDefaultValueEnumViaDestructuringInArrowFn validPropertyDefaultValueEnumViaDestructuringInArrowFn}.\n\nvalidPropertyDefaultValueEnumViaDestructuringInArrowFn\n\nWhen called with a value of null or undefined, the default value of the property will be restored.\n\nDefault value is Foo."}]}]} \ No newline at end of file +{"$schema-ref":"http://schemas.sap.com/sapui5/designtime/api.json/1.0","version":"1.0.0","library":"library.j","symbols":[{"kind":"enum","name":"testlib.AnotherValidEnum","basename":"AnotherValidEnum","resource":"library/j/dependency2.js","module":"library/j/dependency2","static":true,"visibility":"public","description":"AnotherValidEnum","ui5-metamodel":true,"ui5-metadata":{"stereotype":"enum"},"properties":[{"name":"Buzz","visibility":"public","static":true,"type":"string","description":"Bar"},{"name":"Fizz","visibility":"public","static":true,"type":"string","description":"Fizz"}]},{"kind":"enum","name":"testlib.MyValidEnum","basename":"MyValidEnum","resource":"library/j/dependency.js","module":"library/j/dependency","static":true,"visibility":"public","description":"MyValidEnum","ui5-metamodel":true,"ui5-metadata":{"stereotype":"enum"},"properties":[{"name":"Bar","visibility":"public","static":true,"type":"string","description":"Bar"},{"name":"Foo","visibility":"public","static":true,"type":"string","description":"Foo"}]},{"kind":"enum","name":"testlib.ThisIsEnumToo","basename":"ThisIsEnumToo","resource":"library/j/dependency.js","module":"library/j/dependency","static":true,"visibility":"public","description":"ThisIsEnumToo","ui5-metadata":{"stereotype":"enum"},"properties":[{"name":"Value1","visibility":"public","static":true,"type":"string","description":"Foo"},{"name":"Value2","visibility":"public","static":true,"type":"string","description":"Bar"}]},{"kind":"class","name":"testlib.ValidPropertyDefaultValue","basename":"ValidPropertyDefaultValue","resource":"library/j/some.js","module":"library/j/some","export":"","static":true,"visibility":"public","extends":"sap.ui.core.Control","description":"My super documentation of this class","ui5-metamodel":true,"ui5-metadata":{"stereotype":"control","properties":[{"name":"validPropertyDefaultValueEnumSimpleDestructuring","type":"testlib.AnotherValidEnum","defaultValue":"Buzz","group":"Misc","visibility":"public","description":"validPropertyDefaultValueEnumSimpleDestructuring","methods":["getValidPropertyDefaultValueEnumSimpleDestructuring","setValidPropertyDefaultValueEnumSimpleDestructuring"]},{"name":"validPropertyDefaultValueEnumChainedDestructuring","type":"testlib.AnotherValidEnum","defaultValue":"Buzz","group":"Misc","visibility":"public","description":"validPropertyDefaultValueEnumChainedDestructuring","methods":["getValidPropertyDefaultValueEnumChainedDestructuring","setValidPropertyDefaultValueEnumChainedDestructuring"]},{"name":"validPropertyDefaultValueEnumDestructuringWithRename","type":"testlib.AnotherValidEnum","defaultValue":"Fizz","group":"Misc","visibility":"public","description":"validPropertyDefaultValueEnumDestructuringWithRename","methods":["getValidPropertyDefaultValueEnumDestructuringWithRename","setValidPropertyDefaultValueEnumDestructuringWithRename"]},{"name":"validPropertyDefaultValueEnumDestructuringWithRenameInArguments","type":"testlib.ThisIsEnumToo","defaultValue":"Value1","group":"Misc","visibility":"public","description":"validPropertyDefaultValueEnumDestructuringWithRenameInArguments","methods":["getValidPropertyDefaultValueEnumDestructuringWithRenameInArguments","setValidPropertyDefaultValueEnumDestructuringWithRenameInArguments"]},{"name":"validPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar","type":"testlib.ThisIsEnumToo","defaultValue":"Value2","group":"Misc","visibility":"public","description":"validPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar","methods":["getValidPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar","setValidPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar"]},{"name":"validPropertyDefaultValueEnumViaDestructuringInArrowFn","type":"testlib.MyValidEnum","defaultValue":"Foo","group":"Misc","visibility":"public","description":"validPropertyDefaultValueEnumViaDestructuringInArrowFn","methods":["getValidPropertyDefaultValueEnumViaDestructuringInArrowFn","setValidPropertyDefaultValueEnumViaDestructuringInArrowFn"]},{"name":"validPropertyDefaultValueEnumViaDestructuringGlobal","type":"sap.ui.core.TitleLevel","defaultValue":"H1","group":"Misc","visibility":"public","description":"validPropertyDefaultValueEnumViaDestructuringGlobal","methods":["getValidPropertyDefaultValueEnumViaDestructuringGlobal","setValidPropertyDefaultValueEnumViaDestructuringGlobal"]}]},"constructor":{"visibility":"public","description":"Accepts an object literal mSettings that defines initial property values, aggregated and associated objects as well as event handlers. See {@link sap.ui.base.ManagedObject#constructor} for a general description of the syntax of the settings object."},"methods":[{"name":"extend","visibility":"public","static":true,"returnValue":{"type":"function","description":"Created class / constructor function"},"parameters":[{"name":"sClassName","type":"string","optional":false,"description":"Name of the class being created"},{"name":"oClassInfo","type":"object","optional":true,"description":"Object literal with information about the class"},{"name":"FNMetaImpl","type":"function","optional":true,"description":"Constructor function for the metadata object; if not given, it defaults to the metadata implementation used by this class"}],"description":"Creates a new subclass of class testlib.ValidPropertyDefaultValue with name sClassName and enriches it with the information contained in oClassInfo.\n\noClassInfo might contain the same kind of information as described in {@link sap.ui.core.Control.extend}."},{"name":"getMetadata","visibility":"public","static":true,"returnValue":{"type":"sap.ui.base.Metadata","description":"Metadata object describing this class"},"description":"Returns a metadata object for class testlib.ValidPropertyDefaultValue."},{"name":"getValidPropertyDefaultValueEnumChainedDestructuring","visibility":"public","returnValue":{"type":"testlib.AnotherValidEnum","description":"Value of property validPropertyDefaultValueEnumChainedDestructuring"},"description":"Gets current value of property {@link #getValidPropertyDefaultValueEnumChainedDestructuring validPropertyDefaultValueEnumChainedDestructuring}.\n\nvalidPropertyDefaultValueEnumChainedDestructuring\n\nDefault value is Buzz."},{"name":"getValidPropertyDefaultValueEnumDestructuringWithRename","visibility":"public","returnValue":{"type":"testlib.AnotherValidEnum","description":"Value of property validPropertyDefaultValueEnumDestructuringWithRename"},"description":"Gets current value of property {@link #getValidPropertyDefaultValueEnumDestructuringWithRename validPropertyDefaultValueEnumDestructuringWithRename}.\n\nvalidPropertyDefaultValueEnumDestructuringWithRename\n\nDefault value is Fizz."},{"name":"getValidPropertyDefaultValueEnumDestructuringWithRenameInArguments","visibility":"public","returnValue":{"type":"testlib.ThisIsEnumToo","description":"Value of property validPropertyDefaultValueEnumDestructuringWithRenameInArguments"},"description":"Gets current value of property {@link #getValidPropertyDefaultValueEnumDestructuringWithRenameInArguments validPropertyDefaultValueEnumDestructuringWithRenameInArguments}.\n\nvalidPropertyDefaultValueEnumDestructuringWithRenameInArguments\n\nDefault value is Value1."},{"name":"getValidPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar","visibility":"public","returnValue":{"type":"testlib.ThisIsEnumToo","description":"Value of property validPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar"},"description":"Gets current value of property {@link #getValidPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar validPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar}.\n\nvalidPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar\n\nDefault value is Value2."},{"name":"getValidPropertyDefaultValueEnumSimpleDestructuring","visibility":"public","returnValue":{"type":"testlib.AnotherValidEnum","description":"Value of property validPropertyDefaultValueEnumSimpleDestructuring"},"description":"Gets current value of property {@link #getValidPropertyDefaultValueEnumSimpleDestructuring validPropertyDefaultValueEnumSimpleDestructuring}.\n\nvalidPropertyDefaultValueEnumSimpleDestructuring\n\nDefault value is Buzz."},{"name":"getValidPropertyDefaultValueEnumViaDestructuringGlobal","visibility":"public","returnValue":{"type":"sap.ui.core.TitleLevel","description":"Value of property validPropertyDefaultValueEnumViaDestructuringGlobal"},"description":"Gets current value of property {@link #getValidPropertyDefaultValueEnumViaDestructuringGlobal validPropertyDefaultValueEnumViaDestructuringGlobal}.\n\nvalidPropertyDefaultValueEnumViaDestructuringGlobal\n\nDefault value is H1."},{"name":"getValidPropertyDefaultValueEnumViaDestructuringInArrowFn","visibility":"public","returnValue":{"type":"testlib.MyValidEnum","description":"Value of property validPropertyDefaultValueEnumViaDestructuringInArrowFn"},"description":"Gets current value of property {@link #getValidPropertyDefaultValueEnumViaDestructuringInArrowFn validPropertyDefaultValueEnumViaDestructuringInArrowFn}.\n\nvalidPropertyDefaultValueEnumViaDestructuringInArrowFn\n\nDefault value is Foo."},{"name":"setValidPropertyDefaultValueEnumChainedDestructuring","visibility":"public","returnValue":{"type":"this","description":"Reference to this in order to allow method chaining"},"parameters":[{"name":"sValidPropertyDefaultValueEnumChainedDestructuring","type":"testlib.AnotherValidEnum","optional":true,"defaultValue":"Buzz","description":"New value for property validPropertyDefaultValueEnumChainedDestructuring"}],"description":"Sets a new value for property {@link #getValidPropertyDefaultValueEnumChainedDestructuring validPropertyDefaultValueEnumChainedDestructuring}.\n\nvalidPropertyDefaultValueEnumChainedDestructuring\n\nWhen called with a value of null or undefined, the default value of the property will be restored.\n\nDefault value is Buzz."},{"name":"setValidPropertyDefaultValueEnumDestructuringWithRename","visibility":"public","returnValue":{"type":"this","description":"Reference to this in order to allow method chaining"},"parameters":[{"name":"sValidPropertyDefaultValueEnumDestructuringWithRename","type":"testlib.AnotherValidEnum","optional":true,"defaultValue":"Fizz","description":"New value for property validPropertyDefaultValueEnumDestructuringWithRename"}],"description":"Sets a new value for property {@link #getValidPropertyDefaultValueEnumDestructuringWithRename validPropertyDefaultValueEnumDestructuringWithRename}.\n\nvalidPropertyDefaultValueEnumDestructuringWithRename\n\nWhen called with a value of null or undefined, the default value of the property will be restored.\n\nDefault value is Fizz."},{"name":"setValidPropertyDefaultValueEnumDestructuringWithRenameInArguments","visibility":"public","returnValue":{"type":"this","description":"Reference to this in order to allow method chaining"},"parameters":[{"name":"sValidPropertyDefaultValueEnumDestructuringWithRenameInArguments","type":"testlib.ThisIsEnumToo","optional":true,"defaultValue":"Value1","description":"New value for property validPropertyDefaultValueEnumDestructuringWithRenameInArguments"}],"description":"Sets a new value for property {@link #getValidPropertyDefaultValueEnumDestructuringWithRenameInArguments validPropertyDefaultValueEnumDestructuringWithRenameInArguments}.\n\nvalidPropertyDefaultValueEnumDestructuringWithRenameInArguments\n\nWhen called with a value of null or undefined, the default value of the property will be restored.\n\nDefault value is Value1."},{"name":"setValidPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar","visibility":"public","returnValue":{"type":"this","description":"Reference to this in order to allow method chaining"},"parameters":[{"name":"sValidPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar","type":"testlib.ThisIsEnumToo","optional":true,"defaultValue":"Value2","description":"New value for property validPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar"}],"description":"Sets a new value for property {@link #getValidPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar validPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar}.\n\nvalidPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar\n\nWhen called with a value of null or undefined, the default value of the property will be restored.\n\nDefault value is Value2."},{"name":"setValidPropertyDefaultValueEnumSimpleDestructuring","visibility":"public","returnValue":{"type":"this","description":"Reference to this in order to allow method chaining"},"parameters":[{"name":"sValidPropertyDefaultValueEnumSimpleDestructuring","type":"testlib.AnotherValidEnum","optional":true,"defaultValue":"Buzz","description":"New value for property validPropertyDefaultValueEnumSimpleDestructuring"}],"description":"Sets a new value for property {@link #getValidPropertyDefaultValueEnumSimpleDestructuring validPropertyDefaultValueEnumSimpleDestructuring}.\n\nvalidPropertyDefaultValueEnumSimpleDestructuring\n\nWhen called with a value of null or undefined, the default value of the property will be restored.\n\nDefault value is Buzz."},{"name":"setValidPropertyDefaultValueEnumViaDestructuringGlobal","visibility":"public","returnValue":{"type":"this","description":"Reference to this in order to allow method chaining"},"parameters":[{"name":"sValidPropertyDefaultValueEnumViaDestructuringGlobal","type":"sap.ui.core.TitleLevel","optional":true,"defaultValue":"H1","description":"New value for property validPropertyDefaultValueEnumViaDestructuringGlobal"}],"description":"Sets a new value for property {@link #getValidPropertyDefaultValueEnumViaDestructuringGlobal validPropertyDefaultValueEnumViaDestructuringGlobal}.\n\nvalidPropertyDefaultValueEnumViaDestructuringGlobal\n\nWhen called with a value of null or undefined, the default value of the property will be restored.\n\nDefault value is H1."},{"name":"setValidPropertyDefaultValueEnumViaDestructuringInArrowFn","visibility":"public","returnValue":{"type":"this","description":"Reference to this in order to allow method chaining"},"parameters":[{"name":"sValidPropertyDefaultValueEnumViaDestructuringInArrowFn","type":"testlib.MyValidEnum","optional":true,"defaultValue":"Foo","description":"New value for property validPropertyDefaultValueEnumViaDestructuringInArrowFn"}],"description":"Sets a new value for property {@link #getValidPropertyDefaultValueEnumViaDestructuringInArrowFn validPropertyDefaultValueEnumViaDestructuringInArrowFn}.\n\nvalidPropertyDefaultValueEnumViaDestructuringInArrowFn\n\nWhen called with a value of null or undefined, the default value of the property will be restored.\n\nDefault value is Foo."}]}]} \ No newline at end of file From 7500083026ade79a704ae7301e0b1f4e5c01b38c Mon Sep 17 00:00:00 2001 From: Yavor Ivanov Date: Fri, 9 Sep 2022 16:11:16 +0300 Subject: [PATCH 24/69] Put renamed var as key in the localNames --- lib/processors/jsdoc/lib/ui5/plugin.cjs | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/lib/processors/jsdoc/lib/ui5/plugin.cjs b/lib/processors/jsdoc/lib/ui5/plugin.cjs index 0c2bb7acb..832edf96b 100644 --- a/lib/processors/jsdoc/lib/ui5/plugin.cjs +++ b/lib/processors/jsdoc/lib/ui5/plugin.cjs @@ -274,19 +274,17 @@ function analyzeModuleDefinition(node) { .variables.filter((curVar) => prop.value.name === curVar.name)[0]; const renamedVar = checkVarRenaming(resolvedVar); - return renamedVar ? renamedVar.original : prop.value.name; + return { original: renamedVar.original, renamed: prop.value.name }; }) // ObjectPattern means destructuring of the parameter - : [currentModule.factory.params[i].name]; // simple Identifier + : [{original: currentModule.factory.params[i].name}]; // simple Identifier names.forEach(name => { const module = resolveModuleName(currentModule.module, currentModule.dependencies[i]); - debug(` import ${name} from '${module}'`); + debug(` import ${name.renamed || name.original} from '${module}'`); - // TODO: localNames MUST have the renamed var as a key, but a property with the original name - // For example: {"MyVarRenamed": {module: "/dependency1.js", property: "myVarOriginal"}} - // In cases without a rename, MyVarRenamed === myVarOriginal - currentModule.localNames[name] = { - module: module + currentModule.localNames[name.renamed || name.original] = { + module: module, + property: name.original, // no (or empty) path }; }); @@ -700,14 +698,14 @@ function checkVarRenaming (variable) { let potentialRename = variable.defs .reduce((acc, def) => { - if (def.node?.type === Syntax.ArrowFunctionExpression) { + if (def.node && def.node.type === Syntax.ArrowFunctionExpression) { acc = acc.concat(def.node.params); - } else { - acc.push(def.node?.id); + } else if (def.node) { + acc.push(def.node.id); } return acc; }, []) - .filter((param) => param.type === Syntax.ObjectPattern) // Filter on object patterns => Detructure renamig + .filter((param) => param && param.type === Syntax.ObjectPattern) // Filter on object patterns => Detructure renamig // .map( // (def) => // def.node.id /* ObjectPattern */ || From ea06965879876f5dd8d5d65e389cfee586c6b780 Mon Sep 17 00:00:00 2001 From: Yavor Ivanov Date: Mon, 12 Sep 2022 14:38:44 +0300 Subject: [PATCH 25/69] Remove optional chaining in plugin as we need to support node 12 --- lib/processors/jsdoc/lib/ui5/plugin.cjs | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/lib/processors/jsdoc/lib/ui5/plugin.cjs b/lib/processors/jsdoc/lib/ui5/plugin.cjs index 832edf96b..7bb57fa8f 100644 --- a/lib/processors/jsdoc/lib/ui5/plugin.cjs +++ b/lib/processors/jsdoc/lib/ui5/plugin.cjs @@ -521,9 +521,10 @@ function stripChainWrappers(rootNode, path) { function isTemplateLiteralWithoutExpression(node) { return ( - node?.type === Syntax.TemplateLiteral && - node?.expressions?.length === 0 && - node?.quasis?.length === 1 + node && + node.type === Syntax.TemplateLiteral && + node.expressions && node.expressions.length === 0 && + node.quasis && node.quasis.length === 1 ); } @@ -805,7 +806,7 @@ function resolveFullyQuantifiedName(node, type) { if (potentialChunk && potentialChunk.renamed) { originalName = originalName.replace( - new RegExp("(^|\.)" + potentialChunk.renamed + "($|\.)"), + new RegExp("(^|.)" + potentialChunk.renamed + "($|.)"), "$1" + potentialChunk.original + "$2" ); } @@ -947,9 +948,9 @@ function convertValueWithRaw(node, type, propertyName) { if ( potentialEnum ) { return potentialEnum; -// } else if ( value.indexOf(type.split(".").slice(-1)[0] + ".") === 0 ) { -// // unqualified name might be a local name (just a guess - would need static code analysis for proper solution) -// return value.slice(type.split(".").slice(-1)[0].length + 1); + // } else if ( value.indexOf(type.split(".").slice(-1)[0] + ".") === 0 ) { + // // unqualified name might be a local name (just a guess - would need static code analysis for proper solution) + // return value.slice(type.split(".").slice(-1)[0].length + 1); } else { value = getResolvedObjectName(node); warning(`did not understand default value '${value}'${propertyName ? " of property '" + propertyName + "'" : ""}, falling back to source`); @@ -1011,11 +1012,15 @@ function convertValueWithRaw(node, type, propertyName) { raw: "{}" }; } - + } else if ( isTemplateLiteralWithoutExpression(node) ) { + let value = {}; + if (node && node.quasis && node.quasis[0] && node.quasis[0].value) { + value = node.quasis[0].value; + } return { - value: node?.quasis?.[0]?.value?.cooked, - raw: node?.quasis?.[0]?.value?.raw, + value: value.cooked, + raw: value.raw, }; } From 63d54641d783ab43d082c19d71f1db064af24c7f Mon Sep 17 00:00:00 2001 From: Yavor Ivanov Date: Mon, 12 Sep 2022 14:42:51 +0300 Subject: [PATCH 26/69] Adjust tests --- test/expected/build/library.j/dest/resources/library/j/some.js | 2 +- .../library.j/dest/test-resources/library/j/designtime/api.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/expected/build/library.j/dest/resources/library/j/some.js b/test/expected/build/library.j/dest/resources/library/j/some.js index a0758c0e9..dad1fd304 100644 --- a/test/expected/build/library.j/dest/resources/library/j/some.js +++ b/test/expected/build/library.j/dest/resources/library/j/some.js @@ -8,7 +8,7 @@ sap.ui.define([ "./dependency-es6-1", "./dependency-es6-2", "./dependency-es6-3" -], (Control, { MyValidEnum, ThisIsEnumToo: RenamedEnum }, library, es6_1, , es6_2, , es6_3) => { +], (Control, { MyValidEnum, ThisIsEnumToo: RenamedEnum }, library, es6_1, es6_2, es6_3) => { const { AnotherValidEnum } = library; const { Buzz } = AnotherValidEnum; diff --git a/test/expected/build/library.j/dest/test-resources/library/j/designtime/api.json b/test/expected/build/library.j/dest/test-resources/library/j/designtime/api.json index 4a701199d..43a901ff9 100644 --- a/test/expected/build/library.j/dest/test-resources/library/j/designtime/api.json +++ b/test/expected/build/library.j/dest/test-resources/library/j/designtime/api.json @@ -1 +1 @@ -{"$schema-ref":"http://schemas.sap.com/sapui5/designtime/api.json/1.0","version":"1.0.0","library":"library.j","symbols":[{"kind":"enum","name":"testlib.AnotherValidEnum","basename":"AnotherValidEnum","resource":"library/j/dependency2.js","module":"library/j/dependency2","static":true,"visibility":"public","description":"AnotherValidEnum","ui5-metamodel":true,"ui5-metadata":{"stereotype":"enum"},"properties":[{"name":"Buzz","visibility":"public","static":true,"type":"string","description":"Bar"},{"name":"Fizz","visibility":"public","static":true,"type":"string","description":"Fizz"}]},{"kind":"enum","name":"testlib.MyValidEnum","basename":"MyValidEnum","resource":"library/j/dependency.js","module":"library/j/dependency","static":true,"visibility":"public","description":"MyValidEnum","ui5-metamodel":true,"ui5-metadata":{"stereotype":"enum"},"properties":[{"name":"Bar","visibility":"public","static":true,"type":"string","description":"Bar"},{"name":"Foo","visibility":"public","static":true,"type":"string","description":"Foo"}]},{"kind":"enum","name":"testlib.ThisIsEnumToo","basename":"ThisIsEnumToo","resource":"library/j/dependency.js","module":"library/j/dependency","static":true,"visibility":"public","description":"ThisIsEnumToo","ui5-metadata":{"stereotype":"enum"},"properties":[{"name":"Value1","visibility":"public","static":true,"type":"string","description":"Foo"},{"name":"Value2","visibility":"public","static":true,"type":"string","description":"Bar"}]},{"kind":"class","name":"testlib.ValidPropertyDefaultValue","basename":"ValidPropertyDefaultValue","resource":"library/j/some.js","module":"library/j/some","export":"","static":true,"visibility":"public","extends":"sap.ui.core.Control","description":"My super documentation of this class","ui5-metamodel":true,"ui5-metadata":{"stereotype":"control","properties":[{"name":"validPropertyDefaultValueEnumSimpleDestructuring","type":"testlib.AnotherValidEnum","defaultValue":"Buzz","group":"Misc","visibility":"public","description":"validPropertyDefaultValueEnumSimpleDestructuring","methods":["getValidPropertyDefaultValueEnumSimpleDestructuring","setValidPropertyDefaultValueEnumSimpleDestructuring"]},{"name":"validPropertyDefaultValueEnumChainedDestructuring","type":"testlib.AnotherValidEnum","defaultValue":"Buzz","group":"Misc","visibility":"public","description":"validPropertyDefaultValueEnumChainedDestructuring","methods":["getValidPropertyDefaultValueEnumChainedDestructuring","setValidPropertyDefaultValueEnumChainedDestructuring"]},{"name":"validPropertyDefaultValueEnumDestructuringWithRename","type":"testlib.AnotherValidEnum","defaultValue":"Fizz","group":"Misc","visibility":"public","description":"validPropertyDefaultValueEnumDestructuringWithRename","methods":["getValidPropertyDefaultValueEnumDestructuringWithRename","setValidPropertyDefaultValueEnumDestructuringWithRename"]},{"name":"validPropertyDefaultValueEnumDestructuringWithRenameInArguments","type":"testlib.ThisIsEnumToo","defaultValue":"Value1","group":"Misc","visibility":"public","description":"validPropertyDefaultValueEnumDestructuringWithRenameInArguments","methods":["getValidPropertyDefaultValueEnumDestructuringWithRenameInArguments","setValidPropertyDefaultValueEnumDestructuringWithRenameInArguments"]},{"name":"validPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar","type":"testlib.ThisIsEnumToo","defaultValue":"Value2","group":"Misc","visibility":"public","description":"validPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar","methods":["getValidPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar","setValidPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar"]},{"name":"validPropertyDefaultValueEnumViaDestructuringInArrowFn","type":"testlib.MyValidEnum","defaultValue":"Foo","group":"Misc","visibility":"public","description":"validPropertyDefaultValueEnumViaDestructuringInArrowFn","methods":["getValidPropertyDefaultValueEnumViaDestructuringInArrowFn","setValidPropertyDefaultValueEnumViaDestructuringInArrowFn"]},{"name":"validPropertyDefaultValueEnumViaDestructuringGlobal","type":"sap.ui.core.TitleLevel","defaultValue":"H1","group":"Misc","visibility":"public","description":"validPropertyDefaultValueEnumViaDestructuringGlobal","methods":["getValidPropertyDefaultValueEnumViaDestructuringGlobal","setValidPropertyDefaultValueEnumViaDestructuringGlobal"]}]},"constructor":{"visibility":"public","description":"Accepts an object literal mSettings that defines initial property values, aggregated and associated objects as well as event handlers. See {@link sap.ui.base.ManagedObject#constructor} for a general description of the syntax of the settings object."},"methods":[{"name":"extend","visibility":"public","static":true,"returnValue":{"type":"function","description":"Created class / constructor function"},"parameters":[{"name":"sClassName","type":"string","optional":false,"description":"Name of the class being created"},{"name":"oClassInfo","type":"object","optional":true,"description":"Object literal with information about the class"},{"name":"FNMetaImpl","type":"function","optional":true,"description":"Constructor function for the metadata object; if not given, it defaults to the metadata implementation used by this class"}],"description":"Creates a new subclass of class testlib.ValidPropertyDefaultValue with name sClassName and enriches it with the information contained in oClassInfo.\n\noClassInfo might contain the same kind of information as described in {@link sap.ui.core.Control.extend}."},{"name":"getMetadata","visibility":"public","static":true,"returnValue":{"type":"sap.ui.base.Metadata","description":"Metadata object describing this class"},"description":"Returns a metadata object for class testlib.ValidPropertyDefaultValue."},{"name":"getValidPropertyDefaultValueEnumChainedDestructuring","visibility":"public","returnValue":{"type":"testlib.AnotherValidEnum","description":"Value of property validPropertyDefaultValueEnumChainedDestructuring"},"description":"Gets current value of property {@link #getValidPropertyDefaultValueEnumChainedDestructuring validPropertyDefaultValueEnumChainedDestructuring}.\n\nvalidPropertyDefaultValueEnumChainedDestructuring\n\nDefault value is Buzz."},{"name":"getValidPropertyDefaultValueEnumDestructuringWithRename","visibility":"public","returnValue":{"type":"testlib.AnotherValidEnum","description":"Value of property validPropertyDefaultValueEnumDestructuringWithRename"},"description":"Gets current value of property {@link #getValidPropertyDefaultValueEnumDestructuringWithRename validPropertyDefaultValueEnumDestructuringWithRename}.\n\nvalidPropertyDefaultValueEnumDestructuringWithRename\n\nDefault value is Fizz."},{"name":"getValidPropertyDefaultValueEnumDestructuringWithRenameInArguments","visibility":"public","returnValue":{"type":"testlib.ThisIsEnumToo","description":"Value of property validPropertyDefaultValueEnumDestructuringWithRenameInArguments"},"description":"Gets current value of property {@link #getValidPropertyDefaultValueEnumDestructuringWithRenameInArguments validPropertyDefaultValueEnumDestructuringWithRenameInArguments}.\n\nvalidPropertyDefaultValueEnumDestructuringWithRenameInArguments\n\nDefault value is Value1."},{"name":"getValidPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar","visibility":"public","returnValue":{"type":"testlib.ThisIsEnumToo","description":"Value of property validPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar"},"description":"Gets current value of property {@link #getValidPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar validPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar}.\n\nvalidPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar\n\nDefault value is Value2."},{"name":"getValidPropertyDefaultValueEnumSimpleDestructuring","visibility":"public","returnValue":{"type":"testlib.AnotherValidEnum","description":"Value of property validPropertyDefaultValueEnumSimpleDestructuring"},"description":"Gets current value of property {@link #getValidPropertyDefaultValueEnumSimpleDestructuring validPropertyDefaultValueEnumSimpleDestructuring}.\n\nvalidPropertyDefaultValueEnumSimpleDestructuring\n\nDefault value is Buzz."},{"name":"getValidPropertyDefaultValueEnumViaDestructuringGlobal","visibility":"public","returnValue":{"type":"sap.ui.core.TitleLevel","description":"Value of property validPropertyDefaultValueEnumViaDestructuringGlobal"},"description":"Gets current value of property {@link #getValidPropertyDefaultValueEnumViaDestructuringGlobal validPropertyDefaultValueEnumViaDestructuringGlobal}.\n\nvalidPropertyDefaultValueEnumViaDestructuringGlobal\n\nDefault value is H1."},{"name":"getValidPropertyDefaultValueEnumViaDestructuringInArrowFn","visibility":"public","returnValue":{"type":"testlib.MyValidEnum","description":"Value of property validPropertyDefaultValueEnumViaDestructuringInArrowFn"},"description":"Gets current value of property {@link #getValidPropertyDefaultValueEnumViaDestructuringInArrowFn validPropertyDefaultValueEnumViaDestructuringInArrowFn}.\n\nvalidPropertyDefaultValueEnumViaDestructuringInArrowFn\n\nDefault value is Foo."},{"name":"setValidPropertyDefaultValueEnumChainedDestructuring","visibility":"public","returnValue":{"type":"this","description":"Reference to this in order to allow method chaining"},"parameters":[{"name":"sValidPropertyDefaultValueEnumChainedDestructuring","type":"testlib.AnotherValidEnum","optional":true,"defaultValue":"Buzz","description":"New value for property validPropertyDefaultValueEnumChainedDestructuring"}],"description":"Sets a new value for property {@link #getValidPropertyDefaultValueEnumChainedDestructuring validPropertyDefaultValueEnumChainedDestructuring}.\n\nvalidPropertyDefaultValueEnumChainedDestructuring\n\nWhen called with a value of null or undefined, the default value of the property will be restored.\n\nDefault value is Buzz."},{"name":"setValidPropertyDefaultValueEnumDestructuringWithRename","visibility":"public","returnValue":{"type":"this","description":"Reference to this in order to allow method chaining"},"parameters":[{"name":"sValidPropertyDefaultValueEnumDestructuringWithRename","type":"testlib.AnotherValidEnum","optional":true,"defaultValue":"Fizz","description":"New value for property validPropertyDefaultValueEnumDestructuringWithRename"}],"description":"Sets a new value for property {@link #getValidPropertyDefaultValueEnumDestructuringWithRename validPropertyDefaultValueEnumDestructuringWithRename}.\n\nvalidPropertyDefaultValueEnumDestructuringWithRename\n\nWhen called with a value of null or undefined, the default value of the property will be restored.\n\nDefault value is Fizz."},{"name":"setValidPropertyDefaultValueEnumDestructuringWithRenameInArguments","visibility":"public","returnValue":{"type":"this","description":"Reference to this in order to allow method chaining"},"parameters":[{"name":"sValidPropertyDefaultValueEnumDestructuringWithRenameInArguments","type":"testlib.ThisIsEnumToo","optional":true,"defaultValue":"Value1","description":"New value for property validPropertyDefaultValueEnumDestructuringWithRenameInArguments"}],"description":"Sets a new value for property {@link #getValidPropertyDefaultValueEnumDestructuringWithRenameInArguments validPropertyDefaultValueEnumDestructuringWithRenameInArguments}.\n\nvalidPropertyDefaultValueEnumDestructuringWithRenameInArguments\n\nWhen called with a value of null or undefined, the default value of the property will be restored.\n\nDefault value is Value1."},{"name":"setValidPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar","visibility":"public","returnValue":{"type":"this","description":"Reference to this in order to allow method chaining"},"parameters":[{"name":"sValidPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar","type":"testlib.ThisIsEnumToo","optional":true,"defaultValue":"Value2","description":"New value for property validPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar"}],"description":"Sets a new value for property {@link #getValidPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar validPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar}.\n\nvalidPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar\n\nWhen called with a value of null or undefined, the default value of the property will be restored.\n\nDefault value is Value2."},{"name":"setValidPropertyDefaultValueEnumSimpleDestructuring","visibility":"public","returnValue":{"type":"this","description":"Reference to this in order to allow method chaining"},"parameters":[{"name":"sValidPropertyDefaultValueEnumSimpleDestructuring","type":"testlib.AnotherValidEnum","optional":true,"defaultValue":"Buzz","description":"New value for property validPropertyDefaultValueEnumSimpleDestructuring"}],"description":"Sets a new value for property {@link #getValidPropertyDefaultValueEnumSimpleDestructuring validPropertyDefaultValueEnumSimpleDestructuring}.\n\nvalidPropertyDefaultValueEnumSimpleDestructuring\n\nWhen called with a value of null or undefined, the default value of the property will be restored.\n\nDefault value is Buzz."},{"name":"setValidPropertyDefaultValueEnumViaDestructuringGlobal","visibility":"public","returnValue":{"type":"this","description":"Reference to this in order to allow method chaining"},"parameters":[{"name":"sValidPropertyDefaultValueEnumViaDestructuringGlobal","type":"sap.ui.core.TitleLevel","optional":true,"defaultValue":"H1","description":"New value for property validPropertyDefaultValueEnumViaDestructuringGlobal"}],"description":"Sets a new value for property {@link #getValidPropertyDefaultValueEnumViaDestructuringGlobal validPropertyDefaultValueEnumViaDestructuringGlobal}.\n\nvalidPropertyDefaultValueEnumViaDestructuringGlobal\n\nWhen called with a value of null or undefined, the default value of the property will be restored.\n\nDefault value is H1."},{"name":"setValidPropertyDefaultValueEnumViaDestructuringInArrowFn","visibility":"public","returnValue":{"type":"this","description":"Reference to this in order to allow method chaining"},"parameters":[{"name":"sValidPropertyDefaultValueEnumViaDestructuringInArrowFn","type":"testlib.MyValidEnum","optional":true,"defaultValue":"Foo","description":"New value for property validPropertyDefaultValueEnumViaDestructuringInArrowFn"}],"description":"Sets a new value for property {@link #getValidPropertyDefaultValueEnumViaDestructuringInArrowFn validPropertyDefaultValueEnumViaDestructuringInArrowFn}.\n\nvalidPropertyDefaultValueEnumViaDestructuringInArrowFn\n\nWhen called with a value of null or undefined, the default value of the property will be restored.\n\nDefault value is Foo."}]}]} \ No newline at end of file +{"$schema-ref":"http://schemas.sap.com/sapui5/designtime/api.json/1.0","version":"1.0.0","library":"library.j","symbols":[{"kind":"class","name":"library.j.aaa","basename":"aaa","resource":"library/j/dependency-es6-2.js","module":"library/j/dependency-es6-2","export":"","static":true,"visibility":"public","since":"1.22","extends":"library.j.a","ui5-metamodel":true,"ui5-metadata":{"properties":[{"name":"MyProp","type":"boolean","defaultValue":false,"group":"undefined","visibility":"public","since":"1.46","description":"MyProp property","methods":["getMyProp","setMyProp"]}]},"constructor":{"visibility":"public","parameters":[{"name":"sId","type":"string","optional":true,"description":"ID for the new control, generated automatically if no ID is given"},{"name":"mSettings","type":"object","optional":true,"description":"Initial settings for the new control"}],"description":"Constructor for a new library.j.aaa."},"methods":[{"name":"extend","visibility":"public","static":true,"returnValue":{"type":"function","description":"Created class / constructor function"},"parameters":[{"name":"sClassName","type":"string","optional":false,"description":"Name of the class being created"},{"name":"oClassInfo","type":"object","optional":true,"description":"Object literal with information about the class"},{"name":"FNMetaImpl","type":"function","optional":true,"description":"Constructor function for the metadata object; if not given, it defaults to the metadata implementation used by this class"}],"description":"Creates a new subclass of class library.j.aaa with name sClassName and enriches it with the information contained in oClassInfo.\n\noClassInfo might contain the same kind of information as described in {@link library.j.a.extend}."},{"name":"getMetadata","visibility":"public","static":true,"returnValue":{"type":"sap.ui.base.Metadata","description":"Metadata object describing this class"},"description":"Returns a metadata object for class library.j.aaa."},{"name":"getMyProp","visibility":"public","since":"1.46","returnValue":{"type":"boolean","description":"Value of property MyProp"},"description":"Gets current value of property {@link #getMyProp MyProp}.\n\nMyProp property\n\nDefault value is false."},{"name":"setMyProp","visibility":"public","since":"1.46","returnValue":{"type":"this","description":"Reference to this in order to allow method chaining"},"parameters":[{"name":"bMyProp","type":"boolean","optional":true,"defaultValue":false,"description":"New value for property MyProp"}],"description":"Sets a new value for property {@link #getMyProp MyProp}.\n\nMyProp property\n\nWhen called with a value of null or undefined, the default value of the property will be restored.\n\nDefault value is false."}]},{"kind":"class","name":"library.j.Foo","basename":"Foo","resource":"library/j/dependency-es6-1.js","module":"library/j/dependency-es6-1","static":true,"visibility":"public","extends":"library.j.Bar","description":"My super documentation of this class","constructor":{"visibility":"public"}},{"kind":"enum","name":"testlib.AnotherValidEnum","basename":"AnotherValidEnum","resource":"library/j/dependency2.js","module":"library/j/dependency2","static":true,"visibility":"public","description":"AnotherValidEnum","ui5-metamodel":true,"ui5-metadata":{"stereotype":"enum"},"properties":[{"name":"Buzz","visibility":"public","static":true,"type":"string","description":"Bar"},{"name":"Fizz","visibility":"public","static":true,"type":"string","description":"Fizz"}]},{"kind":"enum","name":"testlib.MyValidEnum","basename":"MyValidEnum","resource":"library/j/dependency.js","module":"library/j/dependency","static":true,"visibility":"public","description":"MyValidEnum","ui5-metamodel":true,"ui5-metadata":{"stereotype":"enum"},"properties":[{"name":"Bar","visibility":"public","static":true,"type":"string","description":"Bar"},{"name":"Foo","visibility":"public","static":true,"type":"string","description":"Foo"}]},{"kind":"enum","name":"testlib.ThisIsEnumToo","basename":"ThisIsEnumToo","resource":"library/j/dependency.js","module":"library/j/dependency","static":true,"visibility":"public","description":"ThisIsEnumToo","ui5-metadata":{"stereotype":"enum"},"properties":[{"name":"Value1","visibility":"public","static":true,"type":"string","description":"Foo"},{"name":"Value2","visibility":"public","static":true,"type":"string","description":"Bar"}]},{"kind":"class","name":"testlib.ValidPropertyDefaultValue","basename":"ValidPropertyDefaultValue","resource":"library/j/some.js","module":"library/j/some","export":"","static":true,"visibility":"public","extends":"sap.ui.core.Control","description":"My super documentation of this class","ui5-metamodel":true,"ui5-metadata":{"stereotype":"control","properties":[{"name":"validPropertyDefaultValueEnumSimpleDestructuring","type":"testlib.AnotherValidEnum","defaultValue":"Buzz","group":"Misc","visibility":"public","description":"validPropertyDefaultValueEnumSimpleDestructuring","methods":["getValidPropertyDefaultValueEnumSimpleDestructuring","setValidPropertyDefaultValueEnumSimpleDestructuring"]},{"name":"validPropertyDefaultValueEnumChainedDestructuring","type":"testlib.AnotherValidEnum","defaultValue":"Buzz","group":"Misc","visibility":"public","description":"validPropertyDefaultValueEnumChainedDestructuring","methods":["getValidPropertyDefaultValueEnumChainedDestructuring","setValidPropertyDefaultValueEnumChainedDestructuring"]},{"name":"validPropertyDefaultValueEnumDestructuringWithRename","type":"testlib.AnotherValidEnum","defaultValue":"Fizz","group":"Misc","visibility":"public","description":"validPropertyDefaultValueEnumDestructuringWithRename","methods":["getValidPropertyDefaultValueEnumDestructuringWithRename","setValidPropertyDefaultValueEnumDestructuringWithRename"]},{"name":"validPropertyDefaultValueEnumDestructuringWithRenameInArguments","type":"testlib.ThisIsEnumToo","defaultValue":"Value1","group":"Misc","visibility":"public","description":"validPropertyDefaultValueEnumDestructuringWithRenameInArguments","methods":["getValidPropertyDefaultValueEnumDestructuringWithRenameInArguments","setValidPropertyDefaultValueEnumDestructuringWithRenameInArguments"]},{"name":"validPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar","type":"testlib.ThisIsEnumToo","defaultValue":"Value2","group":"Misc","visibility":"public","description":"validPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar","methods":["getValidPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar","setValidPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar"]},{"name":"validPropertyDefaultValueEnumViaDestructuringInArrowFn","type":"testlib.MyValidEnum","defaultValue":"Foo","group":"Misc","visibility":"public","description":"validPropertyDefaultValueEnumViaDestructuringInArrowFn","methods":["getValidPropertyDefaultValueEnumViaDestructuringInArrowFn","setValidPropertyDefaultValueEnumViaDestructuringInArrowFn"]},{"name":"validPropertyDefaultValueEnumViaDestructuringGlobal","type":"sap.ui.core.TitleLevel","defaultValue":"H1","group":"Misc","visibility":"public","description":"validPropertyDefaultValueEnumViaDestructuringGlobal","methods":["getValidPropertyDefaultValueEnumViaDestructuringGlobal","setValidPropertyDefaultValueEnumViaDestructuringGlobal"]}]},"constructor":{"visibility":"public","description":"Accepts an object literal mSettings that defines initial property values, aggregated and associated objects as well as event handlers. See {@link sap.ui.base.ManagedObject#constructor} for a general description of the syntax of the settings object."},"methods":[{"name":"extend","visibility":"public","static":true,"returnValue":{"type":"function","description":"Created class / constructor function"},"parameters":[{"name":"sClassName","type":"string","optional":false,"description":"Name of the class being created"},{"name":"oClassInfo","type":"object","optional":true,"description":"Object literal with information about the class"},{"name":"FNMetaImpl","type":"function","optional":true,"description":"Constructor function for the metadata object; if not given, it defaults to the metadata implementation used by this class"}],"description":"Creates a new subclass of class testlib.ValidPropertyDefaultValue with name sClassName and enriches it with the information contained in oClassInfo.\n\noClassInfo might contain the same kind of information as described in {@link sap.ui.core.Control.extend}."},{"name":"getMetadata","visibility":"public","static":true,"returnValue":{"type":"sap.ui.base.Metadata","description":"Metadata object describing this class"},"description":"Returns a metadata object for class testlib.ValidPropertyDefaultValue."},{"name":"getValidPropertyDefaultValueEnumChainedDestructuring","visibility":"public","returnValue":{"type":"testlib.AnotherValidEnum","description":"Value of property validPropertyDefaultValueEnumChainedDestructuring"},"description":"Gets current value of property {@link #getValidPropertyDefaultValueEnumChainedDestructuring validPropertyDefaultValueEnumChainedDestructuring}.\n\nvalidPropertyDefaultValueEnumChainedDestructuring\n\nDefault value is Buzz."},{"name":"getValidPropertyDefaultValueEnumDestructuringWithRename","visibility":"public","returnValue":{"type":"testlib.AnotherValidEnum","description":"Value of property validPropertyDefaultValueEnumDestructuringWithRename"},"description":"Gets current value of property {@link #getValidPropertyDefaultValueEnumDestructuringWithRename validPropertyDefaultValueEnumDestructuringWithRename}.\n\nvalidPropertyDefaultValueEnumDestructuringWithRename\n\nDefault value is Fizz."},{"name":"getValidPropertyDefaultValueEnumDestructuringWithRenameInArguments","visibility":"public","returnValue":{"type":"testlib.ThisIsEnumToo","description":"Value of property validPropertyDefaultValueEnumDestructuringWithRenameInArguments"},"description":"Gets current value of property {@link #getValidPropertyDefaultValueEnumDestructuringWithRenameInArguments validPropertyDefaultValueEnumDestructuringWithRenameInArguments}.\n\nvalidPropertyDefaultValueEnumDestructuringWithRenameInArguments\n\nDefault value is Value1."},{"name":"getValidPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar","visibility":"public","returnValue":{"type":"testlib.ThisIsEnumToo","description":"Value of property validPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar"},"description":"Gets current value of property {@link #getValidPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar validPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar}.\n\nvalidPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar\n\nDefault value is Value2."},{"name":"getValidPropertyDefaultValueEnumSimpleDestructuring","visibility":"public","returnValue":{"type":"testlib.AnotherValidEnum","description":"Value of property validPropertyDefaultValueEnumSimpleDestructuring"},"description":"Gets current value of property {@link #getValidPropertyDefaultValueEnumSimpleDestructuring validPropertyDefaultValueEnumSimpleDestructuring}.\n\nvalidPropertyDefaultValueEnumSimpleDestructuring\n\nDefault value is Buzz."},{"name":"getValidPropertyDefaultValueEnumViaDestructuringGlobal","visibility":"public","returnValue":{"type":"sap.ui.core.TitleLevel","description":"Value of property validPropertyDefaultValueEnumViaDestructuringGlobal"},"description":"Gets current value of property {@link #getValidPropertyDefaultValueEnumViaDestructuringGlobal validPropertyDefaultValueEnumViaDestructuringGlobal}.\n\nvalidPropertyDefaultValueEnumViaDestructuringGlobal\n\nDefault value is H1."},{"name":"getValidPropertyDefaultValueEnumViaDestructuringInArrowFn","visibility":"public","returnValue":{"type":"testlib.MyValidEnum","description":"Value of property validPropertyDefaultValueEnumViaDestructuringInArrowFn"},"description":"Gets current value of property {@link #getValidPropertyDefaultValueEnumViaDestructuringInArrowFn validPropertyDefaultValueEnumViaDestructuringInArrowFn}.\n\nvalidPropertyDefaultValueEnumViaDestructuringInArrowFn\n\nDefault value is Foo."},{"name":"setValidPropertyDefaultValueEnumChainedDestructuring","visibility":"public","returnValue":{"type":"this","description":"Reference to this in order to allow method chaining"},"parameters":[{"name":"sValidPropertyDefaultValueEnumChainedDestructuring","type":"testlib.AnotherValidEnum","optional":true,"defaultValue":"Buzz","description":"New value for property validPropertyDefaultValueEnumChainedDestructuring"}],"description":"Sets a new value for property {@link #getValidPropertyDefaultValueEnumChainedDestructuring validPropertyDefaultValueEnumChainedDestructuring}.\n\nvalidPropertyDefaultValueEnumChainedDestructuring\n\nWhen called with a value of null or undefined, the default value of the property will be restored.\n\nDefault value is Buzz."},{"name":"setValidPropertyDefaultValueEnumDestructuringWithRename","visibility":"public","returnValue":{"type":"this","description":"Reference to this in order to allow method chaining"},"parameters":[{"name":"sValidPropertyDefaultValueEnumDestructuringWithRename","type":"testlib.AnotherValidEnum","optional":true,"defaultValue":"Fizz","description":"New value for property validPropertyDefaultValueEnumDestructuringWithRename"}],"description":"Sets a new value for property {@link #getValidPropertyDefaultValueEnumDestructuringWithRename validPropertyDefaultValueEnumDestructuringWithRename}.\n\nvalidPropertyDefaultValueEnumDestructuringWithRename\n\nWhen called with a value of null or undefined, the default value of the property will be restored.\n\nDefault value is Fizz."},{"name":"setValidPropertyDefaultValueEnumDestructuringWithRenameInArguments","visibility":"public","returnValue":{"type":"this","description":"Reference to this in order to allow method chaining"},"parameters":[{"name":"sValidPropertyDefaultValueEnumDestructuringWithRenameInArguments","type":"testlib.ThisIsEnumToo","optional":true,"defaultValue":"Value1","description":"New value for property validPropertyDefaultValueEnumDestructuringWithRenameInArguments"}],"description":"Sets a new value for property {@link #getValidPropertyDefaultValueEnumDestructuringWithRenameInArguments validPropertyDefaultValueEnumDestructuringWithRenameInArguments}.\n\nvalidPropertyDefaultValueEnumDestructuringWithRenameInArguments\n\nWhen called with a value of null or undefined, the default value of the property will be restored.\n\nDefault value is Value1."},{"name":"setValidPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar","visibility":"public","returnValue":{"type":"this","description":"Reference to this in order to allow method chaining"},"parameters":[{"name":"sValidPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar","type":"testlib.ThisIsEnumToo","optional":true,"defaultValue":"Value2","description":"New value for property validPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar"}],"description":"Sets a new value for property {@link #getValidPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar validPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar}.\n\nvalidPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar\n\nWhen called with a value of null or undefined, the default value of the property will be restored.\n\nDefault value is Value2."},{"name":"setValidPropertyDefaultValueEnumSimpleDestructuring","visibility":"public","returnValue":{"type":"this","description":"Reference to this in order to allow method chaining"},"parameters":[{"name":"sValidPropertyDefaultValueEnumSimpleDestructuring","type":"testlib.AnotherValidEnum","optional":true,"defaultValue":"Buzz","description":"New value for property validPropertyDefaultValueEnumSimpleDestructuring"}],"description":"Sets a new value for property {@link #getValidPropertyDefaultValueEnumSimpleDestructuring validPropertyDefaultValueEnumSimpleDestructuring}.\n\nvalidPropertyDefaultValueEnumSimpleDestructuring\n\nWhen called with a value of null or undefined, the default value of the property will be restored.\n\nDefault value is Buzz."},{"name":"setValidPropertyDefaultValueEnumViaDestructuringGlobal","visibility":"public","returnValue":{"type":"this","description":"Reference to this in order to allow method chaining"},"parameters":[{"name":"sValidPropertyDefaultValueEnumViaDestructuringGlobal","type":"sap.ui.core.TitleLevel","optional":true,"defaultValue":"H1","description":"New value for property validPropertyDefaultValueEnumViaDestructuringGlobal"}],"description":"Sets a new value for property {@link #getValidPropertyDefaultValueEnumViaDestructuringGlobal validPropertyDefaultValueEnumViaDestructuringGlobal}.\n\nvalidPropertyDefaultValueEnumViaDestructuringGlobal\n\nWhen called with a value of null or undefined, the default value of the property will be restored.\n\nDefault value is H1."},{"name":"setValidPropertyDefaultValueEnumViaDestructuringInArrowFn","visibility":"public","returnValue":{"type":"this","description":"Reference to this in order to allow method chaining"},"parameters":[{"name":"sValidPropertyDefaultValueEnumViaDestructuringInArrowFn","type":"testlib.MyValidEnum","optional":true,"defaultValue":"Foo","description":"New value for property validPropertyDefaultValueEnumViaDestructuringInArrowFn"}],"description":"Sets a new value for property {@link #getValidPropertyDefaultValueEnumViaDestructuringInArrowFn validPropertyDefaultValueEnumViaDestructuringInArrowFn}.\n\nvalidPropertyDefaultValueEnumViaDestructuringInArrowFn\n\nWhen called with a value of null or undefined, the default value of the property will be restored.\n\nDefault value is Foo."}]}]} \ No newline at end of file From fbb0cb049c9748a57a2bc3e76b8e36cdfe9df763 Mon Sep 17 00:00:00 2001 From: Yavor Ivanov Date: Mon, 19 Sep 2022 15:50:44 +0300 Subject: [PATCH 27/69] Fixe comments --- lib/processors/jsdoc/lib/ui5/plugin.cjs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/processors/jsdoc/lib/ui5/plugin.cjs b/lib/processors/jsdoc/lib/ui5/plugin.cjs index 7bb57fa8f..b5f1faa92 100644 --- a/lib/processors/jsdoc/lib/ui5/plugin.cjs +++ b/lib/processors/jsdoc/lib/ui5/plugin.cjs @@ -1014,10 +1014,8 @@ function convertValueWithRaw(node, type, propertyName) { } } else if ( isTemplateLiteralWithoutExpression(node) ) { - let value = {}; - if (node && node.quasis && node.quasis[0] && node.quasis[0].value) { - value = node.quasis[0].value; - } + let value = node.quasis[0].value || {}; + return { value: value.cooked, raw: value.raw, From c0b52d4d9202eb39a59d60c8ecc7ce999b16f93e Mon Sep 17 00:00:00 2001 From: Yavor Ivanov Date: Tue, 20 Sep 2022 09:45:13 +0300 Subject: [PATCH 28/69] Replace regex with string comparisson function --- lib/processors/jsdoc/lib/ui5/plugin.cjs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/processors/jsdoc/lib/ui5/plugin.cjs b/lib/processors/jsdoc/lib/ui5/plugin.cjs index b5f1faa92..363fa8217 100644 --- a/lib/processors/jsdoc/lib/ui5/plugin.cjs +++ b/lib/processors/jsdoc/lib/ui5/plugin.cjs @@ -805,9 +805,17 @@ function resolveFullyQuantifiedName(node, type) { } if (potentialChunk && potentialChunk.renamed) { - originalName = originalName.replace( - new RegExp("(^|.)" + potentialChunk.renamed + "($|.)"), - "$1" + potentialChunk.original + "$2" + originalName = originalName.replaceAll( + potentialChunk.renamed, + function (match, index, input) { + var isBeginOrDotInFront = !index || input[index - 1] === "."; + var charInTheEnd = input[index + match.length]; + var isEndOrDotInEnd = !charInTheEnd || charInTheEnd === "."; + + return isBeginOrDotInFront && isEndOrDotInEnd + ? potentialChunk.original + : match; + } ); } } From 272fee5833b12a5d5eaf6a6c32807b7df4af5b63 Mon Sep 17 00:00:00 2001 From: Yavor Ivanov Date: Tue, 20 Sep 2022 10:34:30 +0300 Subject: [PATCH 29/69] Cleanups --- lib/processors/jsdoc/lib/ui5/plugin.cjs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/lib/processors/jsdoc/lib/ui5/plugin.cjs b/lib/processors/jsdoc/lib/ui5/plugin.cjs index 363fa8217..7a980143e 100644 --- a/lib/processors/jsdoc/lib/ui5/plugin.cjs +++ b/lib/processors/jsdoc/lib/ui5/plugin.cjs @@ -706,12 +706,9 @@ function checkVarRenaming (variable) { } return acc; }, []) - .filter((param) => param && param.type === Syntax.ObjectPattern) // Filter on object patterns => Detructure renamig - // .map( - // (def) => - // def.node.id /* ObjectPattern */ || - // def.node.params /* ArrowFunctionExpression */ - // ) // Drill down to the ObjectPattern Node + // Filter on object patterns => Detructure renamig + .filter((param) => param && param.type === Syntax.ObjectPattern) + // Drill down to the ObjectPattern Node .filter((objPatternNode) => objPatternNode.properties.some( (prop) => prop.value.name === variable.name From 719b31707d4c1d65c29aa77793069b6fbd0abfd8 Mon Sep 17 00:00:00 2001 From: Yavor Ivanov Date: Wed, 21 Sep 2022 16:12:24 +0300 Subject: [PATCH 30/69] Typo fixes --- lib/processors/jsdoc/lib/ui5/plugin.cjs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/processors/jsdoc/lib/ui5/plugin.cjs b/lib/processors/jsdoc/lib/ui5/plugin.cjs index 7a980143e..7a3c694b3 100644 --- a/lib/processors/jsdoc/lib/ui5/plugin.cjs +++ b/lib/processors/jsdoc/lib/ui5/plugin.cjs @@ -760,8 +760,6 @@ function resolveFullyQuantifiedName(node, type) { return null; } - // TODO: Check for hierarchical destructuring - // i.e. let {Foo} = myObject; let {Bar} = Foo; --> Bar while (leftMostName) { let potentialChunk = currentScope.variables .filter((curVar) => curVar.name === leftMostName) @@ -844,18 +842,18 @@ function resolveFullyQuantifiedName(node, type) { function getEnclosingVariableScope (node) { // Get to the nearest upper scope let nearestScopeableNode = node; - let neatestScope = scopeManager.acquire(nearestScopeableNode); + let nearestScope = scopeManager.acquire(nearestScopeableNode); while ( - !neatestScope && + !nearestScope && nearestScopeableNode && nearestScopeableNode.parent ) { nearestScopeableNode = nearestScopeableNode.parent; - neatestScope = scopeManager.acquire(nearestScopeableNode); + nearestScope = scopeManager.acquire(nearestScopeableNode); } // Get the scope of the nearest scopeable node - return neatestScope; + return nearestScope; }; function isCompileTimeConstant(node) { From 3ffd86bcf908ee64f461723dff6816c53dd5b28e Mon Sep 17 00:00:00 2001 From: Matthias Osswald Date: Mon, 26 Sep 2022 13:24:21 +0200 Subject: [PATCH 31/69] Store expected api.json as beautified json --- .../library/j/designtime/api.json | 567 +++++++++++++++++- test/lib/builder/builder.js | 4 + 2 files changed, 570 insertions(+), 1 deletion(-) diff --git a/test/expected/build/library.j/dest/test-resources/library/j/designtime/api.json b/test/expected/build/library.j/dest/test-resources/library/j/designtime/api.json index 43a901ff9..826393e0f 100644 --- a/test/expected/build/library.j/dest/test-resources/library/j/designtime/api.json +++ b/test/expected/build/library.j/dest/test-resources/library/j/designtime/api.json @@ -1 +1,566 @@ -{"$schema-ref":"http://schemas.sap.com/sapui5/designtime/api.json/1.0","version":"1.0.0","library":"library.j","symbols":[{"kind":"class","name":"library.j.aaa","basename":"aaa","resource":"library/j/dependency-es6-2.js","module":"library/j/dependency-es6-2","export":"","static":true,"visibility":"public","since":"1.22","extends":"library.j.a","ui5-metamodel":true,"ui5-metadata":{"properties":[{"name":"MyProp","type":"boolean","defaultValue":false,"group":"undefined","visibility":"public","since":"1.46","description":"MyProp property","methods":["getMyProp","setMyProp"]}]},"constructor":{"visibility":"public","parameters":[{"name":"sId","type":"string","optional":true,"description":"ID for the new control, generated automatically if no ID is given"},{"name":"mSettings","type":"object","optional":true,"description":"Initial settings for the new control"}],"description":"Constructor for a new library.j.aaa."},"methods":[{"name":"extend","visibility":"public","static":true,"returnValue":{"type":"function","description":"Created class / constructor function"},"parameters":[{"name":"sClassName","type":"string","optional":false,"description":"Name of the class being created"},{"name":"oClassInfo","type":"object","optional":true,"description":"Object literal with information about the class"},{"name":"FNMetaImpl","type":"function","optional":true,"description":"Constructor function for the metadata object; if not given, it defaults to the metadata implementation used by this class"}],"description":"Creates a new subclass of class library.j.aaa with name sClassName and enriches it with the information contained in oClassInfo.\n\noClassInfo might contain the same kind of information as described in {@link library.j.a.extend}."},{"name":"getMetadata","visibility":"public","static":true,"returnValue":{"type":"sap.ui.base.Metadata","description":"Metadata object describing this class"},"description":"Returns a metadata object for class library.j.aaa."},{"name":"getMyProp","visibility":"public","since":"1.46","returnValue":{"type":"boolean","description":"Value of property MyProp"},"description":"Gets current value of property {@link #getMyProp MyProp}.\n\nMyProp property\n\nDefault value is false."},{"name":"setMyProp","visibility":"public","since":"1.46","returnValue":{"type":"this","description":"Reference to this in order to allow method chaining"},"parameters":[{"name":"bMyProp","type":"boolean","optional":true,"defaultValue":false,"description":"New value for property MyProp"}],"description":"Sets a new value for property {@link #getMyProp MyProp}.\n\nMyProp property\n\nWhen called with a value of null or undefined, the default value of the property will be restored.\n\nDefault value is false."}]},{"kind":"class","name":"library.j.Foo","basename":"Foo","resource":"library/j/dependency-es6-1.js","module":"library/j/dependency-es6-1","static":true,"visibility":"public","extends":"library.j.Bar","description":"My super documentation of this class","constructor":{"visibility":"public"}},{"kind":"enum","name":"testlib.AnotherValidEnum","basename":"AnotherValidEnum","resource":"library/j/dependency2.js","module":"library/j/dependency2","static":true,"visibility":"public","description":"AnotherValidEnum","ui5-metamodel":true,"ui5-metadata":{"stereotype":"enum"},"properties":[{"name":"Buzz","visibility":"public","static":true,"type":"string","description":"Bar"},{"name":"Fizz","visibility":"public","static":true,"type":"string","description":"Fizz"}]},{"kind":"enum","name":"testlib.MyValidEnum","basename":"MyValidEnum","resource":"library/j/dependency.js","module":"library/j/dependency","static":true,"visibility":"public","description":"MyValidEnum","ui5-metamodel":true,"ui5-metadata":{"stereotype":"enum"},"properties":[{"name":"Bar","visibility":"public","static":true,"type":"string","description":"Bar"},{"name":"Foo","visibility":"public","static":true,"type":"string","description":"Foo"}]},{"kind":"enum","name":"testlib.ThisIsEnumToo","basename":"ThisIsEnumToo","resource":"library/j/dependency.js","module":"library/j/dependency","static":true,"visibility":"public","description":"ThisIsEnumToo","ui5-metadata":{"stereotype":"enum"},"properties":[{"name":"Value1","visibility":"public","static":true,"type":"string","description":"Foo"},{"name":"Value2","visibility":"public","static":true,"type":"string","description":"Bar"}]},{"kind":"class","name":"testlib.ValidPropertyDefaultValue","basename":"ValidPropertyDefaultValue","resource":"library/j/some.js","module":"library/j/some","export":"","static":true,"visibility":"public","extends":"sap.ui.core.Control","description":"My super documentation of this class","ui5-metamodel":true,"ui5-metadata":{"stereotype":"control","properties":[{"name":"validPropertyDefaultValueEnumSimpleDestructuring","type":"testlib.AnotherValidEnum","defaultValue":"Buzz","group":"Misc","visibility":"public","description":"validPropertyDefaultValueEnumSimpleDestructuring","methods":["getValidPropertyDefaultValueEnumSimpleDestructuring","setValidPropertyDefaultValueEnumSimpleDestructuring"]},{"name":"validPropertyDefaultValueEnumChainedDestructuring","type":"testlib.AnotherValidEnum","defaultValue":"Buzz","group":"Misc","visibility":"public","description":"validPropertyDefaultValueEnumChainedDestructuring","methods":["getValidPropertyDefaultValueEnumChainedDestructuring","setValidPropertyDefaultValueEnumChainedDestructuring"]},{"name":"validPropertyDefaultValueEnumDestructuringWithRename","type":"testlib.AnotherValidEnum","defaultValue":"Fizz","group":"Misc","visibility":"public","description":"validPropertyDefaultValueEnumDestructuringWithRename","methods":["getValidPropertyDefaultValueEnumDestructuringWithRename","setValidPropertyDefaultValueEnumDestructuringWithRename"]},{"name":"validPropertyDefaultValueEnumDestructuringWithRenameInArguments","type":"testlib.ThisIsEnumToo","defaultValue":"Value1","group":"Misc","visibility":"public","description":"validPropertyDefaultValueEnumDestructuringWithRenameInArguments","methods":["getValidPropertyDefaultValueEnumDestructuringWithRenameInArguments","setValidPropertyDefaultValueEnumDestructuringWithRenameInArguments"]},{"name":"validPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar","type":"testlib.ThisIsEnumToo","defaultValue":"Value2","group":"Misc","visibility":"public","description":"validPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar","methods":["getValidPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar","setValidPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar"]},{"name":"validPropertyDefaultValueEnumViaDestructuringInArrowFn","type":"testlib.MyValidEnum","defaultValue":"Foo","group":"Misc","visibility":"public","description":"validPropertyDefaultValueEnumViaDestructuringInArrowFn","methods":["getValidPropertyDefaultValueEnumViaDestructuringInArrowFn","setValidPropertyDefaultValueEnumViaDestructuringInArrowFn"]},{"name":"validPropertyDefaultValueEnumViaDestructuringGlobal","type":"sap.ui.core.TitleLevel","defaultValue":"H1","group":"Misc","visibility":"public","description":"validPropertyDefaultValueEnumViaDestructuringGlobal","methods":["getValidPropertyDefaultValueEnumViaDestructuringGlobal","setValidPropertyDefaultValueEnumViaDestructuringGlobal"]}]},"constructor":{"visibility":"public","description":"Accepts an object literal mSettings that defines initial property values, aggregated and associated objects as well as event handlers. See {@link sap.ui.base.ManagedObject#constructor} for a general description of the syntax of the settings object."},"methods":[{"name":"extend","visibility":"public","static":true,"returnValue":{"type":"function","description":"Created class / constructor function"},"parameters":[{"name":"sClassName","type":"string","optional":false,"description":"Name of the class being created"},{"name":"oClassInfo","type":"object","optional":true,"description":"Object literal with information about the class"},{"name":"FNMetaImpl","type":"function","optional":true,"description":"Constructor function for the metadata object; if not given, it defaults to the metadata implementation used by this class"}],"description":"Creates a new subclass of class testlib.ValidPropertyDefaultValue with name sClassName and enriches it with the information contained in oClassInfo.\n\noClassInfo might contain the same kind of information as described in {@link sap.ui.core.Control.extend}."},{"name":"getMetadata","visibility":"public","static":true,"returnValue":{"type":"sap.ui.base.Metadata","description":"Metadata object describing this class"},"description":"Returns a metadata object for class testlib.ValidPropertyDefaultValue."},{"name":"getValidPropertyDefaultValueEnumChainedDestructuring","visibility":"public","returnValue":{"type":"testlib.AnotherValidEnum","description":"Value of property validPropertyDefaultValueEnumChainedDestructuring"},"description":"Gets current value of property {@link #getValidPropertyDefaultValueEnumChainedDestructuring validPropertyDefaultValueEnumChainedDestructuring}.\n\nvalidPropertyDefaultValueEnumChainedDestructuring\n\nDefault value is Buzz."},{"name":"getValidPropertyDefaultValueEnumDestructuringWithRename","visibility":"public","returnValue":{"type":"testlib.AnotherValidEnum","description":"Value of property validPropertyDefaultValueEnumDestructuringWithRename"},"description":"Gets current value of property {@link #getValidPropertyDefaultValueEnumDestructuringWithRename validPropertyDefaultValueEnumDestructuringWithRename}.\n\nvalidPropertyDefaultValueEnumDestructuringWithRename\n\nDefault value is Fizz."},{"name":"getValidPropertyDefaultValueEnumDestructuringWithRenameInArguments","visibility":"public","returnValue":{"type":"testlib.ThisIsEnumToo","description":"Value of property validPropertyDefaultValueEnumDestructuringWithRenameInArguments"},"description":"Gets current value of property {@link #getValidPropertyDefaultValueEnumDestructuringWithRenameInArguments validPropertyDefaultValueEnumDestructuringWithRenameInArguments}.\n\nvalidPropertyDefaultValueEnumDestructuringWithRenameInArguments\n\nDefault value is Value1."},{"name":"getValidPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar","visibility":"public","returnValue":{"type":"testlib.ThisIsEnumToo","description":"Value of property validPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar"},"description":"Gets current value of property {@link #getValidPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar validPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar}.\n\nvalidPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar\n\nDefault value is Value2."},{"name":"getValidPropertyDefaultValueEnumSimpleDestructuring","visibility":"public","returnValue":{"type":"testlib.AnotherValidEnum","description":"Value of property validPropertyDefaultValueEnumSimpleDestructuring"},"description":"Gets current value of property {@link #getValidPropertyDefaultValueEnumSimpleDestructuring validPropertyDefaultValueEnumSimpleDestructuring}.\n\nvalidPropertyDefaultValueEnumSimpleDestructuring\n\nDefault value is Buzz."},{"name":"getValidPropertyDefaultValueEnumViaDestructuringGlobal","visibility":"public","returnValue":{"type":"sap.ui.core.TitleLevel","description":"Value of property validPropertyDefaultValueEnumViaDestructuringGlobal"},"description":"Gets current value of property {@link #getValidPropertyDefaultValueEnumViaDestructuringGlobal validPropertyDefaultValueEnumViaDestructuringGlobal}.\n\nvalidPropertyDefaultValueEnumViaDestructuringGlobal\n\nDefault value is H1."},{"name":"getValidPropertyDefaultValueEnumViaDestructuringInArrowFn","visibility":"public","returnValue":{"type":"testlib.MyValidEnum","description":"Value of property validPropertyDefaultValueEnumViaDestructuringInArrowFn"},"description":"Gets current value of property {@link #getValidPropertyDefaultValueEnumViaDestructuringInArrowFn validPropertyDefaultValueEnumViaDestructuringInArrowFn}.\n\nvalidPropertyDefaultValueEnumViaDestructuringInArrowFn\n\nDefault value is Foo."},{"name":"setValidPropertyDefaultValueEnumChainedDestructuring","visibility":"public","returnValue":{"type":"this","description":"Reference to this in order to allow method chaining"},"parameters":[{"name":"sValidPropertyDefaultValueEnumChainedDestructuring","type":"testlib.AnotherValidEnum","optional":true,"defaultValue":"Buzz","description":"New value for property validPropertyDefaultValueEnumChainedDestructuring"}],"description":"Sets a new value for property {@link #getValidPropertyDefaultValueEnumChainedDestructuring validPropertyDefaultValueEnumChainedDestructuring}.\n\nvalidPropertyDefaultValueEnumChainedDestructuring\n\nWhen called with a value of null or undefined, the default value of the property will be restored.\n\nDefault value is Buzz."},{"name":"setValidPropertyDefaultValueEnumDestructuringWithRename","visibility":"public","returnValue":{"type":"this","description":"Reference to this in order to allow method chaining"},"parameters":[{"name":"sValidPropertyDefaultValueEnumDestructuringWithRename","type":"testlib.AnotherValidEnum","optional":true,"defaultValue":"Fizz","description":"New value for property validPropertyDefaultValueEnumDestructuringWithRename"}],"description":"Sets a new value for property {@link #getValidPropertyDefaultValueEnumDestructuringWithRename validPropertyDefaultValueEnumDestructuringWithRename}.\n\nvalidPropertyDefaultValueEnumDestructuringWithRename\n\nWhen called with a value of null or undefined, the default value of the property will be restored.\n\nDefault value is Fizz."},{"name":"setValidPropertyDefaultValueEnumDestructuringWithRenameInArguments","visibility":"public","returnValue":{"type":"this","description":"Reference to this in order to allow method chaining"},"parameters":[{"name":"sValidPropertyDefaultValueEnumDestructuringWithRenameInArguments","type":"testlib.ThisIsEnumToo","optional":true,"defaultValue":"Value1","description":"New value for property validPropertyDefaultValueEnumDestructuringWithRenameInArguments"}],"description":"Sets a new value for property {@link #getValidPropertyDefaultValueEnumDestructuringWithRenameInArguments validPropertyDefaultValueEnumDestructuringWithRenameInArguments}.\n\nvalidPropertyDefaultValueEnumDestructuringWithRenameInArguments\n\nWhen called with a value of null or undefined, the default value of the property will be restored.\n\nDefault value is Value1."},{"name":"setValidPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar","visibility":"public","returnValue":{"type":"this","description":"Reference to this in order to allow method chaining"},"parameters":[{"name":"sValidPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar","type":"testlib.ThisIsEnumToo","optional":true,"defaultValue":"Value2","description":"New value for property validPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar"}],"description":"Sets a new value for property {@link #getValidPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar validPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar}.\n\nvalidPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar\n\nWhen called with a value of null or undefined, the default value of the property will be restored.\n\nDefault value is Value2."},{"name":"setValidPropertyDefaultValueEnumSimpleDestructuring","visibility":"public","returnValue":{"type":"this","description":"Reference to this in order to allow method chaining"},"parameters":[{"name":"sValidPropertyDefaultValueEnumSimpleDestructuring","type":"testlib.AnotherValidEnum","optional":true,"defaultValue":"Buzz","description":"New value for property validPropertyDefaultValueEnumSimpleDestructuring"}],"description":"Sets a new value for property {@link #getValidPropertyDefaultValueEnumSimpleDestructuring validPropertyDefaultValueEnumSimpleDestructuring}.\n\nvalidPropertyDefaultValueEnumSimpleDestructuring\n\nWhen called with a value of null or undefined, the default value of the property will be restored.\n\nDefault value is Buzz."},{"name":"setValidPropertyDefaultValueEnumViaDestructuringGlobal","visibility":"public","returnValue":{"type":"this","description":"Reference to this in order to allow method chaining"},"parameters":[{"name":"sValidPropertyDefaultValueEnumViaDestructuringGlobal","type":"sap.ui.core.TitleLevel","optional":true,"defaultValue":"H1","description":"New value for property validPropertyDefaultValueEnumViaDestructuringGlobal"}],"description":"Sets a new value for property {@link #getValidPropertyDefaultValueEnumViaDestructuringGlobal validPropertyDefaultValueEnumViaDestructuringGlobal}.\n\nvalidPropertyDefaultValueEnumViaDestructuringGlobal\n\nWhen called with a value of null or undefined, the default value of the property will be restored.\n\nDefault value is H1."},{"name":"setValidPropertyDefaultValueEnumViaDestructuringInArrowFn","visibility":"public","returnValue":{"type":"this","description":"Reference to this in order to allow method chaining"},"parameters":[{"name":"sValidPropertyDefaultValueEnumViaDestructuringInArrowFn","type":"testlib.MyValidEnum","optional":true,"defaultValue":"Foo","description":"New value for property validPropertyDefaultValueEnumViaDestructuringInArrowFn"}],"description":"Sets a new value for property {@link #getValidPropertyDefaultValueEnumViaDestructuringInArrowFn validPropertyDefaultValueEnumViaDestructuringInArrowFn}.\n\nvalidPropertyDefaultValueEnumViaDestructuringInArrowFn\n\nWhen called with a value of null or undefined, the default value of the property will be restored.\n\nDefault value is Foo."}]}]} \ No newline at end of file +{ + "$schema-ref": "http://schemas.sap.com/sapui5/designtime/api.json/1.0", + "version": "1.0.0", + "library": "library.j", + "symbols": [ + { + "kind": "class", + "name": "library.j.aaa", + "basename": "aaa", + "resource": "library/j/dependency-es6-2.js", + "module": "library/j/dependency-es6-2", + "export": "", + "static": true, + "visibility": "public", + "since": "1.22", + "extends": "library.j.a", + "ui5-metamodel": true, + "ui5-metadata": { + "properties": [ + { + "name": "MyProp", + "type": "boolean", + "defaultValue": false, + "group": "undefined", + "visibility": "public", + "since": "1.46", + "description": "MyProp property", + "methods": [ + "getMyProp", + "setMyProp" + ] + } + ] + }, + "constructor": { + "visibility": "public", + "parameters": [ + { + "name": "sId", + "type": "string", + "optional": true, + "description": "ID for the new control, generated automatically if no ID is given" + }, + { + "name": "mSettings", + "type": "object", + "optional": true, + "description": "Initial settings for the new control" + } + ], + "description": "Constructor for a new library.j.aaa." + }, + "methods": [ + { + "name": "extend", + "visibility": "public", + "static": true, + "returnValue": { + "type": "function", + "description": "Created class / constructor function" + }, + "parameters": [ + { + "name": "sClassName", + "type": "string", + "optional": false, + "description": "Name of the class being created" + }, + { + "name": "oClassInfo", + "type": "object", + "optional": true, + "description": "Object literal with information about the class" + }, + { + "name": "FNMetaImpl", + "type": "function", + "optional": true, + "description": "Constructor function for the metadata object; if not given, it defaults to the metadata implementation used by this class" + } + ], + "description": "Creates a new subclass of class library.j.aaa with name sClassName and enriches it with the information contained in oClassInfo.\n\noClassInfo might contain the same kind of information as described in {@link library.j.a.extend}." + }, + { + "name": "getMetadata", + "visibility": "public", + "static": true, + "returnValue": { + "type": "sap.ui.base.Metadata", + "description": "Metadata object describing this class" + }, + "description": "Returns a metadata object for class library.j.aaa." + }, + { + "name": "getMyProp", + "visibility": "public", + "since": "1.46", + "returnValue": { + "type": "boolean", + "description": "Value of property MyProp" + }, + "description": "Gets current value of property {@link #getMyProp MyProp}.\n\nMyProp property\n\nDefault value is false." + }, + { + "name": "setMyProp", + "visibility": "public", + "since": "1.46", + "returnValue": { + "type": "this", + "description": "Reference to this in order to allow method chaining" + }, + "parameters": [ + { + "name": "bMyProp", + "type": "boolean", + "optional": true, + "defaultValue": false, + "description": "New value for property MyProp" + } + ], + "description": "Sets a new value for property {@link #getMyProp MyProp}.\n\nMyProp property\n\nWhen called with a value of null or undefined, the default value of the property will be restored.\n\nDefault value is false." + } + ] + }, + { + "kind": "class", + "name": "library.j.Foo", + "basename": "Foo", + "resource": "library/j/dependency-es6-1.js", + "module": "library/j/dependency-es6-1", + "static": true, + "visibility": "public", + "extends": "library.j.Bar", + "description": "My super documentation of this class", + "constructor": { + "visibility": "public" + } + }, + { + "kind": "enum", + "name": "testlib.AnotherValidEnum", + "basename": "AnotherValidEnum", + "resource": "library/j/dependency2.js", + "module": "library/j/dependency2", + "static": true, + "visibility": "public", + "description": "AnotherValidEnum", + "ui5-metamodel": true, + "ui5-metadata": { + "stereotype": "enum" + }, + "properties": [ + { + "name": "Buzz", + "visibility": "public", + "static": true, + "type": "string", + "description": "Bar" + }, + { + "name": "Fizz", + "visibility": "public", + "static": true, + "type": "string", + "description": "Fizz" + } + ] + }, + { + "kind": "enum", + "name": "testlib.MyValidEnum", + "basename": "MyValidEnum", + "resource": "library/j/dependency.js", + "module": "library/j/dependency", + "static": true, + "visibility": "public", + "description": "MyValidEnum", + "ui5-metamodel": true, + "ui5-metadata": { + "stereotype": "enum" + }, + "properties": [ + { + "name": "Bar", + "visibility": "public", + "static": true, + "type": "string", + "description": "Bar" + }, + { + "name": "Foo", + "visibility": "public", + "static": true, + "type": "string", + "description": "Foo" + } + ] + }, + { + "kind": "enum", + "name": "testlib.ThisIsEnumToo", + "basename": "ThisIsEnumToo", + "resource": "library/j/dependency.js", + "module": "library/j/dependency", + "static": true, + "visibility": "public", + "description": "ThisIsEnumToo", + "ui5-metadata": { + "stereotype": "enum" + }, + "properties": [ + { + "name": "Value1", + "visibility": "public", + "static": true, + "type": "string", + "description": "Foo" + }, + { + "name": "Value2", + "visibility": "public", + "static": true, + "type": "string", + "description": "Bar" + } + ] + }, + { + "kind": "class", + "name": "testlib.ValidPropertyDefaultValue", + "basename": "ValidPropertyDefaultValue", + "resource": "library/j/some.js", + "module": "library/j/some", + "export": "", + "static": true, + "visibility": "public", + "extends": "sap.ui.core.Control", + "description": "My super documentation of this class", + "ui5-metamodel": true, + "ui5-metadata": { + "stereotype": "control", + "properties": [ + { + "name": "validPropertyDefaultValueEnumSimpleDestructuring", + "type": "testlib.AnotherValidEnum", + "defaultValue": "Buzz", + "group": "Misc", + "visibility": "public", + "description": "validPropertyDefaultValueEnumSimpleDestructuring", + "methods": [ + "getValidPropertyDefaultValueEnumSimpleDestructuring", + "setValidPropertyDefaultValueEnumSimpleDestructuring" + ] + }, + { + "name": "validPropertyDefaultValueEnumChainedDestructuring", + "type": "testlib.AnotherValidEnum", + "defaultValue": "Buzz", + "group": "Misc", + "visibility": "public", + "description": "validPropertyDefaultValueEnumChainedDestructuring", + "methods": [ + "getValidPropertyDefaultValueEnumChainedDestructuring", + "setValidPropertyDefaultValueEnumChainedDestructuring" + ] + }, + { + "name": "validPropertyDefaultValueEnumDestructuringWithRename", + "type": "testlib.AnotherValidEnum", + "defaultValue": "Fizz", + "group": "Misc", + "visibility": "public", + "description": "validPropertyDefaultValueEnumDestructuringWithRename", + "methods": [ + "getValidPropertyDefaultValueEnumDestructuringWithRename", + "setValidPropertyDefaultValueEnumDestructuringWithRename" + ] + }, + { + "name": "validPropertyDefaultValueEnumDestructuringWithRenameInArguments", + "type": "testlib.ThisIsEnumToo", + "defaultValue": "Value1", + "group": "Misc", + "visibility": "public", + "description": "validPropertyDefaultValueEnumDestructuringWithRenameInArguments", + "methods": [ + "getValidPropertyDefaultValueEnumDestructuringWithRenameInArguments", + "setValidPropertyDefaultValueEnumDestructuringWithRenameInArguments" + ] + }, + { + "name": "validPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar", + "type": "testlib.ThisIsEnumToo", + "defaultValue": "Value2", + "group": "Misc", + "visibility": "public", + "description": "validPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar", + "methods": [ + "getValidPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar", + "setValidPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar" + ] + }, + { + "name": "validPropertyDefaultValueEnumViaDestructuringInArrowFn", + "type": "testlib.MyValidEnum", + "defaultValue": "Foo", + "group": "Misc", + "visibility": "public", + "description": "validPropertyDefaultValueEnumViaDestructuringInArrowFn", + "methods": [ + "getValidPropertyDefaultValueEnumViaDestructuringInArrowFn", + "setValidPropertyDefaultValueEnumViaDestructuringInArrowFn" + ] + }, + { + "name": "validPropertyDefaultValueEnumViaDestructuringGlobal", + "type": "sap.ui.core.TitleLevel", + "defaultValue": "H1", + "group": "Misc", + "visibility": "public", + "description": "validPropertyDefaultValueEnumViaDestructuringGlobal", + "methods": [ + "getValidPropertyDefaultValueEnumViaDestructuringGlobal", + "setValidPropertyDefaultValueEnumViaDestructuringGlobal" + ] + } + ] + }, + "constructor": { + "visibility": "public", + "description": "Accepts an object literal mSettings that defines initial property values, aggregated and associated objects as well as event handlers. See {@link sap.ui.base.ManagedObject#constructor} for a general description of the syntax of the settings object." + }, + "methods": [ + { + "name": "extend", + "visibility": "public", + "static": true, + "returnValue": { + "type": "function", + "description": "Created class / constructor function" + }, + "parameters": [ + { + "name": "sClassName", + "type": "string", + "optional": false, + "description": "Name of the class being created" + }, + { + "name": "oClassInfo", + "type": "object", + "optional": true, + "description": "Object literal with information about the class" + }, + { + "name": "FNMetaImpl", + "type": "function", + "optional": true, + "description": "Constructor function for the metadata object; if not given, it defaults to the metadata implementation used by this class" + } + ], + "description": "Creates a new subclass of class testlib.ValidPropertyDefaultValue with name sClassName and enriches it with the information contained in oClassInfo.\n\noClassInfo might contain the same kind of information as described in {@link sap.ui.core.Control.extend}." + }, + { + "name": "getMetadata", + "visibility": "public", + "static": true, + "returnValue": { + "type": "sap.ui.base.Metadata", + "description": "Metadata object describing this class" + }, + "description": "Returns a metadata object for class testlib.ValidPropertyDefaultValue." + }, + { + "name": "getValidPropertyDefaultValueEnumChainedDestructuring", + "visibility": "public", + "returnValue": { + "type": "testlib.AnotherValidEnum", + "description": "Value of property validPropertyDefaultValueEnumChainedDestructuring" + }, + "description": "Gets current value of property {@link #getValidPropertyDefaultValueEnumChainedDestructuring validPropertyDefaultValueEnumChainedDestructuring}.\n\nvalidPropertyDefaultValueEnumChainedDestructuring\n\nDefault value is Buzz." + }, + { + "name": "getValidPropertyDefaultValueEnumDestructuringWithRename", + "visibility": "public", + "returnValue": { + "type": "testlib.AnotherValidEnum", + "description": "Value of property validPropertyDefaultValueEnumDestructuringWithRename" + }, + "description": "Gets current value of property {@link #getValidPropertyDefaultValueEnumDestructuringWithRename validPropertyDefaultValueEnumDestructuringWithRename}.\n\nvalidPropertyDefaultValueEnumDestructuringWithRename\n\nDefault value is Fizz." + }, + { + "name": "getValidPropertyDefaultValueEnumDestructuringWithRenameInArguments", + "visibility": "public", + "returnValue": { + "type": "testlib.ThisIsEnumToo", + "description": "Value of property validPropertyDefaultValueEnumDestructuringWithRenameInArguments" + }, + "description": "Gets current value of property {@link #getValidPropertyDefaultValueEnumDestructuringWithRenameInArguments validPropertyDefaultValueEnumDestructuringWithRenameInArguments}.\n\nvalidPropertyDefaultValueEnumDestructuringWithRenameInArguments\n\nDefault value is Value1." + }, + { + "name": "getValidPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar", + "visibility": "public", + "returnValue": { + "type": "testlib.ThisIsEnumToo", + "description": "Value of property validPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar" + }, + "description": "Gets current value of property {@link #getValidPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar validPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar}.\n\nvalidPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar\n\nDefault value is Value2." + }, + { + "name": "getValidPropertyDefaultValueEnumSimpleDestructuring", + "visibility": "public", + "returnValue": { + "type": "testlib.AnotherValidEnum", + "description": "Value of property validPropertyDefaultValueEnumSimpleDestructuring" + }, + "description": "Gets current value of property {@link #getValidPropertyDefaultValueEnumSimpleDestructuring validPropertyDefaultValueEnumSimpleDestructuring}.\n\nvalidPropertyDefaultValueEnumSimpleDestructuring\n\nDefault value is Buzz." + }, + { + "name": "getValidPropertyDefaultValueEnumViaDestructuringGlobal", + "visibility": "public", + "returnValue": { + "type": "sap.ui.core.TitleLevel", + "description": "Value of property validPropertyDefaultValueEnumViaDestructuringGlobal" + }, + "description": "Gets current value of property {@link #getValidPropertyDefaultValueEnumViaDestructuringGlobal validPropertyDefaultValueEnumViaDestructuringGlobal}.\n\nvalidPropertyDefaultValueEnumViaDestructuringGlobal\n\nDefault value is H1." + }, + { + "name": "getValidPropertyDefaultValueEnumViaDestructuringInArrowFn", + "visibility": "public", + "returnValue": { + "type": "testlib.MyValidEnum", + "description": "Value of property validPropertyDefaultValueEnumViaDestructuringInArrowFn" + }, + "description": "Gets current value of property {@link #getValidPropertyDefaultValueEnumViaDestructuringInArrowFn validPropertyDefaultValueEnumViaDestructuringInArrowFn}.\n\nvalidPropertyDefaultValueEnumViaDestructuringInArrowFn\n\nDefault value is Foo." + }, + { + "name": "setValidPropertyDefaultValueEnumChainedDestructuring", + "visibility": "public", + "returnValue": { + "type": "this", + "description": "Reference to this in order to allow method chaining" + }, + "parameters": [ + { + "name": "sValidPropertyDefaultValueEnumChainedDestructuring", + "type": "testlib.AnotherValidEnum", + "optional": true, + "defaultValue": "Buzz", + "description": "New value for property validPropertyDefaultValueEnumChainedDestructuring" + } + ], + "description": "Sets a new value for property {@link #getValidPropertyDefaultValueEnumChainedDestructuring validPropertyDefaultValueEnumChainedDestructuring}.\n\nvalidPropertyDefaultValueEnumChainedDestructuring\n\nWhen called with a value of null or undefined, the default value of the property will be restored.\n\nDefault value is Buzz." + }, + { + "name": "setValidPropertyDefaultValueEnumDestructuringWithRename", + "visibility": "public", + "returnValue": { + "type": "this", + "description": "Reference to this in order to allow method chaining" + }, + "parameters": [ + { + "name": "sValidPropertyDefaultValueEnumDestructuringWithRename", + "type": "testlib.AnotherValidEnum", + "optional": true, + "defaultValue": "Fizz", + "description": "New value for property validPropertyDefaultValueEnumDestructuringWithRename" + } + ], + "description": "Sets a new value for property {@link #getValidPropertyDefaultValueEnumDestructuringWithRename validPropertyDefaultValueEnumDestructuringWithRename}.\n\nvalidPropertyDefaultValueEnumDestructuringWithRename\n\nWhen called with a value of null or undefined, the default value of the property will be restored.\n\nDefault value is Fizz." + }, + { + "name": "setValidPropertyDefaultValueEnumDestructuringWithRenameInArguments", + "visibility": "public", + "returnValue": { + "type": "this", + "description": "Reference to this in order to allow method chaining" + }, + "parameters": [ + { + "name": "sValidPropertyDefaultValueEnumDestructuringWithRenameInArguments", + "type": "testlib.ThisIsEnumToo", + "optional": true, + "defaultValue": "Value1", + "description": "New value for property validPropertyDefaultValueEnumDestructuringWithRenameInArguments" + } + ], + "description": "Sets a new value for property {@link #getValidPropertyDefaultValueEnumDestructuringWithRenameInArguments validPropertyDefaultValueEnumDestructuringWithRenameInArguments}.\n\nvalidPropertyDefaultValueEnumDestructuringWithRenameInArguments\n\nWhen called with a value of null or undefined, the default value of the property will be restored.\n\nDefault value is Value1." + }, + { + "name": "setValidPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar", + "visibility": "public", + "returnValue": { + "type": "this", + "description": "Reference to this in order to allow method chaining" + }, + "parameters": [ + { + "name": "sValidPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar", + "type": "testlib.ThisIsEnumToo", + "optional": true, + "defaultValue": "Value2", + "description": "New value for property validPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar" + } + ], + "description": "Sets a new value for property {@link #getValidPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar validPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar}.\n\nvalidPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar\n\nWhen called with a value of null or undefined, the default value of the property will be restored.\n\nDefault value is Value2." + }, + { + "name": "setValidPropertyDefaultValueEnumSimpleDestructuring", + "visibility": "public", + "returnValue": { + "type": "this", + "description": "Reference to this in order to allow method chaining" + }, + "parameters": [ + { + "name": "sValidPropertyDefaultValueEnumSimpleDestructuring", + "type": "testlib.AnotherValidEnum", + "optional": true, + "defaultValue": "Buzz", + "description": "New value for property validPropertyDefaultValueEnumSimpleDestructuring" + } + ], + "description": "Sets a new value for property {@link #getValidPropertyDefaultValueEnumSimpleDestructuring validPropertyDefaultValueEnumSimpleDestructuring}.\n\nvalidPropertyDefaultValueEnumSimpleDestructuring\n\nWhen called with a value of null or undefined, the default value of the property will be restored.\n\nDefault value is Buzz." + }, + { + "name": "setValidPropertyDefaultValueEnumViaDestructuringGlobal", + "visibility": "public", + "returnValue": { + "type": "this", + "description": "Reference to this in order to allow method chaining" + }, + "parameters": [ + { + "name": "sValidPropertyDefaultValueEnumViaDestructuringGlobal", + "type": "sap.ui.core.TitleLevel", + "optional": true, + "defaultValue": "H1", + "description": "New value for property validPropertyDefaultValueEnumViaDestructuringGlobal" + } + ], + "description": "Sets a new value for property {@link #getValidPropertyDefaultValueEnumViaDestructuringGlobal validPropertyDefaultValueEnumViaDestructuringGlobal}.\n\nvalidPropertyDefaultValueEnumViaDestructuringGlobal\n\nWhen called with a value of null or undefined, the default value of the property will be restored.\n\nDefault value is H1." + }, + { + "name": "setValidPropertyDefaultValueEnumViaDestructuringInArrowFn", + "visibility": "public", + "returnValue": { + "type": "this", + "description": "Reference to this in order to allow method chaining" + }, + "parameters": [ + { + "name": "sValidPropertyDefaultValueEnumViaDestructuringInArrowFn", + "type": "testlib.MyValidEnum", + "optional": true, + "defaultValue": "Foo", + "description": "New value for property validPropertyDefaultValueEnumViaDestructuringInArrowFn" + } + ], + "description": "Sets a new value for property {@link #getValidPropertyDefaultValueEnumViaDestructuringInArrowFn validPropertyDefaultValueEnumViaDestructuringInArrowFn}.\n\nvalidPropertyDefaultValueEnumViaDestructuringInArrowFn\n\nWhen called with a value of null or undefined, the default value of the property will be restored.\n\nDefault value is Foo." + } + ] + } + ] +} \ No newline at end of file diff --git a/test/lib/builder/builder.js b/test/lib/builder/builder.js index da01e9586..408707ff9 100644 --- a/test/lib/builder/builder.js +++ b/test/lib/builder/builder.js @@ -894,6 +894,10 @@ test.serial("Build library.j with JSDoc build only", async (t) => { excludedTasks: ["*"] }); + // // Beautify api.json, so that it can be better read and compared + const apiJsonPath = path.join(destPath, "test-resources", "library", "j", "designtime", "api.json"); + fs.writeFileSync(apiJsonPath, JSON.stringify(JSON.parse(fs.readFileSync(apiJsonPath, "utf-8")), null, "\t")); + const expectedFiles = await findFiles(expectedPath); // Check for all directories and files directoryDeepEqual(t, destPath, expectedPath); From 8afbadbcb7f3bbce2f178ef200c46183910bc7f3 Mon Sep 17 00:00:00 2001 From: Yavor Ivanov Date: Wed, 28 Sep 2022 10:04:26 +0300 Subject: [PATCH 32/69] Remove renaming --- lib/processors/jsdoc/lib/ui5/plugin.cjs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/processors/jsdoc/lib/ui5/plugin.cjs b/lib/processors/jsdoc/lib/ui5/plugin.cjs index 7a3c694b3..3d25f4229 100644 --- a/lib/processors/jsdoc/lib/ui5/plugin.cjs +++ b/lib/processors/jsdoc/lib/ui5/plugin.cjs @@ -283,8 +283,7 @@ function analyzeModuleDefinition(node) { debug(` import ${name.renamed || name.original} from '${module}'`); currentModule.localNames[name.renamed || name.original] = { - module: module, - property: name.original, + module: module // no (or empty) path }; }); From 46826182e5c108ee1079aef74b2bf287625b9a1c Mon Sep 17 00:00:00 2001 From: Yavor Ivanov Date: Thu, 29 Sep 2022 14:55:23 +0300 Subject: [PATCH 33/69] Remove commented code --- lib/processors/jsdoc/lib/ui5/plugin.cjs | 3 --- 1 file changed, 3 deletions(-) diff --git a/lib/processors/jsdoc/lib/ui5/plugin.cjs b/lib/processors/jsdoc/lib/ui5/plugin.cjs index 3d25f4229..a65a321a6 100644 --- a/lib/processors/jsdoc/lib/ui5/plugin.cjs +++ b/lib/processors/jsdoc/lib/ui5/plugin.cjs @@ -950,9 +950,6 @@ function convertValueWithRaw(node, type, propertyName) { if ( potentialEnum ) { return potentialEnum; - // } else if ( value.indexOf(type.split(".").slice(-1)[0] + ".") === 0 ) { - // // unqualified name might be a local name (just a guess - would need static code analysis for proper solution) - // return value.slice(type.split(".").slice(-1)[0].length + 1); } else { value = getResolvedObjectName(node); warning(`did not understand default value '${value}'${propertyName ? " of property '" + propertyName + "'" : ""}, falling back to source`); From 1d944e3e4096a4f1b5dad4eada94e2a14d71ffec Mon Sep 17 00:00:00 2001 From: Yavor Ivanov Date: Thu, 29 Sep 2022 15:12:20 +0300 Subject: [PATCH 34/69] Make tests closer to the real world naming and usage --- .../j/{dependency2.js => library-core.js} | 10 +++---- .../library/j/{dependency.js => library.js} | 12 ++++---- .../dest/resources/library/j/some.js | 29 +++++++++---------- test/lib/builder/builder.js | 2 +- 4 files changed, 25 insertions(+), 28 deletions(-) rename test/expected/build/library.j/dest/resources/library/j/{dependency2.js => library-core.js} (68%) rename test/expected/build/library.j/dest/resources/library/j/{dependency.js => library.js} (75%) diff --git a/test/expected/build/library.j/dest/resources/library/j/dependency2.js b/test/expected/build/library.j/dest/resources/library/j/library-core.js similarity index 68% rename from test/expected/build/library.j/dest/resources/library/j/dependency2.js rename to test/expected/build/library.j/dest/resources/library/j/library-core.js index aff06f291..18ce26a63 100644 --- a/test/expected/build/library.j/dest/resources/library/j/dependency2.js +++ b/test/expected/build/library.j/dest/resources/library/j/library-core.js @@ -3,11 +3,11 @@ */ sap.ui.define([], function () { sap.ui.getCore().initLibrary({ - name: "testlib", + name: "library.j.core", version: "${version}", dependencies: ["sap.ui.core"], - designtime: "testlib/designtime/library.designtime", - types: ["testlib.AnotherValidEnum"], + designtime: "library/j/core/designtime/library.designtime", + types: ["library.j.core.AnotherValidEnum"], }); /** @@ -17,7 +17,7 @@ sap.ui.define([], function () { * @public * @ui5-metamodel This enumeration also will be described in the UI5 (legacy) designtime metamodel */ - testlib.AnotherValidEnum = { + library.j.core.AnotherValidEnum = { /** * Fizz * @public @@ -30,5 +30,5 @@ sap.ui.define([], function () { Buzz: "Buzz", }; - return testlib; + return library.j.core; }); diff --git a/test/expected/build/library.j/dest/resources/library/j/dependency.js b/test/expected/build/library.j/dest/resources/library/j/library.js similarity index 75% rename from test/expected/build/library.j/dest/resources/library/j/dependency.js rename to test/expected/build/library.j/dest/resources/library/j/library.js index ba161f274..3808348b2 100644 --- a/test/expected/build/library.j/dest/resources/library/j/dependency.js +++ b/test/expected/build/library.j/dest/resources/library/j/library.js @@ -3,11 +3,11 @@ */ sap.ui.define([], function () { sap.ui.getCore().initLibrary({ - name: "testlib", + name: "library.j", version: "${version}", dependencies: ["sap.ui.core"], - designtime: "testlib/designtime/library.designtime", - types: ["testlib.MyValidEnum"], + designtime: "library.j/designtime/library.designtime", + types: ["library.j.MyValidEnum"], }); /** @@ -17,7 +17,7 @@ sap.ui.define([], function () { * @public * @ui5-metamodel This enumeration also will be described in the UI5 (legacy) designtime metamodel */ - testlib.MyValidEnum = { + library.j.MyValidEnum = { /** * Foo * @public @@ -36,7 +36,7 @@ sap.ui.define([], function () { * @enum {string} * @public */ - testlib.ThisIsEnumToo = { + library.j.ThisIsEnumToo = { /** * Foo * @public @@ -49,5 +49,5 @@ sap.ui.define([], function () { Value2: "Value2", }; - return testlib; + return library.j; }); diff --git a/test/expected/build/library.j/dest/resources/library/j/some.js b/test/expected/build/library.j/dest/resources/library/j/some.js index dad1fd304..68b2650ab 100644 --- a/test/expected/build/library.j/dest/resources/library/j/some.js +++ b/test/expected/build/library.j/dest/resources/library/j/some.js @@ -3,16 +3,13 @@ */ sap.ui.define([ "sap/ui/core/Control", - "./dependency", - "./dependency2", - "./dependency-es6-1", - "./dependency-es6-2", - "./dependency-es6-3" -], (Control, { MyValidEnum, ThisIsEnumToo: RenamedEnum }, library, es6_1, es6_2, es6_3) => { + "./library", + "./library-core" +], (Control, { MyValidEnum, ThisIsEnumToo: RenamedEnum }, library) => { const { AnotherValidEnum } = library; const { Buzz } = AnotherValidEnum; - const { AnotherValidEnum: Zzz } = library; + const { AnotherValidEnum: AnotherRenamedEnum } = library; const { H1 } = sap.ui.core.TitleLevel; const { Value2: RenamedValue2 } = RenamedEnum; @@ -26,11 +23,11 @@ sap.ui.define([ * @version ${version} * * @public - * @alias testlib.ValidPropertyDefaultValue + * @alias library.j.ValidPropertyDefaultValue * @ui5-metamodel text */ var ValidPropertyDefaultValue = Control.extend( - "testlib.ValidPropertyDefaultValue", + "library.j.ValidPropertyDefaultValue", { metadata: { properties: { @@ -38,7 +35,7 @@ sap.ui.define([ * validPropertyDefaultValueEnumSimpleDestructuring */ validPropertyDefaultValueEnumSimpleDestructuring: { - type: "testlib.AnotherValidEnum", + type: "library.j.core.AnotherValidEnum", group: "Misc", defaultValue: AnotherValidEnum.Buzz, }, @@ -47,7 +44,7 @@ sap.ui.define([ * validPropertyDefaultValueEnumChainedDestructuring */ validPropertyDefaultValueEnumChainedDestructuring: { - type: "testlib.AnotherValidEnum", + type: "library.j.core.AnotherValidEnum", group: "Misc", defaultValue: Buzz, }, @@ -56,16 +53,16 @@ sap.ui.define([ * validPropertyDefaultValueEnumDestructuringWithRename */ validPropertyDefaultValueEnumDestructuringWithRename: { - type: "testlib.AnotherValidEnum", + type: "library.j.core.AnotherValidEnum", group: "Misc", - defaultValue: Zzz.Fizz, + defaultValue: AnotherRenamedEnum.Fizz, }, /** * validPropertyDefaultValueEnumDestructuringWithRenameInArguments */ validPropertyDefaultValueEnumDestructuringWithRenameInArguments: { - type: "testlib.ThisIsEnumToo", + type: "library.j.ThisIsEnumToo", group: "Misc", defaultValue: RenamedEnum.Value1, }, @@ -74,7 +71,7 @@ sap.ui.define([ * validPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar */ validPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar: { - type: "testlib.ThisIsEnumToo", + type: "library.j.ThisIsEnumToo", group: "Misc", defaultValue: RenamedValue2, }, @@ -83,7 +80,7 @@ sap.ui.define([ * validPropertyDefaultValueEnumViaDestructuringInArrowFn */ validPropertyDefaultValueEnumViaDestructuringInArrowFn: { - type: "testlib.MyValidEnum", + type: "library.j.MyValidEnum", group: "Misc", defaultValue: MyValidEnum.Foo, }, diff --git a/test/lib/builder/builder.js b/test/lib/builder/builder.js index 408707ff9..d4395fa99 100644 --- a/test/lib/builder/builder.js +++ b/test/lib/builder/builder.js @@ -880,7 +880,7 @@ test.serial("Build library.i with manifest info taken from .library and library. t.pass(); }); -test.serial("Build library.j with JSDoc build only", async (t) => { +test.only("Build library.j with JSDoc build only", async (t) => { const destPath = path.join("test", "tmp", "build", "library.j", "dest"); const expectedPath = path.join("test", "expected", "build", "library.j", "dest"); From 7af32020ebcf493b7942e3958fbe357324025a4a Mon Sep 17 00:00:00 2001 From: Yavor Ivanov Date: Thu, 29 Sep 2022 16:32:31 +0300 Subject: [PATCH 35/69] Modify tests to fit more likely on the real world scenarios --- ...{dependency-es6-1.js => ES6.features.1.js} | 0 ...{dependency-es6-2.js => ES6.features.2.js} | 13 +- ...{dependency-es6-3.js => ES6.features.3.js} | 0 .../dest/resources/library/j/library-core.js | 2 +- .../dest/resources/library/j/library.js | 4 +- .../dest/resources/library/j/some.js | 6 +- .../library/j/designtime/api.json | 219 +++++++++--------- ...{dependency-es6-1.js => ES6.features.1.js} | 0 ...{dependency-es6-2.js => ES6.features.2.js} | 13 +- ...{dependency-es6-3.js => ES6.features.3.js} | 0 .../j/{dependency2.js => library-core.js} | 12 +- .../library/j/{dependency.js => library.js} | 16 +- .../library.j/main/src/library/j/some.js | 31 ++- test/lib/builder/builder.js | 6 +- 14 files changed, 157 insertions(+), 165 deletions(-) rename test/expected/build/library.j/dest/resources/library/j/{dependency-es6-1.js => ES6.features.1.js} (100%) rename test/expected/build/library.j/dest/resources/library/j/{dependency-es6-2.js => ES6.features.2.js} (72%) rename test/expected/build/library.j/dest/resources/library/j/{dependency-es6-3.js => ES6.features.3.js} (100%) rename test/fixtures/library.j/main/src/library/j/{dependency-es6-1.js => ES6.features.1.js} (100%) rename test/fixtures/library.j/main/src/library/j/{dependency-es6-2.js => ES6.features.2.js} (72%) rename test/fixtures/library.j/main/src/library/j/{dependency-es6-3.js => ES6.features.3.js} (100%) rename test/fixtures/library.j/main/src/library/j/{dependency2.js => library-core.js} (67%) rename test/fixtures/library.j/main/src/library/j/{dependency.js => library.js} (73%) diff --git a/test/expected/build/library.j/dest/resources/library/j/dependency-es6-1.js b/test/expected/build/library.j/dest/resources/library/j/ES6.features.1.js similarity index 100% rename from test/expected/build/library.j/dest/resources/library/j/dependency-es6-1.js rename to test/expected/build/library.j/dest/resources/library/j/ES6.features.1.js diff --git a/test/expected/build/library.j/dest/resources/library/j/dependency-es6-2.js b/test/expected/build/library.j/dest/resources/library/j/ES6.features.2.js similarity index 72% rename from test/expected/build/library.j/dest/resources/library/j/dependency-es6-2.js rename to test/expected/build/library.j/dest/resources/library/j/ES6.features.2.js index 541fe9b5f..b3fcef68d 100644 --- a/test/expected/build/library.j/dest/resources/library/j/dependency-es6-2.js +++ b/test/expected/build/library.j/dest/resources/library/j/ES6.features.2.js @@ -8,9 +8,9 @@ */ window.someRandomModule || sap.ui.define( - ["./a"], + ["./Control"], /** - * Constructor for a new library.j.aaa. + * Constructor for a new library.j.SubControl. * * @param {string} [sId] ID for the new control, generated automatically if no ID is given * @param {object} [mSettings] Initial settings for the new control @@ -21,14 +21,13 @@ window.someRandomModule || * @version ${version} * * @constructor - * @extends library.j.a + * @extends library.j.Control * @public * @since 1.22 - * @alias library.j.aaa - * @ui5-metamodel This control will also be described in the UI5 (legacy) design time meta model. + * @alias library.j.SubControl */ - (a) => - a.extend(`library.j.aaa`, { + (Control) => + Control.extend(`library.j.SubControl`, { metadata: { properties: { /** diff --git a/test/expected/build/library.j/dest/resources/library/j/dependency-es6-3.js b/test/expected/build/library.j/dest/resources/library/j/ES6.features.3.js similarity index 100% rename from test/expected/build/library.j/dest/resources/library/j/dependency-es6-3.js rename to test/expected/build/library.j/dest/resources/library/j/ES6.features.3.js diff --git a/test/expected/build/library.j/dest/resources/library/j/library-core.js b/test/expected/build/library.j/dest/resources/library/j/library-core.js index 18ce26a63..ba22deece 100644 --- a/test/expected/build/library.j/dest/resources/library/j/library-core.js +++ b/test/expected/build/library.j/dest/resources/library/j/library-core.js @@ -24,7 +24,7 @@ sap.ui.define([], function () { */ Fizz: "Fizz", /** - * Bar + * Buzz * @public */ Buzz: "Buzz", diff --git a/test/expected/build/library.j/dest/resources/library/j/library.js b/test/expected/build/library.j/dest/resources/library/j/library.js index 3808348b2..5ec0cefd7 100644 --- a/test/expected/build/library.j/dest/resources/library/j/library.js +++ b/test/expected/build/library.j/dest/resources/library/j/library.js @@ -38,12 +38,12 @@ sap.ui.define([], function () { */ library.j.ThisIsEnumToo = { /** - * Foo + * Value1 * @public */ Value1: "Value1", /** - * Bar + * Value2 * @public */ Value2: "Value2", diff --git a/test/expected/build/library.j/dest/resources/library/j/some.js b/test/expected/build/library.j/dest/resources/library/j/some.js index 68b2650ab..89f3bd311 100644 --- a/test/expected/build/library.j/dest/resources/library/j/some.js +++ b/test/expected/build/library.j/dest/resources/library/j/some.js @@ -5,11 +5,11 @@ sap.ui.define([ "sap/ui/core/Control", "./library", "./library-core" -], (Control, { MyValidEnum, ThisIsEnumToo: RenamedEnum }, library) => { +], (Control, { MyValidEnum, ThisIsEnumToo: RenamedEnum }, coreLibrary) => { - const { AnotherValidEnum } = library; + const { AnotherValidEnum } = coreLibrary; const { Buzz } = AnotherValidEnum; - const { AnotherValidEnum: AnotherRenamedEnum } = library; + const { AnotherValidEnum: AnotherRenamedEnum } = coreLibrary; const { H1 } = sap.ui.core.TitleLevel; const { Value2: RenamedValue2 } = RenamedEnum; diff --git a/test/expected/build/library.j/dest/test-resources/library/j/designtime/api.json b/test/expected/build/library.j/dest/test-resources/library/j/designtime/api.json index 826393e0f..d881f3658 100644 --- a/test/expected/build/library.j/dest/test-resources/library/j/designtime/api.json +++ b/test/expected/build/library.j/dest/test-resources/library/j/designtime/api.json @@ -3,18 +3,92 @@ "version": "1.0.0", "library": "library.j", "symbols": [ + { + "kind": "enum", + "name": "library.j.core.AnotherValidEnum", + "basename": "AnotherValidEnum", + "resource": "library/j/library-core.js", + "module": "library/j/library-core", + "static": true, + "visibility": "public", + "description": "AnotherValidEnum", + "ui5-metamodel": true, + "ui5-metadata": { + "stereotype": "enum" + }, + "properties": [ + { + "name": "Buzz", + "visibility": "public", + "static": true, + "type": "string", + "description": "Buzz" + }, + { + "name": "Fizz", + "visibility": "public", + "static": true, + "type": "string", + "description": "Fizz" + } + ] + }, { "kind": "class", - "name": "library.j.aaa", - "basename": "aaa", - "resource": "library/j/dependency-es6-2.js", - "module": "library/j/dependency-es6-2", + "name": "library.j.Foo", + "basename": "Foo", + "resource": "library/j/ES6.features.1.js", + "module": "library/j/ES6.features.1", + "static": true, + "visibility": "public", + "extends": "library.j.Bar", + "description": "My super documentation of this class", + "constructor": { + "visibility": "public" + } + }, + { + "kind": "enum", + "name": "library.j.MyValidEnum", + "basename": "MyValidEnum", + "resource": "library/j/library.js", + "module": "library/j/library", + "export": "MyValidEnum", + "static": true, + "visibility": "public", + "description": "MyValidEnum", + "ui5-metamodel": true, + "ui5-metadata": { + "stereotype": "enum" + }, + "properties": [ + { + "name": "Bar", + "visibility": "public", + "static": true, + "type": "string", + "description": "Bar" + }, + { + "name": "Foo", + "visibility": "public", + "static": true, + "type": "string", + "description": "Foo" + } + ] + }, + { + "kind": "class", + "name": "library.j.SubControl", + "basename": "SubControl", + "resource": "library/j/ES6.features.2.js", + "module": "library/j/ES6.features.2", "export": "", "static": true, "visibility": "public", "since": "1.22", - "extends": "library.j.a", - "ui5-metamodel": true, + "extends": "library.j.Control", "ui5-metadata": { "properties": [ { @@ -48,7 +122,7 @@ "description": "Initial settings for the new control" } ], - "description": "Constructor for a new library.j.aaa." + "description": "Constructor for a new library.j.SubControl." }, "methods": [ { @@ -79,7 +153,7 @@ "description": "Constructor function for the metadata object; if not given, it defaults to the metadata implementation used by this class" } ], - "description": "Creates a new subclass of class library.j.aaa with name sClassName and enriches it with the information contained in oClassInfo.\n\noClassInfo might contain the same kind of information as described in {@link library.j.a.extend}." + "description": "Creates a new subclass of class library.j.SubControl with name sClassName and enriches it with the information contained in oClassInfo.\n\noClassInfo might contain the same kind of information as described in {@link library.j.Control.extend}." }, { "name": "getMetadata", @@ -89,7 +163,7 @@ "type": "sap.ui.base.Metadata", "description": "Metadata object describing this class" }, - "description": "Returns a metadata object for class library.j.aaa." + "description": "Returns a metadata object for class library.j.SubControl." }, { "name": "getMyProp", @@ -122,86 +196,13 @@ } ] }, - { - "kind": "class", - "name": "library.j.Foo", - "basename": "Foo", - "resource": "library/j/dependency-es6-1.js", - "module": "library/j/dependency-es6-1", - "static": true, - "visibility": "public", - "extends": "library.j.Bar", - "description": "My super documentation of this class", - "constructor": { - "visibility": "public" - } - }, - { - "kind": "enum", - "name": "testlib.AnotherValidEnum", - "basename": "AnotherValidEnum", - "resource": "library/j/dependency2.js", - "module": "library/j/dependency2", - "static": true, - "visibility": "public", - "description": "AnotherValidEnum", - "ui5-metamodel": true, - "ui5-metadata": { - "stereotype": "enum" - }, - "properties": [ - { - "name": "Buzz", - "visibility": "public", - "static": true, - "type": "string", - "description": "Bar" - }, - { - "name": "Fizz", - "visibility": "public", - "static": true, - "type": "string", - "description": "Fizz" - } - ] - }, { "kind": "enum", - "name": "testlib.MyValidEnum", - "basename": "MyValidEnum", - "resource": "library/j/dependency.js", - "module": "library/j/dependency", - "static": true, - "visibility": "public", - "description": "MyValidEnum", - "ui5-metamodel": true, - "ui5-metadata": { - "stereotype": "enum" - }, - "properties": [ - { - "name": "Bar", - "visibility": "public", - "static": true, - "type": "string", - "description": "Bar" - }, - { - "name": "Foo", - "visibility": "public", - "static": true, - "type": "string", - "description": "Foo" - } - ] - }, - { - "kind": "enum", - "name": "testlib.ThisIsEnumToo", + "name": "library.j.ThisIsEnumToo", "basename": "ThisIsEnumToo", - "resource": "library/j/dependency.js", - "module": "library/j/dependency", + "resource": "library/j/library.js", + "module": "library/j/library", + "export": "ThisIsEnumToo", "static": true, "visibility": "public", "description": "ThisIsEnumToo", @@ -214,20 +215,20 @@ "visibility": "public", "static": true, "type": "string", - "description": "Foo" + "description": "Value1" }, { "name": "Value2", "visibility": "public", "static": true, "type": "string", - "description": "Bar" + "description": "Value2" } ] }, { "kind": "class", - "name": "testlib.ValidPropertyDefaultValue", + "name": "library.j.ValidPropertyDefaultValue", "basename": "ValidPropertyDefaultValue", "resource": "library/j/some.js", "module": "library/j/some", @@ -242,7 +243,7 @@ "properties": [ { "name": "validPropertyDefaultValueEnumSimpleDestructuring", - "type": "testlib.AnotherValidEnum", + "type": "library.j.core.AnotherValidEnum", "defaultValue": "Buzz", "group": "Misc", "visibility": "public", @@ -254,7 +255,7 @@ }, { "name": "validPropertyDefaultValueEnumChainedDestructuring", - "type": "testlib.AnotherValidEnum", + "type": "library.j.core.AnotherValidEnum", "defaultValue": "Buzz", "group": "Misc", "visibility": "public", @@ -266,7 +267,7 @@ }, { "name": "validPropertyDefaultValueEnumDestructuringWithRename", - "type": "testlib.AnotherValidEnum", + "type": "library.j.core.AnotherValidEnum", "defaultValue": "Fizz", "group": "Misc", "visibility": "public", @@ -278,7 +279,7 @@ }, { "name": "validPropertyDefaultValueEnumDestructuringWithRenameInArguments", - "type": "testlib.ThisIsEnumToo", + "type": "library.j.ThisIsEnumToo", "defaultValue": "Value1", "group": "Misc", "visibility": "public", @@ -290,7 +291,7 @@ }, { "name": "validPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar", - "type": "testlib.ThisIsEnumToo", + "type": "library.j.ThisIsEnumToo", "defaultValue": "Value2", "group": "Misc", "visibility": "public", @@ -302,7 +303,7 @@ }, { "name": "validPropertyDefaultValueEnumViaDestructuringInArrowFn", - "type": "testlib.MyValidEnum", + "type": "library.j.MyValidEnum", "defaultValue": "Foo", "group": "Misc", "visibility": "public", @@ -359,7 +360,7 @@ "description": "Constructor function for the metadata object; if not given, it defaults to the metadata implementation used by this class" } ], - "description": "Creates a new subclass of class testlib.ValidPropertyDefaultValue with name sClassName and enriches it with the information contained in oClassInfo.\n\noClassInfo might contain the same kind of information as described in {@link sap.ui.core.Control.extend}." + "description": "Creates a new subclass of class library.j.ValidPropertyDefaultValue with name sClassName and enriches it with the information contained in oClassInfo.\n\noClassInfo might contain the same kind of information as described in {@link sap.ui.core.Control.extend}." }, { "name": "getMetadata", @@ -369,13 +370,13 @@ "type": "sap.ui.base.Metadata", "description": "Metadata object describing this class" }, - "description": "Returns a metadata object for class testlib.ValidPropertyDefaultValue." + "description": "Returns a metadata object for class library.j.ValidPropertyDefaultValue." }, { "name": "getValidPropertyDefaultValueEnumChainedDestructuring", "visibility": "public", "returnValue": { - "type": "testlib.AnotherValidEnum", + "type": "library.j.core.AnotherValidEnum", "description": "Value of property validPropertyDefaultValueEnumChainedDestructuring" }, "description": "Gets current value of property {@link #getValidPropertyDefaultValueEnumChainedDestructuring validPropertyDefaultValueEnumChainedDestructuring}.\n\nvalidPropertyDefaultValueEnumChainedDestructuring\n\nDefault value is Buzz." @@ -384,7 +385,7 @@ "name": "getValidPropertyDefaultValueEnumDestructuringWithRename", "visibility": "public", "returnValue": { - "type": "testlib.AnotherValidEnum", + "type": "library.j.core.AnotherValidEnum", "description": "Value of property validPropertyDefaultValueEnumDestructuringWithRename" }, "description": "Gets current value of property {@link #getValidPropertyDefaultValueEnumDestructuringWithRename validPropertyDefaultValueEnumDestructuringWithRename}.\n\nvalidPropertyDefaultValueEnumDestructuringWithRename\n\nDefault value is Fizz." @@ -393,7 +394,7 @@ "name": "getValidPropertyDefaultValueEnumDestructuringWithRenameInArguments", "visibility": "public", "returnValue": { - "type": "testlib.ThisIsEnumToo", + "type": "library.j.ThisIsEnumToo", "description": "Value of property validPropertyDefaultValueEnumDestructuringWithRenameInArguments" }, "description": "Gets current value of property {@link #getValidPropertyDefaultValueEnumDestructuringWithRenameInArguments validPropertyDefaultValueEnumDestructuringWithRenameInArguments}.\n\nvalidPropertyDefaultValueEnumDestructuringWithRenameInArguments\n\nDefault value is Value1." @@ -402,7 +403,7 @@ "name": "getValidPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar", "visibility": "public", "returnValue": { - "type": "testlib.ThisIsEnumToo", + "type": "library.j.ThisIsEnumToo", "description": "Value of property validPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar" }, "description": "Gets current value of property {@link #getValidPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar validPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar}.\n\nvalidPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar\n\nDefault value is Value2." @@ -411,7 +412,7 @@ "name": "getValidPropertyDefaultValueEnumSimpleDestructuring", "visibility": "public", "returnValue": { - "type": "testlib.AnotherValidEnum", + "type": "library.j.core.AnotherValidEnum", "description": "Value of property validPropertyDefaultValueEnumSimpleDestructuring" }, "description": "Gets current value of property {@link #getValidPropertyDefaultValueEnumSimpleDestructuring validPropertyDefaultValueEnumSimpleDestructuring}.\n\nvalidPropertyDefaultValueEnumSimpleDestructuring\n\nDefault value is Buzz." @@ -429,7 +430,7 @@ "name": "getValidPropertyDefaultValueEnumViaDestructuringInArrowFn", "visibility": "public", "returnValue": { - "type": "testlib.MyValidEnum", + "type": "library.j.MyValidEnum", "description": "Value of property validPropertyDefaultValueEnumViaDestructuringInArrowFn" }, "description": "Gets current value of property {@link #getValidPropertyDefaultValueEnumViaDestructuringInArrowFn validPropertyDefaultValueEnumViaDestructuringInArrowFn}.\n\nvalidPropertyDefaultValueEnumViaDestructuringInArrowFn\n\nDefault value is Foo." @@ -444,7 +445,7 @@ "parameters": [ { "name": "sValidPropertyDefaultValueEnumChainedDestructuring", - "type": "testlib.AnotherValidEnum", + "type": "library.j.core.AnotherValidEnum", "optional": true, "defaultValue": "Buzz", "description": "New value for property validPropertyDefaultValueEnumChainedDestructuring" @@ -462,7 +463,7 @@ "parameters": [ { "name": "sValidPropertyDefaultValueEnumDestructuringWithRename", - "type": "testlib.AnotherValidEnum", + "type": "library.j.core.AnotherValidEnum", "optional": true, "defaultValue": "Fizz", "description": "New value for property validPropertyDefaultValueEnumDestructuringWithRename" @@ -480,7 +481,7 @@ "parameters": [ { "name": "sValidPropertyDefaultValueEnumDestructuringWithRenameInArguments", - "type": "testlib.ThisIsEnumToo", + "type": "library.j.ThisIsEnumToo", "optional": true, "defaultValue": "Value1", "description": "New value for property validPropertyDefaultValueEnumDestructuringWithRenameInArguments" @@ -498,7 +499,7 @@ "parameters": [ { "name": "sValidPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar", - "type": "testlib.ThisIsEnumToo", + "type": "library.j.ThisIsEnumToo", "optional": true, "defaultValue": "Value2", "description": "New value for property validPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar" @@ -516,7 +517,7 @@ "parameters": [ { "name": "sValidPropertyDefaultValueEnumSimpleDestructuring", - "type": "testlib.AnotherValidEnum", + "type": "library.j.core.AnotherValidEnum", "optional": true, "defaultValue": "Buzz", "description": "New value for property validPropertyDefaultValueEnumSimpleDestructuring" @@ -552,7 +553,7 @@ "parameters": [ { "name": "sValidPropertyDefaultValueEnumViaDestructuringInArrowFn", - "type": "testlib.MyValidEnum", + "type": "library.j.MyValidEnum", "optional": true, "defaultValue": "Foo", "description": "New value for property validPropertyDefaultValueEnumViaDestructuringInArrowFn" diff --git a/test/fixtures/library.j/main/src/library/j/dependency-es6-1.js b/test/fixtures/library.j/main/src/library/j/ES6.features.1.js similarity index 100% rename from test/fixtures/library.j/main/src/library/j/dependency-es6-1.js rename to test/fixtures/library.j/main/src/library/j/ES6.features.1.js diff --git a/test/fixtures/library.j/main/src/library/j/dependency-es6-2.js b/test/fixtures/library.j/main/src/library/j/ES6.features.2.js similarity index 72% rename from test/fixtures/library.j/main/src/library/j/dependency-es6-2.js rename to test/fixtures/library.j/main/src/library/j/ES6.features.2.js index 541fe9b5f..b3fcef68d 100644 --- a/test/fixtures/library.j/main/src/library/j/dependency-es6-2.js +++ b/test/fixtures/library.j/main/src/library/j/ES6.features.2.js @@ -8,9 +8,9 @@ */ window.someRandomModule || sap.ui.define( - ["./a"], + ["./Control"], /** - * Constructor for a new library.j.aaa. + * Constructor for a new library.j.SubControl. * * @param {string} [sId] ID for the new control, generated automatically if no ID is given * @param {object} [mSettings] Initial settings for the new control @@ -21,14 +21,13 @@ window.someRandomModule || * @version ${version} * * @constructor - * @extends library.j.a + * @extends library.j.Control * @public * @since 1.22 - * @alias library.j.aaa - * @ui5-metamodel This control will also be described in the UI5 (legacy) design time meta model. + * @alias library.j.SubControl */ - (a) => - a.extend(`library.j.aaa`, { + (Control) => + Control.extend(`library.j.SubControl`, { metadata: { properties: { /** diff --git a/test/fixtures/library.j/main/src/library/j/dependency-es6-3.js b/test/fixtures/library.j/main/src/library/j/ES6.features.3.js similarity index 100% rename from test/fixtures/library.j/main/src/library/j/dependency-es6-3.js rename to test/fixtures/library.j/main/src/library/j/ES6.features.3.js diff --git a/test/fixtures/library.j/main/src/library/j/dependency2.js b/test/fixtures/library.j/main/src/library/j/library-core.js similarity index 67% rename from test/fixtures/library.j/main/src/library/j/dependency2.js rename to test/fixtures/library.j/main/src/library/j/library-core.js index aff06f291..ba22deece 100644 --- a/test/fixtures/library.j/main/src/library/j/dependency2.js +++ b/test/fixtures/library.j/main/src/library/j/library-core.js @@ -3,11 +3,11 @@ */ sap.ui.define([], function () { sap.ui.getCore().initLibrary({ - name: "testlib", + name: "library.j.core", version: "${version}", dependencies: ["sap.ui.core"], - designtime: "testlib/designtime/library.designtime", - types: ["testlib.AnotherValidEnum"], + designtime: "library/j/core/designtime/library.designtime", + types: ["library.j.core.AnotherValidEnum"], }); /** @@ -17,18 +17,18 @@ sap.ui.define([], function () { * @public * @ui5-metamodel This enumeration also will be described in the UI5 (legacy) designtime metamodel */ - testlib.AnotherValidEnum = { + library.j.core.AnotherValidEnum = { /** * Fizz * @public */ Fizz: "Fizz", /** - * Bar + * Buzz * @public */ Buzz: "Buzz", }; - return testlib; + return library.j.core; }); diff --git a/test/fixtures/library.j/main/src/library/j/dependency.js b/test/fixtures/library.j/main/src/library/j/library.js similarity index 73% rename from test/fixtures/library.j/main/src/library/j/dependency.js rename to test/fixtures/library.j/main/src/library/j/library.js index ba161f274..5ec0cefd7 100644 --- a/test/fixtures/library.j/main/src/library/j/dependency.js +++ b/test/fixtures/library.j/main/src/library/j/library.js @@ -3,11 +3,11 @@ */ sap.ui.define([], function () { sap.ui.getCore().initLibrary({ - name: "testlib", + name: "library.j", version: "${version}", dependencies: ["sap.ui.core"], - designtime: "testlib/designtime/library.designtime", - types: ["testlib.MyValidEnum"], + designtime: "library.j/designtime/library.designtime", + types: ["library.j.MyValidEnum"], }); /** @@ -17,7 +17,7 @@ sap.ui.define([], function () { * @public * @ui5-metamodel This enumeration also will be described in the UI5 (legacy) designtime metamodel */ - testlib.MyValidEnum = { + library.j.MyValidEnum = { /** * Foo * @public @@ -36,18 +36,18 @@ sap.ui.define([], function () { * @enum {string} * @public */ - testlib.ThisIsEnumToo = { + library.j.ThisIsEnumToo = { /** - * Foo + * Value1 * @public */ Value1: "Value1", /** - * Bar + * Value2 * @public */ Value2: "Value2", }; - return testlib; + return library.j; }); diff --git a/test/fixtures/library.j/main/src/library/j/some.js b/test/fixtures/library.j/main/src/library/j/some.js index dad1fd304..89f3bd311 100644 --- a/test/fixtures/library.j/main/src/library/j/some.js +++ b/test/fixtures/library.j/main/src/library/j/some.js @@ -3,16 +3,13 @@ */ sap.ui.define([ "sap/ui/core/Control", - "./dependency", - "./dependency2", - "./dependency-es6-1", - "./dependency-es6-2", - "./dependency-es6-3" -], (Control, { MyValidEnum, ThisIsEnumToo: RenamedEnum }, library, es6_1, es6_2, es6_3) => { + "./library", + "./library-core" +], (Control, { MyValidEnum, ThisIsEnumToo: RenamedEnum }, coreLibrary) => { - const { AnotherValidEnum } = library; + const { AnotherValidEnum } = coreLibrary; const { Buzz } = AnotherValidEnum; - const { AnotherValidEnum: Zzz } = library; + const { AnotherValidEnum: AnotherRenamedEnum } = coreLibrary; const { H1 } = sap.ui.core.TitleLevel; const { Value2: RenamedValue2 } = RenamedEnum; @@ -26,11 +23,11 @@ sap.ui.define([ * @version ${version} * * @public - * @alias testlib.ValidPropertyDefaultValue + * @alias library.j.ValidPropertyDefaultValue * @ui5-metamodel text */ var ValidPropertyDefaultValue = Control.extend( - "testlib.ValidPropertyDefaultValue", + "library.j.ValidPropertyDefaultValue", { metadata: { properties: { @@ -38,7 +35,7 @@ sap.ui.define([ * validPropertyDefaultValueEnumSimpleDestructuring */ validPropertyDefaultValueEnumSimpleDestructuring: { - type: "testlib.AnotherValidEnum", + type: "library.j.core.AnotherValidEnum", group: "Misc", defaultValue: AnotherValidEnum.Buzz, }, @@ -47,7 +44,7 @@ sap.ui.define([ * validPropertyDefaultValueEnumChainedDestructuring */ validPropertyDefaultValueEnumChainedDestructuring: { - type: "testlib.AnotherValidEnum", + type: "library.j.core.AnotherValidEnum", group: "Misc", defaultValue: Buzz, }, @@ -56,16 +53,16 @@ sap.ui.define([ * validPropertyDefaultValueEnumDestructuringWithRename */ validPropertyDefaultValueEnumDestructuringWithRename: { - type: "testlib.AnotherValidEnum", + type: "library.j.core.AnotherValidEnum", group: "Misc", - defaultValue: Zzz.Fizz, + defaultValue: AnotherRenamedEnum.Fizz, }, /** * validPropertyDefaultValueEnumDestructuringWithRenameInArguments */ validPropertyDefaultValueEnumDestructuringWithRenameInArguments: { - type: "testlib.ThisIsEnumToo", + type: "library.j.ThisIsEnumToo", group: "Misc", defaultValue: RenamedEnum.Value1, }, @@ -74,7 +71,7 @@ sap.ui.define([ * validPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar */ validPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar: { - type: "testlib.ThisIsEnumToo", + type: "library.j.ThisIsEnumToo", group: "Misc", defaultValue: RenamedValue2, }, @@ -83,7 +80,7 @@ sap.ui.define([ * validPropertyDefaultValueEnumViaDestructuringInArrowFn */ validPropertyDefaultValueEnumViaDestructuringInArrowFn: { - type: "testlib.MyValidEnum", + type: "library.j.MyValidEnum", group: "Misc", defaultValue: MyValidEnum.Foo, }, diff --git a/test/lib/builder/builder.js b/test/lib/builder/builder.js index d4395fa99..da01e9586 100644 --- a/test/lib/builder/builder.js +++ b/test/lib/builder/builder.js @@ -880,7 +880,7 @@ test.serial("Build library.i with manifest info taken from .library and library. t.pass(); }); -test.only("Build library.j with JSDoc build only", async (t) => { +test.serial("Build library.j with JSDoc build only", async (t) => { const destPath = path.join("test", "tmp", "build", "library.j", "dest"); const expectedPath = path.join("test", "expected", "build", "library.j", "dest"); @@ -894,10 +894,6 @@ test.only("Build library.j with JSDoc build only", async (t) => { excludedTasks: ["*"] }); - // // Beautify api.json, so that it can be better read and compared - const apiJsonPath = path.join(destPath, "test-resources", "library", "j", "designtime", "api.json"); - fs.writeFileSync(apiJsonPath, JSON.stringify(JSON.parse(fs.readFileSync(apiJsonPath, "utf-8")), null, "\t")); - const expectedFiles = await findFiles(expectedPath); // Check for all directories and files directoryDeepEqual(t, destPath, expectedPath); From c861fcf5bb3b5feaf6db79dd5d93a9188e8d5839 Mon Sep 17 00:00:00 2001 From: Yavor Ivanov Date: Fri, 30 Sep 2022 09:05:30 +0300 Subject: [PATCH 36/69] Beautify api.json --- test/lib/builder/builder.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/lib/builder/builder.js b/test/lib/builder/builder.js index da01e9586..408707ff9 100644 --- a/test/lib/builder/builder.js +++ b/test/lib/builder/builder.js @@ -894,6 +894,10 @@ test.serial("Build library.j with JSDoc build only", async (t) => { excludedTasks: ["*"] }); + // // Beautify api.json, so that it can be better read and compared + const apiJsonPath = path.join(destPath, "test-resources", "library", "j", "designtime", "api.json"); + fs.writeFileSync(apiJsonPath, JSON.stringify(JSON.parse(fs.readFileSync(apiJsonPath, "utf-8")), null, "\t")); + const expectedFiles = await findFiles(expectedPath); // Check for all directories and files directoryDeepEqual(t, destPath, expectedPath); From b6c3f96ebe50dcb6349165a49521a8b24224beb9 Mon Sep 17 00:00:00 2001 From: Yavor Ivanov Date: Mon, 3 Oct 2022 09:59:14 +0300 Subject: [PATCH 37/69] Make tests more production like --- .../resources/library/j/ES6.features.2.js | 45 ------------------- .../library/j/{ES6.features.1.js => Foo.js} | 0 .../dest/resources/library/j/SubControl.js | 45 +++++++++++++++++++ .../{some.js => ValidPropertyDefaultValue.js} | 23 +++++----- .../j/{library-core.js => core/library.js} | 0 .../dest/resources/library/j/library.js | 2 +- .../j/{ES6.features.3.js => someGenerator.js} | 0 .../library/j/designtime/api.json | 23 +++++----- .../main/src/library/j/ES6.features.2.js | 45 ------------------- .../library/j/{ES6.features.1.js => Foo.js} | 0 .../main/src/library/j/SubControl.js | 45 +++++++++++++++++++ .../{some.js => ValidPropertyDefaultValue.js} | 23 +++++----- .../j/{library-core.js => core/library.js} | 0 .../library.j/main/src/library/j/library.js | 2 +- .../j/{ES6.features.3.js => someGenerator.js} | 0 15 files changed, 129 insertions(+), 124 deletions(-) delete mode 100644 test/expected/build/library.j/dest/resources/library/j/ES6.features.2.js rename test/expected/build/library.j/dest/resources/library/j/{ES6.features.1.js => Foo.js} (100%) create mode 100644 test/expected/build/library.j/dest/resources/library/j/SubControl.js rename test/expected/build/library.j/dest/resources/library/j/{some.js => ValidPropertyDefaultValue.js} (90%) rename test/expected/build/library.j/dest/resources/library/j/{library-core.js => core/library.js} (100%) rename test/expected/build/library.j/dest/resources/library/j/{ES6.features.3.js => someGenerator.js} (100%) delete mode 100644 test/fixtures/library.j/main/src/library/j/ES6.features.2.js rename test/fixtures/library.j/main/src/library/j/{ES6.features.1.js => Foo.js} (100%) create mode 100644 test/fixtures/library.j/main/src/library/j/SubControl.js rename test/fixtures/library.j/main/src/library/j/{some.js => ValidPropertyDefaultValue.js} (90%) rename test/fixtures/library.j/main/src/library/j/{library-core.js => core/library.js} (100%) rename test/fixtures/library.j/main/src/library/j/{ES6.features.3.js => someGenerator.js} (100%) diff --git a/test/expected/build/library.j/dest/resources/library/j/ES6.features.2.js b/test/expected/build/library.j/dest/resources/library/j/ES6.features.2.js deleted file mode 100644 index b3fcef68d..000000000 --- a/test/expected/build/library.j/dest/resources/library/j/ES6.features.2.js +++ /dev/null @@ -1,45 +0,0 @@ -/*! - * ${copyright} - */ - -/** - * Covers: - * - ArrowFunctionExpression - */ -window.someRandomModule || - sap.ui.define( - ["./Control"], - /** - * Constructor for a new library.j.SubControl. - * - * @param {string} [sId] ID for the new control, generated automatically if no ID is given - * @param {object} [mSettings] Initial settings for the new control - * - * @class - * - * @author SAP SE - * @version ${version} - * - * @constructor - * @extends library.j.Control - * @public - * @since 1.22 - * @alias library.j.SubControl - */ - (Control) => - Control.extend(`library.j.SubControl`, { - metadata: { - properties: { - /** - * MyProp property - * @since 1.46 - */ - MyProp: { - type: "boolean", - group: `Misc`, - defaultValue: false, - }, - }, - }, - }) - ); diff --git a/test/expected/build/library.j/dest/resources/library/j/ES6.features.1.js b/test/expected/build/library.j/dest/resources/library/j/Foo.js similarity index 100% rename from test/expected/build/library.j/dest/resources/library/j/ES6.features.1.js rename to test/expected/build/library.j/dest/resources/library/j/Foo.js diff --git a/test/expected/build/library.j/dest/resources/library/j/SubControl.js b/test/expected/build/library.j/dest/resources/library/j/SubControl.js new file mode 100644 index 000000000..283fcaf16 --- /dev/null +++ b/test/expected/build/library.j/dest/resources/library/j/SubControl.js @@ -0,0 +1,45 @@ +/*! + * ${copyright} + */ + +/** + * Covers: + * - ArrowFunctionExpression + */ + window.someRandomModule || + sap.ui.define( + ["sap/ui/core/Control"], + /** + * Constructor for a new library.j.SubControl. + * + * @param {string} [sId] ID for the new control, generated automatically if no ID is given + * @param {object} [mSettings] Initial settings for the new control + * + * @class + * + * @author SAP SE + * @version ${version} + * + * @constructor + * @extends sap.ui.core.Control + * @public + * @since 1.22 + * @alias library.j.SubControl + */ + (Control) => + Control.extend(`library.j.SubControl`, { + metadata: { + properties: { + /** + * MyProp property + * @since 1.46 + */ + MyProp: { + type: "boolean", + group: `Misc`, + defaultValue: false, + }, + }, + }, + }) + ); diff --git a/test/expected/build/library.j/dest/resources/library/j/some.js b/test/expected/build/library.j/dest/resources/library/j/ValidPropertyDefaultValue.js similarity index 90% rename from test/expected/build/library.j/dest/resources/library/j/some.js rename to test/expected/build/library.j/dest/resources/library/j/ValidPropertyDefaultValue.js index 89f3bd311..b50252983 100644 --- a/test/expected/build/library.j/dest/resources/library/j/some.js +++ b/test/expected/build/library.j/dest/resources/library/j/ValidPropertyDefaultValue.js @@ -6,7 +6,6 @@ sap.ui.define([ "./library", "./library-core" ], (Control, { MyValidEnum, ThisIsEnumToo: RenamedEnum }, coreLibrary) => { - const { AnotherValidEnum } = coreLibrary; const { Buzz } = AnotherValidEnum; const { AnotherValidEnum: AnotherRenamedEnum } = coreLibrary; @@ -61,20 +60,22 @@ sap.ui.define([ /** * validPropertyDefaultValueEnumDestructuringWithRenameInArguments */ - validPropertyDefaultValueEnumDestructuringWithRenameInArguments: { - type: "library.j.ThisIsEnumToo", - group: "Misc", - defaultValue: RenamedEnum.Value1, - }, + validPropertyDefaultValueEnumDestructuringWithRenameInArguments: + { + type: "library.j.ThisIsEnumToo", + group: "Misc", + defaultValue: RenamedEnum.Value1, + }, /** * validPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar */ - validPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar: { - type: "library.j.ThisIsEnumToo", - group: "Misc", - defaultValue: RenamedValue2, - }, + validPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar: + { + type: "library.j.ThisIsEnumToo", + group: "Misc", + defaultValue: RenamedValue2, + }, /** * validPropertyDefaultValueEnumViaDestructuringInArrowFn diff --git a/test/expected/build/library.j/dest/resources/library/j/library-core.js b/test/expected/build/library.j/dest/resources/library/j/core/library.js similarity index 100% rename from test/expected/build/library.j/dest/resources/library/j/library-core.js rename to test/expected/build/library.j/dest/resources/library/j/core/library.js diff --git a/test/expected/build/library.j/dest/resources/library/j/library.js b/test/expected/build/library.j/dest/resources/library/j/library.js index 5ec0cefd7..8a5d5343e 100644 --- a/test/expected/build/library.j/dest/resources/library/j/library.js +++ b/test/expected/build/library.j/dest/resources/library/j/library.js @@ -6,7 +6,7 @@ sap.ui.define([], function () { name: "library.j", version: "${version}", dependencies: ["sap.ui.core"], - designtime: "library.j/designtime/library.designtime", + designtime: "library/j/designtime/library.designtime", types: ["library.j.MyValidEnum"], }); diff --git a/test/expected/build/library.j/dest/resources/library/j/ES6.features.3.js b/test/expected/build/library.j/dest/resources/library/j/someGenerator.js similarity index 100% rename from test/expected/build/library.j/dest/resources/library/j/ES6.features.3.js rename to test/expected/build/library.j/dest/resources/library/j/someGenerator.js diff --git a/test/expected/build/library.j/dest/test-resources/library/j/designtime/api.json b/test/expected/build/library.j/dest/test-resources/library/j/designtime/api.json index d881f3658..181630a66 100644 --- a/test/expected/build/library.j/dest/test-resources/library/j/designtime/api.json +++ b/test/expected/build/library.j/dest/test-resources/library/j/designtime/api.json @@ -7,8 +7,9 @@ "kind": "enum", "name": "library.j.core.AnotherValidEnum", "basename": "AnotherValidEnum", - "resource": "library/j/library-core.js", - "module": "library/j/library-core", + "resource": "library/j/core/library.js", + "module": "library/j/core/library", + "export": "AnotherValidEnum", "static": true, "visibility": "public", "description": "AnotherValidEnum", @@ -37,8 +38,9 @@ "kind": "class", "name": "library.j.Foo", "basename": "Foo", - "resource": "library/j/ES6.features.1.js", - "module": "library/j/ES6.features.1", + "resource": "library/j/Foo.js", + "module": "library/j/Foo", + "export": "", "static": true, "visibility": "public", "extends": "library.j.Bar", @@ -82,14 +84,15 @@ "kind": "class", "name": "library.j.SubControl", "basename": "SubControl", - "resource": "library/j/ES6.features.2.js", - "module": "library/j/ES6.features.2", + "resource": "library/j/SubControl.js", + "module": "library/j/SubControl", "export": "", "static": true, "visibility": "public", "since": "1.22", - "extends": "library.j.Control", + "extends": "sap.ui.core.Control", "ui5-metadata": { + "stereotype": "control", "properties": [ { "name": "MyProp", @@ -153,7 +156,7 @@ "description": "Constructor function for the metadata object; if not given, it defaults to the metadata implementation used by this class" } ], - "description": "Creates a new subclass of class library.j.SubControl with name sClassName and enriches it with the information contained in oClassInfo.\n\noClassInfo might contain the same kind of information as described in {@link library.j.Control.extend}." + "description": "Creates a new subclass of class library.j.SubControl with name sClassName and enriches it with the information contained in oClassInfo.\n\noClassInfo might contain the same kind of information as described in {@link sap.ui.core.Control.extend}." }, { "name": "getMetadata", @@ -230,8 +233,8 @@ "kind": "class", "name": "library.j.ValidPropertyDefaultValue", "basename": "ValidPropertyDefaultValue", - "resource": "library/j/some.js", - "module": "library/j/some", + "resource": "library/j/ValidPropertyDefaultValue.js", + "module": "library/j/ValidPropertyDefaultValue", "export": "", "static": true, "visibility": "public", diff --git a/test/fixtures/library.j/main/src/library/j/ES6.features.2.js b/test/fixtures/library.j/main/src/library/j/ES6.features.2.js deleted file mode 100644 index b3fcef68d..000000000 --- a/test/fixtures/library.j/main/src/library/j/ES6.features.2.js +++ /dev/null @@ -1,45 +0,0 @@ -/*! - * ${copyright} - */ - -/** - * Covers: - * - ArrowFunctionExpression - */ -window.someRandomModule || - sap.ui.define( - ["./Control"], - /** - * Constructor for a new library.j.SubControl. - * - * @param {string} [sId] ID for the new control, generated automatically if no ID is given - * @param {object} [mSettings] Initial settings for the new control - * - * @class - * - * @author SAP SE - * @version ${version} - * - * @constructor - * @extends library.j.Control - * @public - * @since 1.22 - * @alias library.j.SubControl - */ - (Control) => - Control.extend(`library.j.SubControl`, { - metadata: { - properties: { - /** - * MyProp property - * @since 1.46 - */ - MyProp: { - type: "boolean", - group: `Misc`, - defaultValue: false, - }, - }, - }, - }) - ); diff --git a/test/fixtures/library.j/main/src/library/j/ES6.features.1.js b/test/fixtures/library.j/main/src/library/j/Foo.js similarity index 100% rename from test/fixtures/library.j/main/src/library/j/ES6.features.1.js rename to test/fixtures/library.j/main/src/library/j/Foo.js diff --git a/test/fixtures/library.j/main/src/library/j/SubControl.js b/test/fixtures/library.j/main/src/library/j/SubControl.js new file mode 100644 index 000000000..283fcaf16 --- /dev/null +++ b/test/fixtures/library.j/main/src/library/j/SubControl.js @@ -0,0 +1,45 @@ +/*! + * ${copyright} + */ + +/** + * Covers: + * - ArrowFunctionExpression + */ + window.someRandomModule || + sap.ui.define( + ["sap/ui/core/Control"], + /** + * Constructor for a new library.j.SubControl. + * + * @param {string} [sId] ID for the new control, generated automatically if no ID is given + * @param {object} [mSettings] Initial settings for the new control + * + * @class + * + * @author SAP SE + * @version ${version} + * + * @constructor + * @extends sap.ui.core.Control + * @public + * @since 1.22 + * @alias library.j.SubControl + */ + (Control) => + Control.extend(`library.j.SubControl`, { + metadata: { + properties: { + /** + * MyProp property + * @since 1.46 + */ + MyProp: { + type: "boolean", + group: `Misc`, + defaultValue: false, + }, + }, + }, + }) + ); diff --git a/test/fixtures/library.j/main/src/library/j/some.js b/test/fixtures/library.j/main/src/library/j/ValidPropertyDefaultValue.js similarity index 90% rename from test/fixtures/library.j/main/src/library/j/some.js rename to test/fixtures/library.j/main/src/library/j/ValidPropertyDefaultValue.js index 89f3bd311..b50252983 100644 --- a/test/fixtures/library.j/main/src/library/j/some.js +++ b/test/fixtures/library.j/main/src/library/j/ValidPropertyDefaultValue.js @@ -6,7 +6,6 @@ sap.ui.define([ "./library", "./library-core" ], (Control, { MyValidEnum, ThisIsEnumToo: RenamedEnum }, coreLibrary) => { - const { AnotherValidEnum } = coreLibrary; const { Buzz } = AnotherValidEnum; const { AnotherValidEnum: AnotherRenamedEnum } = coreLibrary; @@ -61,20 +60,22 @@ sap.ui.define([ /** * validPropertyDefaultValueEnumDestructuringWithRenameInArguments */ - validPropertyDefaultValueEnumDestructuringWithRenameInArguments: { - type: "library.j.ThisIsEnumToo", - group: "Misc", - defaultValue: RenamedEnum.Value1, - }, + validPropertyDefaultValueEnumDestructuringWithRenameInArguments: + { + type: "library.j.ThisIsEnumToo", + group: "Misc", + defaultValue: RenamedEnum.Value1, + }, /** * validPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar */ - validPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar: { - type: "library.j.ThisIsEnumToo", - group: "Misc", - defaultValue: RenamedValue2, - }, + validPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar: + { + type: "library.j.ThisIsEnumToo", + group: "Misc", + defaultValue: RenamedValue2, + }, /** * validPropertyDefaultValueEnumViaDestructuringInArrowFn diff --git a/test/fixtures/library.j/main/src/library/j/library-core.js b/test/fixtures/library.j/main/src/library/j/core/library.js similarity index 100% rename from test/fixtures/library.j/main/src/library/j/library-core.js rename to test/fixtures/library.j/main/src/library/j/core/library.js diff --git a/test/fixtures/library.j/main/src/library/j/library.js b/test/fixtures/library.j/main/src/library/j/library.js index 5ec0cefd7..8a5d5343e 100644 --- a/test/fixtures/library.j/main/src/library/j/library.js +++ b/test/fixtures/library.j/main/src/library/j/library.js @@ -6,7 +6,7 @@ sap.ui.define([], function () { name: "library.j", version: "${version}", dependencies: ["sap.ui.core"], - designtime: "library.j/designtime/library.designtime", + designtime: "library/j/designtime/library.designtime", types: ["library.j.MyValidEnum"], }); diff --git a/test/fixtures/library.j/main/src/library/j/ES6.features.3.js b/test/fixtures/library.j/main/src/library/j/someGenerator.js similarity index 100% rename from test/fixtures/library.j/main/src/library/j/ES6.features.3.js rename to test/fixtures/library.j/main/src/library/j/someGenerator.js From e6dd1ff9cafb7363b4f20fb67b2a0f8ab5e8abce Mon Sep 17 00:00:00 2001 From: Yavor Ivanov Date: Tue, 4 Oct 2022 09:52:27 +0300 Subject: [PATCH 38/69] Bugfix: Properly define dependencies --- .../dest/resources/library/j/ValidPropertyDefaultValue.js | 2 +- .../library.j/main/src/library/j/ValidPropertyDefaultValue.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/expected/build/library.j/dest/resources/library/j/ValidPropertyDefaultValue.js b/test/expected/build/library.j/dest/resources/library/j/ValidPropertyDefaultValue.js index b50252983..c6b90fc91 100644 --- a/test/expected/build/library.j/dest/resources/library/j/ValidPropertyDefaultValue.js +++ b/test/expected/build/library.j/dest/resources/library/j/ValidPropertyDefaultValue.js @@ -4,7 +4,7 @@ sap.ui.define([ "sap/ui/core/Control", "./library", - "./library-core" + "./core/library" ], (Control, { MyValidEnum, ThisIsEnumToo: RenamedEnum }, coreLibrary) => { const { AnotherValidEnum } = coreLibrary; const { Buzz } = AnotherValidEnum; diff --git a/test/fixtures/library.j/main/src/library/j/ValidPropertyDefaultValue.js b/test/fixtures/library.j/main/src/library/j/ValidPropertyDefaultValue.js index b50252983..c6b90fc91 100644 --- a/test/fixtures/library.j/main/src/library/j/ValidPropertyDefaultValue.js +++ b/test/fixtures/library.j/main/src/library/j/ValidPropertyDefaultValue.js @@ -4,7 +4,7 @@ sap.ui.define([ "sap/ui/core/Control", "./library", - "./library-core" + "./core/library" ], (Control, { MyValidEnum, ThisIsEnumToo: RenamedEnum }, coreLibrary) => { const { AnotherValidEnum } = coreLibrary; const { Buzz } = AnotherValidEnum; From 7f9eed3f495ae22e258f9284cd74e217576e77e4 Mon Sep 17 00:00:00 2001 From: Yavor Ivanov Date: Fri, 14 Oct 2022 15:18:03 +0300 Subject: [PATCH 39/69] Align with UI5 repo comments --- lib/processors/jsdoc/lib/ui5/plugin.cjs | 127 ++++++++++++------------ 1 file changed, 66 insertions(+), 61 deletions(-) diff --git a/lib/processors/jsdoc/lib/ui5/plugin.cjs b/lib/processors/jsdoc/lib/ui5/plugin.cjs index a65a321a6..46156fbd1 100644 --- a/lib/processors/jsdoc/lib/ui5/plugin.cjs +++ b/lib/processors/jsdoc/lib/ui5/plugin.cjs @@ -259,7 +259,7 @@ function analyzeModuleDefinition(node) { currentModule.dependencies = convertValue(args[arg], "string[]"); arg++; } - if ( arg < args.length && + if ( arg < args.length && [Syntax.FunctionExpression, Syntax.ArrowFunctionExpression].includes(args[arg].type)) { currentModule.factory = args[arg]; @@ -270,8 +270,7 @@ function analyzeModuleDefinition(node) { const names = (currentModule.factory.params[i].type === Syntax.ObjectPattern) ? currentModule.factory.params[i].properties.map(prop => { - const resolvedVar = getEnclosingVariableScope(prop) - .variables.filter((curVar) => prop.value.name === curVar.name)[0]; + const resolvedVar = getEnclosingVariableScope(prop).set.get(prop.value.name); const renamedVar = checkVarRenaming(resolvedVar); return { original: renamedVar.original, renamed: prop.value.name }; @@ -473,7 +472,7 @@ function createPropertyMap(node, defaultKey) { /** * Resolves potential wrapper expressions like: ChainExpression, AwaitExpression, etc. - * @param {Node} node + * @param {Node} node * @returns {Node} the resolved node */ function resolvePotentialWrapperExpression(node) { @@ -497,9 +496,9 @@ function resolvePotentialWrapperExpression(node) { /** * Strips the ChainExpression wrapper if such - * - * @param {Node} rootNode - * @param {String} path + * + * @param {Node} rootNode + * @param {String} path * @returns {Node} */ function stripChainWrappers(rootNode, path) { @@ -529,8 +528,8 @@ function isTemplateLiteralWithoutExpression(node) { /** * Checks whether a node is Literal or TemplateLiteral without an expression - * - * @param {Node} node + * + * @param {Node} node * @returns {String} */ function isStringLiteral(node) { @@ -577,8 +576,8 @@ function isArrowFuncExpression(node) { /** * Checks whether the node is of a "returning" type - * - * @param {Node} node + * + * @param {Node} node * @returns {Boolean} */ function isReturningNode(node) { @@ -659,9 +658,9 @@ function isPotentialEnum(node) { // ---- ES6+ Destructuring --------------------------------------------------------- /** * Tries to resolve an ENUM, regardless where it is defined and being destructured. - * - * @param {Node} node - * @param {String} type + * + * @param {Node} node + * @param {String} type * @returns {Object} */ function resolvePotentialEnum(node, type) { @@ -671,10 +670,10 @@ function resolvePotentialEnum(node, type) { return null; } - // When the fully quantified name gets resolved, we could try the "old" approach by checking + // When the fully quantified name gets resolved, we could try the "old" approach by checking // the type + key let value = varsDestructuringStack.join("."); - + if ( value.startsWith(type + ".") ) { // starts with fully qualified enum name -> cut off name value = value.slice(type.length + 1); @@ -687,8 +686,8 @@ function resolvePotentialEnum(node, type) { /** * Checks whether a var has been renamed while destructuring i.e. {A: b} = SomeObject - * - * @param {Variable} variable + * + * @param {Variable} variable * @returns {Object} */ function checkVarRenaming (variable) { @@ -697,6 +696,7 @@ function checkVarRenaming (variable) { // variable.defs[0].node.id.properties[0].value.name === variable.name; // Renamed let potentialRename = variable.defs + // Align structure from from variables comming from function parametters and ones defined in the current scope .reduce((acc, def) => { if (def.node && def.node.type === Syntax.ArrowFunctionExpression) { acc = acc.concat(def.node.params); @@ -706,7 +706,7 @@ function checkVarRenaming (variable) { return acc; }, []) // Filter on object patterns => Detructure renamig - .filter((param) => param && param.type === Syntax.ObjectPattern) + .filter((param) => param && param.type === Syntax.ObjectPattern) // Drill down to the ObjectPattern Node .filter((objPatternNode) => objPatternNode.properties.some( @@ -723,7 +723,7 @@ function checkVarRenaming (variable) { .map((prop) => { return { original: prop.key.name, renamed: prop.value.name }; })[0]; - + if (potentialRename) { return potentialRename; } @@ -743,9 +743,9 @@ function checkVarRenaming (variable) { /** * Builds the fully quantified name when there's a destructuring of a variable - * - * @param {Node} node - * @param {String} type + * + * @param {Node} node + * @param {String} type * @returns {Object} */ function resolveFullyQuantifiedName(node, type) { @@ -760,33 +760,34 @@ function resolveFullyQuantifiedName(node, type) { } while (leftMostName) { - let potentialChunk = currentScope.variables - .filter((curVar) => curVar.name === leftMostName) - .reduce((acc, curVar) => { - const potentialRenaming = checkVarRenaming(curVar); - const filteredValues = curVar.references - .filter((ref) => ref.writeExpr) - .map((ref) => { - const curNode = ref.writeExpr; - if ( curNode.type === Syntax.MemberExpression && !curNode.computed && curNode.object.type === Syntax.Identifier ) { - return curNode.object.name; - } else if (curNode.type === Syntax.MemberExpression && curNode.object.type === Syntax.MemberExpression) { // Standalone variable without leading dot notation namespace - return getResolvedObjectName(curNode); - } + const curVar = currentScope.set.get(leftMostName); - return (curNode && curNode.name) || ""; - }); + if (!curVar) { + break; + } - acc.push({ - ref: filteredValues[0], - original: potentialRenaming - ? potentialRenaming.original - : curVar.name, - renamed: potentialRenaming ? potentialRenaming.renamed : null, - replaced: potentialRenaming ? potentialRenaming.replaced : null, - }); - return acc; - }, [])[0]; + const potentialRenaming = checkVarRenaming(curVar); + const filteredValues = curVar.references + .filter((ref) => ref.writeExpr) + .map((ref) => { + const curNode = ref.writeExpr; + if ( curNode.type === Syntax.MemberExpression && !curNode.computed && curNode.object.type === Syntax.Identifier ) { + return curNode.object.name; + } else if (curNode.type === Syntax.MemberExpression && curNode.object.type === Syntax.MemberExpression) { // Standalone variable without leading dot notation namespace + return getResolvedObjectName(curNode); + } + + return (curNode && curNode.name) || ""; + }); + + const potentialChunk = { + ref: filteredValues[0], + original: potentialRenaming + ? potentialRenaming.original + : curVar.name, + renamed: potentialRenaming ? potentialRenaming.renamed : null, + replaced: potentialRenaming ? potentialRenaming.replaced : null, + }; leftMostName = potentialChunk && potentialChunk.ref; @@ -815,7 +816,7 @@ function resolveFullyQuantifiedName(node, type) { } // When an enum is defined in an external module, we cannot rely that this module is loaded and we could - // read from enumValues variable. Therefore we need to resolve the enum name from the type. + // read from enumValues variable. Therefore we need to resolve the enum name from the type. // The imported dependency name would be replaced by the type i.e. IF type: "sap.ui.core" THEN coreLibrary -> sap.ui.core // The leftMostChunk is the (eventual) dependency name i.e. coreLibrary let originalNameChunks = originalName.split("."); @@ -834,8 +835,8 @@ function resolveFullyQuantifiedName(node, type) { /** * Gets enclosing scope - * - * @param {Node} node + * + * @param {Node} node * @returns {Scope} */ function getEnclosingVariableScope (node) { @@ -980,6 +981,10 @@ function convertValueWithRaw(node, type, propertyName) { }; } + // This could be an ENUM which has been destructed up to the entity part. In that case the node.type === Syntax.Identifier + // For example, the `Solid` const in the following snippet: + // sap.ui.define(["sap/m/library"], ( { BackgroundDesign } ) => { + // const { Solid } = BackgroundDesign; const potentialEnum = resolvePotentialEnum(node, type); if ( potentialEnum ) { return potentialEnum; @@ -1011,7 +1016,7 @@ function convertValueWithRaw(node, type, propertyName) { raw: "{}" }; } - + } else if ( isTemplateLiteralWithoutExpression(node) ) { let value = node.quasis[0].value || {}; @@ -1443,16 +1448,16 @@ function determineValueRange(expression, varname, inverse) { && expression.left.type === Syntax.BinaryExpression && expression.right.type === Syntax.BinaryExpression ) { - if ( expression.operator === "&&" - && determineValueRangeBorder(range, expression.left, varname, inverse) + if ( expression.operator === "&&" + && determineValueRangeBorder(range, expression.left, varname, inverse) && determineValueRangeBorder(range, expression.right, varname, inverse) ) { return range; } else if ( ["||", "??"].includes(expression.operator) - && ( determineValueRangeBorder(range, expression.left, varname, inverse) + && ( determineValueRangeBorder(range, expression.left, varname, inverse) || determineValueRangeBorder(range, expression.right, varname, inverse) )) { return range; } - + } else if ( expression.type === Syntax.BinaryExpression && determineValueRangeBorder(range, expression, varname, inverse) ) { return range; @@ -3070,7 +3075,7 @@ exports.astNodeVisitor = { * to retain the full record type structure. * * JSDoc is copyright (c) 2011-present Michael Mathews micmath@gmail.com and the contributors to JSDoc. - */ + */ function getTypeStrings(parsedType, isOutermostType) { let applications; let typeString; @@ -3175,11 +3180,11 @@ exports.astNodeVisitor = { // #### BEGIN: MODIFIED BY SAP if ( tagInfo && (/function/.test(tagInfo.typeExpression) || /\{.*\}/.test(tagInfo.typeExpression)) && tagInfo.parsedType ) { // #### END: MODIFIED BY SAP - // console.info("old typeExpression", tagInfo.typeExpression); - // console.info("old parse tree", tagInfo.parsedType); - // console.info("old parse result", tagInfo.type); + // console.info("old typeExpression", tagInfo.typeExpression); + // console.info("old parse tree", tagInfo.parsedType); + // console.info("old parse result", tagInfo.type); tagInfo.type = getTypeStrings(tagInfo.parsedType); - // console.info("new parse result", tagInfo.type); + // console.info("new parse result", tagInfo.type); } return tagInfo; } From 41f22001b1c229215c2898ba79c5f1a35cfa87c2 Mon Sep 17 00:00:00 2001 From: Yavor Ivanov Date: Mon, 17 Oct 2022 07:05:42 +0300 Subject: [PATCH 40/69] Align with OpenUI5 repo --- lib/processors/jsdoc/lib/ui5/plugin.cjs | 36 ++++++++++++------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/lib/processors/jsdoc/lib/ui5/plugin.cjs b/lib/processors/jsdoc/lib/ui5/plugin.cjs index 46156fbd1..0435ed06c 100644 --- a/lib/processors/jsdoc/lib/ui5/plugin.cjs +++ b/lib/processors/jsdoc/lib/ui5/plugin.cjs @@ -791,28 +791,26 @@ function resolveFullyQuantifiedName(node, type) { leftMostName = potentialChunk && potentialChunk.ref; - if (potentialChunk && potentialChunk.replaced) { - originalName = originalName.replace(potentialChunk.replaced, potentialChunk.original); - } else { - originalName = leftMostName - ? leftMostName + "." + originalName - : originalName; - } + const isReplace = + potentialChunk && + potentialChunk.replaced && + potentialChunk.replaced !== potentialChunk.original; - if (potentialChunk && potentialChunk.renamed) { - originalName = originalName.replaceAll( - potentialChunk.renamed, - function (match, index, input) { - var isBeginOrDotInFront = !index || input[index - 1] === "."; - var charInTheEnd = input[index + match.length]; - var isEndOrDotInEnd = !charInTheEnd || charInTheEnd === "."; + const isRename = + potentialChunk && + potentialChunk.renamed && + potentialChunk.renamed !== potentialChunk.original; - return isBeginOrDotInFront && isEndOrDotInEnd - ? potentialChunk.original - : match; - } - ); + if ( isReplace || isRename) { + const renamedChunks = originalName.split(".") + renamedChunks.splice(0, 1, potentialChunk.original) + originalName = renamedChunks.join("."); } + + originalName = + leftMostName && !isReplace + ? leftMostName + "." + originalName + : originalName; } // When an enum is defined in an external module, we cannot rely that this module is loaded and we could From 519559affedf91918b5e7a748d58df295f295c0e Mon Sep 17 00:00:00 2001 From: Yavor Ivanov Date: Mon, 17 Oct 2022 12:58:19 +0300 Subject: [PATCH 41/69] Align with UI5 --- lib/processors/jsdoc/lib/ui5/plugin.cjs | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/lib/processors/jsdoc/lib/ui5/plugin.cjs b/lib/processors/jsdoc/lib/ui5/plugin.cjs index 0435ed06c..734e9ea25 100644 --- a/lib/processors/jsdoc/lib/ui5/plugin.cjs +++ b/lib/processors/jsdoc/lib/ui5/plugin.cjs @@ -267,15 +267,21 @@ function analyzeModuleDefinition(node) { } if ( currentModule.dependencies && currentModule.factory ) { for ( let i = 0; i < currentModule.dependencies.length && i < currentModule.factory.params.length; i++ ) { - const names = - (currentModule.factory.params[i].type === Syntax.ObjectPattern) - ? currentModule.factory.params[i].properties.map(prop => { - const resolvedVar = getEnclosingVariableScope(prop).set.get(prop.value.name); - const renamedVar = checkVarRenaming(resolvedVar); - - return { original: renamedVar.original, renamed: prop.value.name }; - }) // ObjectPattern means destructuring of the parameter - : [{original: currentModule.factory.params[i].name}]; // simple Identifier + let names; + + // ObjectPattern means destructuring of the parameter of a function + if (currentModule.factory.params[i].type === Syntax.ObjectPattern) { + // There might be multiple variables defined in the destructor and even further- + // those variables to be renamed i.e. function doSomething({a, b: renamedB}, c) { + names = currentModule.factory.params[i].properties.map(prop => { + const resolvedVar = getEnclosingVariableScope(prop).set.get(prop.value.name); + const renamedVar = checkVarRenaming(resolvedVar); + + return { original: renamedVar.original, renamed: prop.value.name }; + }); + } else { // simple Identifier + names = [{original: currentModule.factory.params[i].name}]; + } names.forEach(name => { const module = resolveModuleName(currentModule.module, currentModule.dependencies[i]); From 482e99adb41c4c1daa524d8ebcf78a84c1b5c15c Mon Sep 17 00:00:00 2001 From: Yavor Ivanov Date: Thu, 3 Nov 2022 15:02:01 +0200 Subject: [PATCH 42/69] Refactor: checkVarRenaming We cannot process variables with multiple definitions as we need to do analysis which is far beoyund our capabilities. This limitiation on the other side, gives us the opportunity to greatly simplify and reduce the code. We could process eiter a destructure function argument or a variable defintion --- lib/processors/jsdoc/lib/ui5/plugin.cjs | 128 +++++++++++++----------- 1 file changed, 67 insertions(+), 61 deletions(-) diff --git a/lib/processors/jsdoc/lib/ui5/plugin.cjs b/lib/processors/jsdoc/lib/ui5/plugin.cjs index 734e9ea25..57e098b58 100644 --- a/lib/processors/jsdoc/lib/ui5/plugin.cjs +++ b/lib/processors/jsdoc/lib/ui5/plugin.cjs @@ -277,7 +277,7 @@ function analyzeModuleDefinition(node) { const resolvedVar = getEnclosingVariableScope(prop).set.get(prop.value.name); const renamedVar = checkVarRenaming(resolvedVar); - return { original: renamedVar.original, renamed: prop.value.name }; + return renamedVar || { original: prop.key.name }; }); } else { // simple Identifier names = [{original: currentModule.factory.params[i].name}]; @@ -701,50 +701,52 @@ function checkVarRenaming (variable) { // variable.defs[0].node.id.properties[0].key.name === variable.name; // Original // variable.defs[0].node.id.properties[0].value.name === variable.name; // Renamed - let potentialRename = variable.defs - // Align structure from from variables comming from function parametters and ones defined in the current scope - .reduce((acc, def) => { - if (def.node && def.node.type === Syntax.ArrowFunctionExpression) { - acc = acc.concat(def.node.params); - } else if (def.node) { - acc.push(def.node.id); - } - return acc; - }, []) - // Filter on object patterns => Detructure renamig - .filter((param) => param && param.type === Syntax.ObjectPattern) - // Drill down to the ObjectPattern Node - .filter((objPatternNode) => - objPatternNode.properties.some( - (prop) => prop.value.name === variable.name - ) - ) // Filter on ObjectPattern nodes that contain the variable - .reduce((acc, objPatternNode) => { - return acc.concat( - objPatternNode.properties.filter( - (prop) => prop.value.name === variable.name - ) - ); - }, []) - .map((prop) => { - return { original: prop.key.name, renamed: prop.value.name }; - })[0]; - - if (potentialRename) { - return potentialRename; - } - - // var AriaHasPopup = sap.ui.core.aria.HasPopup; -> AriaHasPopup.None - potentialRename = - variable.defs.filter( - (def) => - def.node && def.node.id && def.node.id.type === Syntax.Identifier - ) - .map((def) => { - return { original: getResolvedObjectName(def.name), replaced: def.name.name }; - })[0]; - - return potentialRename; + // If variable.defs (Variable definitions within the source code) are more 1, then we'd not be able to + // determine which defintion to use. For example: + // function doSomething({a}, b) { + // console.log(a); + // var { c : a } = { b }; + // console.log(a); + // } + // doSomething({a:42}, 5); + // + // So, we'd not able to analyze which "a" to which console.log to map + if (variable.defs && variable.defs.length !== 1) { + return null; + } + + const varDefinition = variable.defs[0]; + let defNode; + + if (varDefinition.node.type === Syntax.ArrowFunctionExpression) { + // If destructuring happens as an ArrowFunction argument, then we need to find the exact argument. + // The structure is as follows: + // variable.defs.node.params[].properties[], where + // - node: ArrowFunctionExpression + // - node.params: ArrowFunctionExpression arguments + // - node.params[].properties: Destructured variables (Nodes). Represents 'b' and 'c' in: (a, {b, c}) => {} + defNode = varDefinition.node.params.find( + (arg) => + arg.properties && + arg.properties.some((prop) => prop.value.name === variable.name) + ); + } else { // Variable definition + defNode = varDefinition.node.id; + } + + + if (!defNode || defNode.type !== Syntax.ObjectPattern) { // Not a destructuring + return null; + } + + const varNode = defNode.properties.find( (prop) => prop.value.name === variable.name ); + + + if (varNode && varNode.key.name !== varNode.value.name) { // There's a rename + return { original: varNode.key.name, renamed: varNode.value.name }; + } else { + return null; + } }; /** @@ -786,37 +788,34 @@ function resolveFullyQuantifiedName(node, type) { return (curNode && curNode.name) || ""; }); - const potentialChunk = { + let potentialChunk = { ref: filteredValues[0], - original: potentialRenaming - ? potentialRenaming.original - : curVar.name, - renamed: potentialRenaming ? potentialRenaming.renamed : null, - replaced: potentialRenaming ? potentialRenaming.replaced : null, + original: curVar.name }; - leftMostName = potentialChunk && potentialChunk.ref; + if (potentialRenaming) { + potentialChunk = Object.assign(potentialChunk, { + original: potentialRenaming.original, + renamed: potentialRenaming.renamed + }); + } - const isReplace = - potentialChunk && - potentialChunk.replaced && - potentialChunk.replaced !== potentialChunk.original; + leftMostName = potentialChunk.ref; const isRename = potentialChunk && potentialChunk.renamed && potentialChunk.renamed !== potentialChunk.original; - if ( isReplace || isRename) { + if ( isRename ) { const renamedChunks = originalName.split(".") renamedChunks.splice(0, 1, potentialChunk.original) originalName = renamedChunks.join("."); } - originalName = - leftMostName && !isReplace - ? leftMostName + "." + originalName - : originalName; + originalName = leftMostName + ? leftMostName + "." + originalName + : originalName; } // When an enum is defined in an external module, we cannot rely that this module is loaded and we could @@ -827,6 +826,8 @@ function resolveFullyQuantifiedName(node, type) { let typeChunks = type.split(".") const firstMatchedChunkIndex = originalNameChunks.findIndex((chunk) => typeChunks.indexOf(chunk) !== -1); + // TODO: Use currentModule.localNames to resolve coreLibrary -> sap.ui.core OR getResolvedObjectName()/getObjectName() eventually? + // getResolvedName(originalName); if (firstMatchedChunkIndex !== -1) { originalNameChunks = originalNameChunks.slice(firstMatchedChunkIndex); const typeIndex = typeChunks.indexOf(originalNameChunks[0]); @@ -892,6 +893,11 @@ function getLeftmostName(node) { function getResolvedObjectName(node) { const name = getObjectName(node); const _import = getLeftmostName(node); + + return getResolvedName(name, _import); +} + +function getResolvedName(name, _import) { const local = _import && currentModule.localNames[_import]; if ( name && local && (local.class || local.module) ) { let resolvedName; From 0bb4dc4f96b4fef34b6d8ee9c9a2aaa269d5aaf6 Mon Sep 17 00:00:00 2001 From: Yavor Ivanov Date: Fri, 4 Nov 2022 10:45:03 +0200 Subject: [PATCH 43/69] Refactor fully qunitified name resolver --- lib/processors/jsdoc/lib/ui5/plugin.cjs | 117 +++++++++++------------- 1 file changed, 52 insertions(+), 65 deletions(-) diff --git a/lib/processors/jsdoc/lib/ui5/plugin.cjs b/lib/processors/jsdoc/lib/ui5/plugin.cjs index 57e098b58..75c406d5c 100644 --- a/lib/processors/jsdoc/lib/ui5/plugin.cjs +++ b/lib/processors/jsdoc/lib/ui5/plugin.cjs @@ -690,13 +690,37 @@ function resolvePotentialEnum(node, type) { } } +/** + * Returns the {Node} of the destructured argument of a (arrow) function. + * + * @param {Definition|ParameterDefinition} varDefinition + * @returns {Node} + */ +function getFuncArgumentDestructNode(varDefinition, varName) { + if (varDefinition.node.type === Syntax.ArrowFunctionExpression) { + // If destructuring happens as an ArrowFunction argument, then we need to find the exact argument. + // The structure is as follows: + // variable.defs.node.params[].properties[], where + // - node: ArrowFunctionExpression + // - node.params: ArrowFunctionExpression arguments + // - node.params[].properties: Destructured variables (Nodes). Represents 'b' and 'c' in: (a, {b, c}) => {} + return varDefinition.node.params.find( + (arg) => + arg.properties && + arg.properties.some((prop) => prop.value.name === varName) + ); + } + + // return undefined; +} + /** * Checks whether a var has been renamed while destructuring i.e. {A: b} = SomeObject * * @param {Variable} variable * @returns {Object} */ -function checkVarRenaming (variable) { +function checkVarRenaming(variable) { // variable.defs[0].node.id.type === Syntax.ObjectPattern -> Renaming // variable.defs[0].node.id.properties[0].key.name === variable.name; // Original // variable.defs[0].node.id.properties[0].value.name === variable.name; // Renamed @@ -716,33 +740,19 @@ function checkVarRenaming (variable) { } const varDefinition = variable.defs[0]; - let defNode; - - if (varDefinition.node.type === Syntax.ArrowFunctionExpression) { - // If destructuring happens as an ArrowFunction argument, then we need to find the exact argument. - // The structure is as follows: - // variable.defs.node.params[].properties[], where - // - node: ArrowFunctionExpression - // - node.params: ArrowFunctionExpression arguments - // - node.params[].properties: Destructured variables (Nodes). Represents 'b' and 'c' in: (a, {b, c}) => {} - defNode = varDefinition.node.params.find( - (arg) => - arg.properties && - arg.properties.some((prop) => prop.value.name === variable.name) - ); - } else { // Variable definition - defNode = varDefinition.node.id; - } - + const defNode = getFuncArgumentDestructNode(varDefinition, variable.name) // (arrow) function argument + || varDefinition.node.id; // variable definition if (!defNode || defNode.type !== Syntax.ObjectPattern) { // Not a destructuring return null; } - const varNode = defNode.properties.find( (prop) => prop.value.name === variable.name ); - + const varNode = defNode.properties.find( + (prop) => prop.value.name === variable.name + ); - if (varNode && varNode.key.name !== varNode.value.name) { // There's a rename + if (varNode && varNode.key.name !== varNode.value.name) { + // There's a rename return { original: varNode.key.name, renamed: varNode.value.name }; } else { return null; @@ -758,10 +768,11 @@ function checkVarRenaming (variable) { */ function resolveFullyQuantifiedName(node, type) { // The missing part is on the left side. The right side is clear. - // We would eiter ways would resolve to the same leftmost token. + // We would eiter ways resolve to the same leftmost token. let leftMostName = getLeftmostName(node); let originalName = getObjectName(node) || ""; const currentScope = getEnclosingVariableScope(node); + let renameMap = {}; if (!currentScope) { return null; @@ -775,7 +786,7 @@ function resolveFullyQuantifiedName(node, type) { } const potentialRenaming = checkVarRenaming(curVar); - const filteredValues = curVar.references + leftMostName = curVar.references .filter((ref) => ref.writeExpr) .map((ref) => { const curNode = ref.writeExpr; @@ -786,56 +797,32 @@ function resolveFullyQuantifiedName(node, type) { } return (curNode && curNode.name) || ""; - }); - - let potentialChunk = { - ref: filteredValues[0], - original: curVar.name - }; + })[0]; - if (potentialRenaming) { - potentialChunk = Object.assign(potentialChunk, { - original: potentialRenaming.original, - renamed: potentialRenaming.renamed - }); - } + if (potentialRenaming && potentialRenaming.original !== potentialRenaming.renamed) { + renameMap[potentialRenaming.original] = potentialRenaming.renamed - leftMostName = potentialChunk.ref; - - const isRename = - potentialChunk && - potentialChunk.renamed && - potentialChunk.renamed !== potentialChunk.original; - - if ( isRename ) { const renamedChunks = originalName.split(".") - renamedChunks.splice(0, 1, potentialChunk.original) + renamedChunks.splice(0, 1, potentialRenaming.original) originalName = renamedChunks.join("."); } - originalName = leftMostName - ? leftMostName + "." + originalName - : originalName; + // This is a destructured function argument. + // We'd need to determine the external module (getResolvedName() -> currentModule.localNames[]) + // and append it to the argument's name. + if ( !!getFuncArgumentDestructNode(curVar.defs[0], curVar.name) ) { + const nameToResolve = renameMap[curVar.name] || curVar.name; + originalName = + [getResolvedName(nameToResolve, nameToResolve), originalName].join("."); + } else if (leftMostName) { + originalName = leftMostName + "." + originalName; + } } - // When an enum is defined in an external module, we cannot rely that this module is loaded and we could - // read from enumValues variable. Therefore we need to resolve the enum name from the type. - // The imported dependency name would be replaced by the type i.e. IF type: "sap.ui.core" THEN coreLibrary -> sap.ui.core - // The leftMostChunk is the (eventual) dependency name i.e. coreLibrary - let originalNameChunks = originalName.split("."); - let typeChunks = type.split(".") - const firstMatchedChunkIndex = originalNameChunks.findIndex((chunk) => typeChunks.indexOf(chunk) !== -1); - - // TODO: Use currentModule.localNames to resolve coreLibrary -> sap.ui.core OR getResolvedObjectName()/getObjectName() eventually? - // getResolvedName(originalName); - if (firstMatchedChunkIndex !== -1) { - originalNameChunks = originalNameChunks.slice(firstMatchedChunkIndex); - const typeIndex = typeChunks.indexOf(originalNameChunks[0]); - typeChunks = typeChunks.slice(0, typeIndex); - originalNameChunks = typeChunks.concat(originalNameChunks); - } + const originalNameChunks = originalName.split("."); + const resolvedNamespace = getResolvedName(originalNameChunks[0], originalNameChunks[0]).split("."); - return originalNameChunks; + return resolvedNamespace.concat(originalNameChunks.slice(1)); } /** From e152dacdc2c8994b0fdb11826fa6aff148973ab1 Mon Sep 17 00:00:00 2001 From: Yavor Ivanov Date: Mon, 7 Nov 2022 11:21:37 +0200 Subject: [PATCH 44/69] Support aria.hasPopup case --- lib/processors/jsdoc/lib/ui5/plugin.cjs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/processors/jsdoc/lib/ui5/plugin.cjs b/lib/processors/jsdoc/lib/ui5/plugin.cjs index 75c406d5c..8de9ec607 100644 --- a/lib/processors/jsdoc/lib/ui5/plugin.cjs +++ b/lib/processors/jsdoc/lib/ui5/plugin.cjs @@ -744,8 +744,8 @@ function checkVarRenaming(variable) { || varDefinition.node.id; // variable definition if (!defNode || defNode.type !== Syntax.ObjectPattern) { // Not a destructuring - return null; - } + return null; + } const varNode = defNode.properties.find( (prop) => prop.value.name === variable.name @@ -763,10 +763,9 @@ function checkVarRenaming(variable) { * Builds the fully quantified name when there's a destructuring of a variable * * @param {Node} node - * @param {String} type * @returns {Object} */ -function resolveFullyQuantifiedName(node, type) { +function resolveFullyQuantifiedName(node) { // The missing part is on the left side. The right side is clear. // We would eiter ways resolve to the same leftmost token. let leftMostName = getLeftmostName(node); @@ -785,6 +784,15 @@ function resolveFullyQuantifiedName(node, type) { break; } + const defNode = + getFuncArgumentDestructNode(curVar.defs[0], curVar.name) || // (arrow) function argument + curVar.defs[0].node.id; // variable definition + + if (!defNode || defNode.type !== Syntax.ObjectPattern) { + // Not a destructuring + return getResolvedName(originalName, leftMostName).split("."); + } + const potentialRenaming = checkVarRenaming(curVar); leftMostName = curVar.references .filter((ref) => ref.writeExpr) From 65732e7ffa4a243040ab332d4beba4375b3ad7d5 Mon Sep 17 00:00:00 2001 From: Yavor Ivanov Date: Mon, 7 Nov 2022 13:30:33 +0200 Subject: [PATCH 45/69] Refactor code and introducce isVarDestructuring() --- lib/processors/jsdoc/lib/ui5/plugin.cjs | 34 +++++++++++++++++-------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/lib/processors/jsdoc/lib/ui5/plugin.cjs b/lib/processors/jsdoc/lib/ui5/plugin.cjs index 8de9ec607..79a6b62f6 100644 --- a/lib/processors/jsdoc/lib/ui5/plugin.cjs +++ b/lib/processors/jsdoc/lib/ui5/plugin.cjs @@ -670,7 +670,7 @@ function isPotentialEnum(node) { * @returns {Object} */ function resolvePotentialEnum(node, type) { - const varsDestructuringStack = resolveFullyQuantifiedName(node, type); + const varsDestructuringStack = resolveFullyQuantifiedName(node); if (!varsDestructuringStack || !varsDestructuringStack.length) { return null; @@ -714,6 +714,22 @@ function getFuncArgumentDestructNode(varDefinition, varName) { // return undefined; } +/** + * Checks whether a variable has been destructured. + * + * @param {Variable} variable + * @returns + */ +function isVarDestructuring(variable) { + const defNode = + variable && + variable.defs && + ( getFuncArgumentDestructNode(variable.defs[0], variable.name) // (arrow) function argument + || variable.defs[0].node.id ); // variable definition + + return defNode && defNode.type === Syntax.ObjectPattern; +} + /** * Checks whether a var has been renamed while destructuring i.e. {A: b} = SomeObject * @@ -735,7 +751,11 @@ function checkVarRenaming(variable) { // doSomething({a:42}, 5); // // So, we'd not able to analyze which "a" to which console.log to map - if (variable.defs && variable.defs.length !== 1) { + if ( + !variable || !variable.defs + || (variable.defs && variable.defs.length !== 1) + || !isVarDestructuring(variable) + ) { return null; } @@ -743,10 +763,6 @@ function checkVarRenaming(variable) { const defNode = getFuncArgumentDestructNode(varDefinition, variable.name) // (arrow) function argument || varDefinition.node.id; // variable definition - if (!defNode || defNode.type !== Syntax.ObjectPattern) { // Not a destructuring - return null; - } - const varNode = defNode.properties.find( (prop) => prop.value.name === variable.name ); @@ -784,11 +800,7 @@ function resolveFullyQuantifiedName(node) { break; } - const defNode = - getFuncArgumentDestructNode(curVar.defs[0], curVar.name) || // (arrow) function argument - curVar.defs[0].node.id; // variable definition - - if (!defNode || defNode.type !== Syntax.ObjectPattern) { + if ( !isVarDestructuring(curVar) ) { // Not a destructuring return getResolvedName(originalName, leftMostName).split("."); } From d17363e8eddbc496ca5a87a867a0e8c439eb52ac Mon Sep 17 00:00:00 2001 From: Yavor Ivanov Date: Mon, 14 Nov 2022 09:41:40 +0200 Subject: [PATCH 46/69] Align with OpenUI5 --- lib/processors/jsdoc/lib/ui5/plugin.cjs | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/processors/jsdoc/lib/ui5/plugin.cjs b/lib/processors/jsdoc/lib/ui5/plugin.cjs index 79a6b62f6..1865c8f99 100644 --- a/lib/processors/jsdoc/lib/ui5/plugin.cjs +++ b/lib/processors/jsdoc/lib/ui5/plugin.cjs @@ -2731,6 +2731,7 @@ exports.handlers = { e.doclet.meta.__shortpath = getRelativePath(filepath); _ui5data.resource = currentModule.resource; _ui5data.module = currentModule.name || currentModule.module; + _ui5data.initialLongname = e.doclet.longname; const localDecl = findLocalDeclaration(e.doclet.meta.lineno, e.doclet.meta.columnno); if ( localDecl ) { From ec7cee0356af0a946ae9b0caf4f56f80fde83e1e Mon Sep 17 00:00:00 2001 From: Yavor Ivanov Date: Tue, 15 Nov 2022 09:10:20 +0200 Subject: [PATCH 47/69] Define new scenarios for destructuring - Nested ObjectPattern destructuring - ArrayPattern handling - ArrayPattern + (nested) ObjectPattern --- .../library/j/ValidPropertyDefaultValue.js | 233 +++++++++++------- .../library/j/ValidPropertyDefaultValue.js | 233 +++++++++++------- 2 files changed, 292 insertions(+), 174 deletions(-) diff --git a/test/expected/build/library.j/dest/resources/library/j/ValidPropertyDefaultValue.js b/test/expected/build/library.j/dest/resources/library/j/ValidPropertyDefaultValue.js index c6b90fc91..e570f2ce1 100644 --- a/test/expected/build/library.j/dest/resources/library/j/ValidPropertyDefaultValue.js +++ b/test/expected/build/library.j/dest/resources/library/j/ValidPropertyDefaultValue.js @@ -1,104 +1,163 @@ /*! * ${copyright} */ -sap.ui.define([ - "sap/ui/core/Control", - "./library", - "./core/library" -], (Control, { MyValidEnum, ThisIsEnumToo: RenamedEnum }, coreLibrary) => { - const { AnotherValidEnum } = coreLibrary; - const { Buzz } = AnotherValidEnum; - const { AnotherValidEnum: AnotherRenamedEnum } = coreLibrary; - const { H1 } = sap.ui.core.TitleLevel; - const { Value2: RenamedValue2 } = RenamedEnum; +sap.ui.define( + [ + "sap/ui/core/Control", + "./library", + "./core/library", + "sap/external/thirdparty/library", + "sap/external2/thirdparty/library", + ], + ( + Control, + { MyValidEnum, ThisIsEnumToo: RenamedEnum }, + coreLibrary, + [arrPattern, {arrWith: {deep: arrPatternDeepDestruct}}], + { objPattern: {deeply: {destructured: objPatternDeepDestruct}, objPattern1Lvl} } + ) => { + const { AnotherValidEnum } = coreLibrary; + const { Buzz } = AnotherValidEnum; + const { AnotherValidEnum: {Buzz: BuzzRenamed} } = coreLibrary; + const { AnotherValidEnum: AnotherRenamedEnum } = coreLibrary; + const { H1 } = sap.ui.core.TitleLevel; + const { Value2: RenamedValue2 } = RenamedEnum; - /** - * @class - * My super documentation of this class - * - * @extends sap.ui.core.Control - * - * @author SAP SE - * @version ${version} - * - * @public - * @alias library.j.ValidPropertyDefaultValue - * @ui5-metamodel text - */ - var ValidPropertyDefaultValue = Control.extend( - "library.j.ValidPropertyDefaultValue", - { - metadata: { - properties: { - /** - * validPropertyDefaultValueEnumSimpleDestructuring - */ - validPropertyDefaultValueEnumSimpleDestructuring: { - type: "library.j.core.AnotherValidEnum", - group: "Misc", - defaultValue: AnotherValidEnum.Buzz, - }, + /** + * @class + * My super documentation of this class + * + * @extends sap.ui.core.Control + * + * @author SAP SE + * @version ${version} + * + * @public + * @alias library.j.ValidPropertyDefaultValue + * @ui5-metamodel text + */ + var ValidPropertyDefaultValue = Control.extend( + "library.j.ValidPropertyDefaultValue", + { + metadata: { + properties: { + /** + * validPropertyDefaultValueEnumSimpleDestructuring + */ + validPropertyDefaultValueEnumSimpleDestructuring: { + type: "library.j.core.AnotherValidEnum", + group: "Misc", + defaultValue: AnotherValidEnum.Buzz, + }, - /** - * validPropertyDefaultValueEnumChainedDestructuring - */ - validPropertyDefaultValueEnumChainedDestructuring: { - type: "library.j.core.AnotherValidEnum", - group: "Misc", - defaultValue: Buzz, - }, + /** + * validPropertyDefaultValueEnumChainedDestructuring + */ + validPropertyDefaultValueEnumChainedDestructuring: { + type: "library.j.core.AnotherValidEnum", + group: "Misc", + defaultValue: Buzz, + }, - /** - * validPropertyDefaultValueEnumDestructuringWithRename - */ - validPropertyDefaultValueEnumDestructuringWithRename: { - type: "library.j.core.AnotherValidEnum", - group: "Misc", - defaultValue: AnotherRenamedEnum.Fizz, - }, + /** + * validPropertyDefaultValueEnumNestedDestructuring + */ + validPropertyDefaultValueEnumChainedDestructuring: { + type: "library.j.core.AnotherValidEnum", + group: "Misc", + defaultValue: BuzzRenamed, + }, + + /** + * validPropertyDefaultValueEnumDestructuringWithRename + */ + validPropertyDefaultValueEnumDestructuringWithRename: { + type: "library.j.core.AnotherValidEnum", + group: "Misc", + defaultValue: AnotherRenamedEnum.Fizz, + }, + + /** + * validPropertyDefaultValueEnumDestructuringWithRenameInArguments + */ + validPropertyDefaultValueEnumDestructuringWithRenameInArguments: + { + type: "library.j.ThisIsEnumToo", + group: "Misc", + defaultValue: RenamedEnum.Value1, + }, + + /** + * validPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar + */ + validPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar: + { + type: "library.j.ThisIsEnumToo", + group: "Misc", + defaultValue: RenamedValue2, + }, - /** - * validPropertyDefaultValueEnumDestructuringWithRenameInArguments - */ - validPropertyDefaultValueEnumDestructuringWithRenameInArguments: - { - type: "library.j.ThisIsEnumToo", + /** + * validPropertyDefaultValueEnumViaDestructuringInArrowFn + */ + validPropertyDefaultValueEnumViaDestructuringInArrowFn: + { + type: "library.j.MyValidEnum", + group: "Misc", + defaultValue: MyValidEnum.Foo, + }, + + /** + * validPropertyDefaultValueEnumViaDestructuringGlobal + */ + validPropertyDefaultValueEnumViaDestructuringGlobal: { + type: "sap.ui.core.TitleLevel", group: "Misc", - defaultValue: RenamedEnum.Value1, + defaultValue: H1, }, - /** - * validPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar - */ - validPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar: - { - type: "library.j.ThisIsEnumToo", + /** + * validPropertyDefaultValueArrPattern + */ + validPropertyDefaultValueArrPattern: { + type: "sap.external.thirdparty.library", group: "Misc", - defaultValue: RenamedValue2, + defaultValue: arrPattern, }, - /** - * validPropertyDefaultValueEnumViaDestructuringInArrowFn - */ - validPropertyDefaultValueEnumViaDestructuringInArrowFn: { - type: "library.j.MyValidEnum", - group: "Misc", - defaultValue: MyValidEnum.Foo, - }, + /** + * validPropertyDefaultValueArrPatternDeepDestruct + */ + validPropertyDefaultValueArrPatternDeepDestruct: { + type: "sap.external.thirdparty.library.arrWith.deep", + group: "Misc", + defaultValue: arrPatternDeepDestruct, + }, - /** - * validPropertyDefaultValueEnumViaDestructuringGlobal - */ - validPropertyDefaultValueEnumViaDestructuringGlobal: { - type: "sap.ui.core.TitleLevel", - group: "Misc", - defaultValue: H1, + /** + * validPropertyDefaultValueArrPatternDeepDestruct + */ + validPropertyDefaultValueObjPatternDeepDestruct: { + type: "sap.external2.thirdparty.library.objPattern.deeply", + group: "Misc", + defaultValue: objPatternDeepDestruct, + }, + + /** + * validPropertyDefaultValueObjPatternNested + */ + validPropertyDefaultValueObjPatternNested: { + type: "sap.external2.thirdparty.library.objPattern", + group: "Misc", + defaultValue: objPattern1Lvl, + } }, }, - }, - renderer: function () {}, - } - ); + renderer: function () {}, + } + ); - return ValidPropertyDefaultValue; -}, /* bExport= */ true); + return ValidPropertyDefaultValue; + }, + /* bExport= */ true +); diff --git a/test/fixtures/library.j/main/src/library/j/ValidPropertyDefaultValue.js b/test/fixtures/library.j/main/src/library/j/ValidPropertyDefaultValue.js index c6b90fc91..e570f2ce1 100644 --- a/test/fixtures/library.j/main/src/library/j/ValidPropertyDefaultValue.js +++ b/test/fixtures/library.j/main/src/library/j/ValidPropertyDefaultValue.js @@ -1,104 +1,163 @@ /*! * ${copyright} */ -sap.ui.define([ - "sap/ui/core/Control", - "./library", - "./core/library" -], (Control, { MyValidEnum, ThisIsEnumToo: RenamedEnum }, coreLibrary) => { - const { AnotherValidEnum } = coreLibrary; - const { Buzz } = AnotherValidEnum; - const { AnotherValidEnum: AnotherRenamedEnum } = coreLibrary; - const { H1 } = sap.ui.core.TitleLevel; - const { Value2: RenamedValue2 } = RenamedEnum; +sap.ui.define( + [ + "sap/ui/core/Control", + "./library", + "./core/library", + "sap/external/thirdparty/library", + "sap/external2/thirdparty/library", + ], + ( + Control, + { MyValidEnum, ThisIsEnumToo: RenamedEnum }, + coreLibrary, + [arrPattern, {arrWith: {deep: arrPatternDeepDestruct}}], + { objPattern: {deeply: {destructured: objPatternDeepDestruct}, objPattern1Lvl} } + ) => { + const { AnotherValidEnum } = coreLibrary; + const { Buzz } = AnotherValidEnum; + const { AnotherValidEnum: {Buzz: BuzzRenamed} } = coreLibrary; + const { AnotherValidEnum: AnotherRenamedEnum } = coreLibrary; + const { H1 } = sap.ui.core.TitleLevel; + const { Value2: RenamedValue2 } = RenamedEnum; - /** - * @class - * My super documentation of this class - * - * @extends sap.ui.core.Control - * - * @author SAP SE - * @version ${version} - * - * @public - * @alias library.j.ValidPropertyDefaultValue - * @ui5-metamodel text - */ - var ValidPropertyDefaultValue = Control.extend( - "library.j.ValidPropertyDefaultValue", - { - metadata: { - properties: { - /** - * validPropertyDefaultValueEnumSimpleDestructuring - */ - validPropertyDefaultValueEnumSimpleDestructuring: { - type: "library.j.core.AnotherValidEnum", - group: "Misc", - defaultValue: AnotherValidEnum.Buzz, - }, + /** + * @class + * My super documentation of this class + * + * @extends sap.ui.core.Control + * + * @author SAP SE + * @version ${version} + * + * @public + * @alias library.j.ValidPropertyDefaultValue + * @ui5-metamodel text + */ + var ValidPropertyDefaultValue = Control.extend( + "library.j.ValidPropertyDefaultValue", + { + metadata: { + properties: { + /** + * validPropertyDefaultValueEnumSimpleDestructuring + */ + validPropertyDefaultValueEnumSimpleDestructuring: { + type: "library.j.core.AnotherValidEnum", + group: "Misc", + defaultValue: AnotherValidEnum.Buzz, + }, - /** - * validPropertyDefaultValueEnumChainedDestructuring - */ - validPropertyDefaultValueEnumChainedDestructuring: { - type: "library.j.core.AnotherValidEnum", - group: "Misc", - defaultValue: Buzz, - }, + /** + * validPropertyDefaultValueEnumChainedDestructuring + */ + validPropertyDefaultValueEnumChainedDestructuring: { + type: "library.j.core.AnotherValidEnum", + group: "Misc", + defaultValue: Buzz, + }, - /** - * validPropertyDefaultValueEnumDestructuringWithRename - */ - validPropertyDefaultValueEnumDestructuringWithRename: { - type: "library.j.core.AnotherValidEnum", - group: "Misc", - defaultValue: AnotherRenamedEnum.Fizz, - }, + /** + * validPropertyDefaultValueEnumNestedDestructuring + */ + validPropertyDefaultValueEnumChainedDestructuring: { + type: "library.j.core.AnotherValidEnum", + group: "Misc", + defaultValue: BuzzRenamed, + }, + + /** + * validPropertyDefaultValueEnumDestructuringWithRename + */ + validPropertyDefaultValueEnumDestructuringWithRename: { + type: "library.j.core.AnotherValidEnum", + group: "Misc", + defaultValue: AnotherRenamedEnum.Fizz, + }, + + /** + * validPropertyDefaultValueEnumDestructuringWithRenameInArguments + */ + validPropertyDefaultValueEnumDestructuringWithRenameInArguments: + { + type: "library.j.ThisIsEnumToo", + group: "Misc", + defaultValue: RenamedEnum.Value1, + }, + + /** + * validPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar + */ + validPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar: + { + type: "library.j.ThisIsEnumToo", + group: "Misc", + defaultValue: RenamedValue2, + }, - /** - * validPropertyDefaultValueEnumDestructuringWithRenameInArguments - */ - validPropertyDefaultValueEnumDestructuringWithRenameInArguments: - { - type: "library.j.ThisIsEnumToo", + /** + * validPropertyDefaultValueEnumViaDestructuringInArrowFn + */ + validPropertyDefaultValueEnumViaDestructuringInArrowFn: + { + type: "library.j.MyValidEnum", + group: "Misc", + defaultValue: MyValidEnum.Foo, + }, + + /** + * validPropertyDefaultValueEnumViaDestructuringGlobal + */ + validPropertyDefaultValueEnumViaDestructuringGlobal: { + type: "sap.ui.core.TitleLevel", group: "Misc", - defaultValue: RenamedEnum.Value1, + defaultValue: H1, }, - /** - * validPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar - */ - validPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar: - { - type: "library.j.ThisIsEnumToo", + /** + * validPropertyDefaultValueArrPattern + */ + validPropertyDefaultValueArrPattern: { + type: "sap.external.thirdparty.library", group: "Misc", - defaultValue: RenamedValue2, + defaultValue: arrPattern, }, - /** - * validPropertyDefaultValueEnumViaDestructuringInArrowFn - */ - validPropertyDefaultValueEnumViaDestructuringInArrowFn: { - type: "library.j.MyValidEnum", - group: "Misc", - defaultValue: MyValidEnum.Foo, - }, + /** + * validPropertyDefaultValueArrPatternDeepDestruct + */ + validPropertyDefaultValueArrPatternDeepDestruct: { + type: "sap.external.thirdparty.library.arrWith.deep", + group: "Misc", + defaultValue: arrPatternDeepDestruct, + }, - /** - * validPropertyDefaultValueEnumViaDestructuringGlobal - */ - validPropertyDefaultValueEnumViaDestructuringGlobal: { - type: "sap.ui.core.TitleLevel", - group: "Misc", - defaultValue: H1, + /** + * validPropertyDefaultValueArrPatternDeepDestruct + */ + validPropertyDefaultValueObjPatternDeepDestruct: { + type: "sap.external2.thirdparty.library.objPattern.deeply", + group: "Misc", + defaultValue: objPatternDeepDestruct, + }, + + /** + * validPropertyDefaultValueObjPatternNested + */ + validPropertyDefaultValueObjPatternNested: { + type: "sap.external2.thirdparty.library.objPattern", + group: "Misc", + defaultValue: objPattern1Lvl, + } }, }, - }, - renderer: function () {}, - } - ); + renderer: function () {}, + } + ); - return ValidPropertyDefaultValue; -}, /* bExport= */ true); + return ValidPropertyDefaultValue; + }, + /* bExport= */ true +); From cb726a50ae5d3826977ce4895bc21eb2f9160614 Mon Sep 17 00:00:00 2001 From: Yavor Ivanov Date: Tue, 15 Nov 2022 09:11:16 +0200 Subject: [PATCH 48/69] Handle ObjectPattern nested destructuring in arguments Basic handling of ArrayPattern in Arguments --- lib/processors/jsdoc/lib/ui5/plugin.cjs | 49 +++++++++++++++++++------ 1 file changed, 38 insertions(+), 11 deletions(-) diff --git a/lib/processors/jsdoc/lib/ui5/plugin.cjs b/lib/processors/jsdoc/lib/ui5/plugin.cjs index 1865c8f99..9566a604d 100644 --- a/lib/processors/jsdoc/lib/ui5/plugin.cjs +++ b/lib/processors/jsdoc/lib/ui5/plugin.cjs @@ -267,19 +267,46 @@ function analyzeModuleDefinition(node) { } if ( currentModule.dependencies && currentModule.factory ) { for ( let i = 0; i < currentModule.dependencies.length && i < currentModule.factory.params.length; i++ ) { - let names; + let names = []; - // ObjectPattern means destructuring of the parameter of a function - if (currentModule.factory.params[i].type === Syntax.ObjectPattern) { + if (currentModule.factory.params[i].type === Syntax.ArrayPattern) { // ArrayPattern means destructuring of the parameter of a function + names = currentModule.factory.params[i].elements.map((param) => { + return {original: param.name}; + }); + } else if (currentModule.factory.params[i].type === Syntax.ObjectPattern) { // ObjectPattern means destructuring of the parameter of a function // There might be multiple variables defined in the destructor and even further- // those variables to be renamed i.e. function doSomething({a, b: renamedB}, c) { - names = currentModule.factory.params[i].properties.map(prop => { - const resolvedVar = getEnclosingVariableScope(prop).set.get(prop.value.name); - const renamedVar = checkVarRenaming(resolvedVar); + names = currentModule.factory.params[i].properties.reduce((acc, prop) => { + + // Resolves nested destructuring with (potential) multiple end nodes + const resolveObjectPatternChain = (prop, keys) => { + let chainSequence = []; + if (prop.value && prop.value.type === Syntax.ObjectPattern) { + for (let i = 0; i < prop.value.properties.length; i++) { + chainSequence = chainSequence.concat( + resolveObjectPatternChain( prop.value.properties[i], [...keys, prop.key.name] ) + ); + } + } else { + chainSequence.push({ prop, keys }); + } - return renamedVar || { original: prop.key.name }; - }); - } else { // simple Identifier + return chainSequence; + }; + + const objectPatternIdentifiers = resolveObjectPatternChain(prop, []); + + objectPatternIdentifiers.forEach(({prop, keys}) => { + if (prop.key.name !== prop.value.name) { + acc.push({ original: prop.key.name, renamed: prop.value.name, path: keys.join(".") }); + } else { + acc.push({ original: prop.key.name, path: keys.join(".") }); + } + }); + + return acc; + }, []); + } else if (currentModule.factory.params[i].type === Syntax.Identifier) { // simple Identifier names = [{original: currentModule.factory.params[i].name}]; } @@ -288,8 +315,8 @@ function analyzeModuleDefinition(node) { debug(` import ${name.renamed || name.original} from '${module}'`); currentModule.localNames[name.renamed || name.original] = { - module: module - // no (or empty) path + module: module, + ...(name.path ? {path: name.path} : {}) }; }); } From b2eee55614f5f8ae40ac90c40512dfbe87688f7b Mon Sep 17 00:00:00 2001 From: Yavor Ivanov Date: Tue, 15 Nov 2022 09:21:24 +0200 Subject: [PATCH 49/69] Additional test cases --- .../library/j/ValidPropertyDefaultValue.js | 45 +++++++++++++------ .../library/j/ValidPropertyDefaultValue.js | 45 +++++++++++++------ 2 files changed, 64 insertions(+), 26 deletions(-) diff --git a/test/expected/build/library.j/dest/resources/library/j/ValidPropertyDefaultValue.js b/test/expected/build/library.j/dest/resources/library/j/ValidPropertyDefaultValue.js index e570f2ce1..a5b32b73b 100644 --- a/test/expected/build/library.j/dest/resources/library/j/ValidPropertyDefaultValue.js +++ b/test/expected/build/library.j/dest/resources/library/j/ValidPropertyDefaultValue.js @@ -14,7 +14,7 @@ sap.ui.define( { MyValidEnum, ThisIsEnumToo: RenamedEnum }, coreLibrary, [arrPattern, {arrWith: {deep: arrPatternDeepDestruct}}], - { objPattern: {deeply: {destructured: objPatternDeepDestruct}, objPattern1Lvl} } + { objPattern: {deeply: {destructured: objPatternDeepDestruct}, objPattern1Lvl}, ...libraryExt } ) => { const { AnotherValidEnum } = coreLibrary; const { Buzz } = AnotherValidEnum; @@ -22,6 +22,7 @@ sap.ui.define( const { AnotherValidEnum: AnotherRenamedEnum } = coreLibrary; const { H1 } = sap.ui.core.TitleLevel; const { Value2: RenamedValue2 } = RenamedEnum; + const [ arrPatternVarDef, {nested: {arrPatternVarDef: arrPatternVarDefNestedAndRenamed}} ] = libraryExt; /** * @class @@ -47,7 +48,7 @@ sap.ui.define( validPropertyDefaultValueEnumSimpleDestructuring: { type: "library.j.core.AnotherValidEnum", group: "Misc", - defaultValue: AnotherValidEnum.Buzz, + defaultValue: AnotherValidEnum.Buzz }, /** @@ -56,7 +57,7 @@ sap.ui.define( validPropertyDefaultValueEnumChainedDestructuring: { type: "library.j.core.AnotherValidEnum", group: "Misc", - defaultValue: Buzz, + defaultValue: Buzz }, /** @@ -65,7 +66,7 @@ sap.ui.define( validPropertyDefaultValueEnumChainedDestructuring: { type: "library.j.core.AnotherValidEnum", group: "Misc", - defaultValue: BuzzRenamed, + defaultValue: BuzzRenamed }, /** @@ -74,7 +75,7 @@ sap.ui.define( validPropertyDefaultValueEnumDestructuringWithRename: { type: "library.j.core.AnotherValidEnum", group: "Misc", - defaultValue: AnotherRenamedEnum.Fizz, + defaultValue: AnotherRenamedEnum.Fizz }, /** @@ -84,7 +85,7 @@ sap.ui.define( { type: "library.j.ThisIsEnumToo", group: "Misc", - defaultValue: RenamedEnum.Value1, + defaultValue: RenamedEnum.Value1 }, /** @@ -94,7 +95,7 @@ sap.ui.define( { type: "library.j.ThisIsEnumToo", group: "Misc", - defaultValue: RenamedValue2, + defaultValue: RenamedValue2 }, /** @@ -104,7 +105,7 @@ sap.ui.define( { type: "library.j.MyValidEnum", group: "Misc", - defaultValue: MyValidEnum.Foo, + defaultValue: MyValidEnum.Foo }, /** @@ -113,7 +114,7 @@ sap.ui.define( validPropertyDefaultValueEnumViaDestructuringGlobal: { type: "sap.ui.core.TitleLevel", group: "Misc", - defaultValue: H1, + defaultValue: H1 }, /** @@ -122,7 +123,7 @@ sap.ui.define( validPropertyDefaultValueArrPattern: { type: "sap.external.thirdparty.library", group: "Misc", - defaultValue: arrPattern, + defaultValue: arrPattern }, /** @@ -131,7 +132,7 @@ sap.ui.define( validPropertyDefaultValueArrPatternDeepDestruct: { type: "sap.external.thirdparty.library.arrWith.deep", group: "Misc", - defaultValue: arrPatternDeepDestruct, + defaultValue: arrPatternDeepDestruct }, /** @@ -140,7 +141,7 @@ sap.ui.define( validPropertyDefaultValueObjPatternDeepDestruct: { type: "sap.external2.thirdparty.library.objPattern.deeply", group: "Misc", - defaultValue: objPatternDeepDestruct, + defaultValue: objPatternDeepDestruct }, /** @@ -149,7 +150,25 @@ sap.ui.define( validPropertyDefaultValueObjPatternNested: { type: "sap.external2.thirdparty.library.objPattern", group: "Misc", - defaultValue: objPattern1Lvl, + defaultValue: objPattern1Lvl + }, + + /** + * validPropertyDefaultValueArrPatternVarDef + */ + validPropertyDefaultValueArrPatternVarDef: { + type: "sap.external2.thirdparty.library", + group: "Misc", + defaultValue: arrPatternVarDef + }, + + /** + * validPropertyDefaultValueArrPatternVarDef + */ + validPropertyDefaultValueArrPatternVarDefNestedAndRenamed: { + type: "sap.external2.thirdparty.library.nested", + group: "Misc", + defaultValue: arrPatternVarDefNestedAndRenamed } }, }, diff --git a/test/fixtures/library.j/main/src/library/j/ValidPropertyDefaultValue.js b/test/fixtures/library.j/main/src/library/j/ValidPropertyDefaultValue.js index e570f2ce1..a5b32b73b 100644 --- a/test/fixtures/library.j/main/src/library/j/ValidPropertyDefaultValue.js +++ b/test/fixtures/library.j/main/src/library/j/ValidPropertyDefaultValue.js @@ -14,7 +14,7 @@ sap.ui.define( { MyValidEnum, ThisIsEnumToo: RenamedEnum }, coreLibrary, [arrPattern, {arrWith: {deep: arrPatternDeepDestruct}}], - { objPattern: {deeply: {destructured: objPatternDeepDestruct}, objPattern1Lvl} } + { objPattern: {deeply: {destructured: objPatternDeepDestruct}, objPattern1Lvl}, ...libraryExt } ) => { const { AnotherValidEnum } = coreLibrary; const { Buzz } = AnotherValidEnum; @@ -22,6 +22,7 @@ sap.ui.define( const { AnotherValidEnum: AnotherRenamedEnum } = coreLibrary; const { H1 } = sap.ui.core.TitleLevel; const { Value2: RenamedValue2 } = RenamedEnum; + const [ arrPatternVarDef, {nested: {arrPatternVarDef: arrPatternVarDefNestedAndRenamed}} ] = libraryExt; /** * @class @@ -47,7 +48,7 @@ sap.ui.define( validPropertyDefaultValueEnumSimpleDestructuring: { type: "library.j.core.AnotherValidEnum", group: "Misc", - defaultValue: AnotherValidEnum.Buzz, + defaultValue: AnotherValidEnum.Buzz }, /** @@ -56,7 +57,7 @@ sap.ui.define( validPropertyDefaultValueEnumChainedDestructuring: { type: "library.j.core.AnotherValidEnum", group: "Misc", - defaultValue: Buzz, + defaultValue: Buzz }, /** @@ -65,7 +66,7 @@ sap.ui.define( validPropertyDefaultValueEnumChainedDestructuring: { type: "library.j.core.AnotherValidEnum", group: "Misc", - defaultValue: BuzzRenamed, + defaultValue: BuzzRenamed }, /** @@ -74,7 +75,7 @@ sap.ui.define( validPropertyDefaultValueEnumDestructuringWithRename: { type: "library.j.core.AnotherValidEnum", group: "Misc", - defaultValue: AnotherRenamedEnum.Fizz, + defaultValue: AnotherRenamedEnum.Fizz }, /** @@ -84,7 +85,7 @@ sap.ui.define( { type: "library.j.ThisIsEnumToo", group: "Misc", - defaultValue: RenamedEnum.Value1, + defaultValue: RenamedEnum.Value1 }, /** @@ -94,7 +95,7 @@ sap.ui.define( { type: "library.j.ThisIsEnumToo", group: "Misc", - defaultValue: RenamedValue2, + defaultValue: RenamedValue2 }, /** @@ -104,7 +105,7 @@ sap.ui.define( { type: "library.j.MyValidEnum", group: "Misc", - defaultValue: MyValidEnum.Foo, + defaultValue: MyValidEnum.Foo }, /** @@ -113,7 +114,7 @@ sap.ui.define( validPropertyDefaultValueEnumViaDestructuringGlobal: { type: "sap.ui.core.TitleLevel", group: "Misc", - defaultValue: H1, + defaultValue: H1 }, /** @@ -122,7 +123,7 @@ sap.ui.define( validPropertyDefaultValueArrPattern: { type: "sap.external.thirdparty.library", group: "Misc", - defaultValue: arrPattern, + defaultValue: arrPattern }, /** @@ -131,7 +132,7 @@ sap.ui.define( validPropertyDefaultValueArrPatternDeepDestruct: { type: "sap.external.thirdparty.library.arrWith.deep", group: "Misc", - defaultValue: arrPatternDeepDestruct, + defaultValue: arrPatternDeepDestruct }, /** @@ -140,7 +141,7 @@ sap.ui.define( validPropertyDefaultValueObjPatternDeepDestruct: { type: "sap.external2.thirdparty.library.objPattern.deeply", group: "Misc", - defaultValue: objPatternDeepDestruct, + defaultValue: objPatternDeepDestruct }, /** @@ -149,7 +150,25 @@ sap.ui.define( validPropertyDefaultValueObjPatternNested: { type: "sap.external2.thirdparty.library.objPattern", group: "Misc", - defaultValue: objPattern1Lvl, + defaultValue: objPattern1Lvl + }, + + /** + * validPropertyDefaultValueArrPatternVarDef + */ + validPropertyDefaultValueArrPatternVarDef: { + type: "sap.external2.thirdparty.library", + group: "Misc", + defaultValue: arrPatternVarDef + }, + + /** + * validPropertyDefaultValueArrPatternVarDef + */ + validPropertyDefaultValueArrPatternVarDefNestedAndRenamed: { + type: "sap.external2.thirdparty.library.nested", + group: "Misc", + defaultValue: arrPatternVarDefNestedAndRenamed } }, }, From 1f2060f75a9979c1a721db7e1eab49183fc2136b Mon Sep 17 00:00:00 2001 From: Yavor Ivanov Date: Tue, 15 Nov 2022 15:24:26 +0200 Subject: [PATCH 50/69] Refactor arguments handler to cover ObjectPattern, ArrayPattern & mixture of them --- lib/processors/jsdoc/lib/ui5/plugin.cjs | 73 ++++++++++++++----------- 1 file changed, 40 insertions(+), 33 deletions(-) diff --git a/lib/processors/jsdoc/lib/ui5/plugin.cjs b/lib/processors/jsdoc/lib/ui5/plugin.cjs index 9566a604d..a872405d0 100644 --- a/lib/processors/jsdoc/lib/ui5/plugin.cjs +++ b/lib/processors/jsdoc/lib/ui5/plugin.cjs @@ -265,47 +265,54 @@ function analyzeModuleDefinition(node) { currentModule.factory = args[arg]; arg++; } + + + function resolveObjectPatternChain (valueNode, keyNode, keyChain) { + let chainSequence = []; + + if (valueNode && valueNode.type === Syntax.ObjectPattern) { + for (let i = 0; i < valueNode.properties.length; i++) { + chainSequence = chainSequence.concat( + resolveObjectPatternChain( + valueNode.properties[i].value, + valueNode.properties[i].key, + [...keyChain, valueNode.properties[i].key.name] ) + ); + } + } else if (valueNode && valueNode.type === Syntax.ArrayPattern) { + for (let i = 0; i < valueNode.elements.length; i++) { + chainSequence = chainSequence.concat( + resolveObjectPatternChain( + valueNode.elements[i], + valueNode.elements[i], + keyChain ) + ); + } + } else { + chainSequence.push({ valueNode, keyNode, keyChain }); + } + + return chainSequence; + }; + if ( currentModule.dependencies && currentModule.factory ) { for ( let i = 0; i < currentModule.dependencies.length && i < currentModule.factory.params.length; i++ ) { let names = []; - if (currentModule.factory.params[i].type === Syntax.ArrayPattern) { // ArrayPattern means destructuring of the parameter of a function - names = currentModule.factory.params[i].elements.map((param) => { - return {original: param.name}; - }); - } else if (currentModule.factory.params[i].type === Syntax.ObjectPattern) { // ObjectPattern means destructuring of the parameter of a function - // There might be multiple variables defined in the destructor and even further- - // those variables to be renamed i.e. function doSomething({a, b: renamedB}, c) { - names = currentModule.factory.params[i].properties.reduce((acc, prop) => { - - // Resolves nested destructuring with (potential) multiple end nodes - const resolveObjectPatternChain = (prop, keys) => { - let chainSequence = []; - if (prop.value && prop.value.type === Syntax.ObjectPattern) { - for (let i = 0; i < prop.value.properties.length; i++) { - chainSequence = chainSequence.concat( - resolveObjectPatternChain( prop.value.properties[i], [...keys, prop.key.name] ) - ); - } - } else { - chainSequence.push({ prop, keys }); + if ( [Syntax.ObjectPattern, Syntax.ArrayPattern].includes(currentModule.factory.params[i].type) ) { // ObjectPattern/ArrayPattern means destructuring of the parameter of a function + names = resolveObjectPatternChain(currentModule.factory.params[i], null, []) + .map(({valueNode, keyNode, keyChain}) => { + let result = { original: keyNode.name, } + if (keyNode.name !== valueNode.name) { + result.renamed = valueNode.name; } - - return chainSequence; - }; - - const objectPatternIdentifiers = resolveObjectPatternChain(prop, []); - - objectPatternIdentifiers.forEach(({prop, keys}) => { - if (prop.key.name !== prop.value.name) { - acc.push({ original: prop.key.name, renamed: prop.value.name, path: keys.join(".") }); - } else { - acc.push({ original: prop.key.name, path: keys.join(".") }); + if (keyChain.length > 1 /*|| keyNode.name !== valueNode.name*/) { + result.path = keyChain.join("."); } + + return result; }); - return acc; - }, []); } else if (currentModule.factory.params[i].type === Syntax.Identifier) { // simple Identifier names = [{original: currentModule.factory.params[i].name}]; } From f2a645898efbe2becac8963ae818a79e44f0f917 Mon Sep 17 00:00:00 2001 From: Yavor Ivanov Date: Tue, 15 Nov 2022 16:12:01 +0200 Subject: [PATCH 51/69] Make ObjectPattern resolver reusable --- lib/processors/jsdoc/lib/ui5/plugin.cjs | 81 ++++++++++++++----------- 1 file changed, 47 insertions(+), 34 deletions(-) diff --git a/lib/processors/jsdoc/lib/ui5/plugin.cjs b/lib/processors/jsdoc/lib/ui5/plugin.cjs index a872405d0..f7a0f68a4 100644 --- a/lib/processors/jsdoc/lib/ui5/plugin.cjs +++ b/lib/processors/jsdoc/lib/ui5/plugin.cjs @@ -266,35 +266,6 @@ function analyzeModuleDefinition(node) { arg++; } - - function resolveObjectPatternChain (valueNode, keyNode, keyChain) { - let chainSequence = []; - - if (valueNode && valueNode.type === Syntax.ObjectPattern) { - for (let i = 0; i < valueNode.properties.length; i++) { - chainSequence = chainSequence.concat( - resolveObjectPatternChain( - valueNode.properties[i].value, - valueNode.properties[i].key, - [...keyChain, valueNode.properties[i].key.name] ) - ); - } - } else if (valueNode && valueNode.type === Syntax.ArrayPattern) { - for (let i = 0; i < valueNode.elements.length; i++) { - chainSequence = chainSequence.concat( - resolveObjectPatternChain( - valueNode.elements[i], - valueNode.elements[i], - keyChain ) - ); - } - } else { - chainSequence.push({ valueNode, keyNode, keyChain }); - } - - return chainSequence; - }; - if ( currentModule.dependencies && currentModule.factory ) { for ( let i = 0; i < currentModule.dependencies.length && i < currentModule.factory.params.length; i++ ) { let names = []; @@ -696,6 +667,43 @@ function isPotentialEnum(node) { } // ---- ES6+ Destructuring --------------------------------------------------------- + +/** + * Resolves (nested) Object/ArrayPattern nodes and builds a "path" + * + * @param {Node} valueNode + * @param {Node} keyNode + * @param {Array} keyChain + * @returns Array>> + */ +function resolveObjectPatternChain (valueNode, keyNode, keyChain) { + let chainSequence = []; + + if (valueNode && valueNode.type === Syntax.ObjectPattern) { + for (let i = 0; i < valueNode.properties.length; i++) { + chainSequence = chainSequence.concat( + resolveObjectPatternChain( + valueNode.properties[i].value, + valueNode.properties[i].key, + [...keyChain, valueNode.properties[i].key.name] ) + ); + } + } else if (valueNode && valueNode.type === Syntax.ArrayPattern) { + for (let i = 0; i < valueNode.elements.length; i++) { + chainSequence = chainSequence.concat( + resolveObjectPatternChain( + valueNode.elements[i], + valueNode.elements[i], + keyChain ) + ); + } + } else { + chainSequence.push({ valueNode, keyNode, keyChain }); + } + + return chainSequence; +}; + /** * Tries to resolve an ENUM, regardless where it is defined and being destructured. * @@ -797,13 +805,18 @@ function checkVarRenaming(variable) { const defNode = getFuncArgumentDestructNode(varDefinition, variable.name) // (arrow) function argument || varDefinition.node.id; // variable definition - const varNode = defNode.properties.find( - (prop) => prop.value.name === variable.name + const varNode = resolveObjectPatternChain(defNode, null, []).find( + ({valueNode}) => valueNode.name === variable.name ); - if (varNode && varNode.key.name !== varNode.value.name) { - // There's a rename - return { original: varNode.key.name, renamed: varNode.value.name }; + if (varNode && varNode.keyNode.name !== varNode.valueNode.name) { // There's a rename + let result = { original: varNode.keyNode.name, renamed: varNode.valueNode.name }; + + if (varNode.keyChain.length > 1 /*|| keyNode.name !== valueNode.name*/) { + result.path = varNode.keyChain.join("."); + } + + return result; } else { return null; } From f44c701448866d71633f1b33b51cda560537addb Mon Sep 17 00:00:00 2001 From: Yavor Ivanov Date: Tue, 15 Nov 2022 16:12:14 +0200 Subject: [PATCH 52/69] Adjust tests --- .../library/j/ValidPropertyDefaultValue.js | 18 ++++++++++-------- .../src/library/j/ValidPropertyDefaultValue.js | 18 ++++++++++-------- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/test/expected/build/library.j/dest/resources/library/j/ValidPropertyDefaultValue.js b/test/expected/build/library.j/dest/resources/library/j/ValidPropertyDefaultValue.js index a5b32b73b..b54d5bb63 100644 --- a/test/expected/build/library.j/dest/resources/library/j/ValidPropertyDefaultValue.js +++ b/test/expected/build/library.j/dest/resources/library/j/ValidPropertyDefaultValue.js @@ -8,13 +8,15 @@ sap.ui.define( "./core/library", "sap/external/thirdparty/library", "sap/external2/thirdparty/library", + "sap/external3/thirdparty/library", ], ( Control, { MyValidEnum, ThisIsEnumToo: RenamedEnum }, coreLibrary, [arrPattern, {arrWith: {deep: arrPatternDeepDestruct}}], - { objPattern: {deeply: {destructured: objPatternDeepDestruct}, objPattern1Lvl}, ...libraryExt } + { objPattern: {deeply: {destructured: objPatternDeepDestruct}, objPattern1Lvl} }, + libraryExt ) => { const { AnotherValidEnum } = coreLibrary; const { Buzz } = AnotherValidEnum; @@ -63,7 +65,7 @@ sap.ui.define( /** * validPropertyDefaultValueEnumNestedDestructuring */ - validPropertyDefaultValueEnumChainedDestructuring: { + validPropertyDefaultValueEnumNestedDestructuring: { type: "library.j.core.AnotherValidEnum", group: "Misc", defaultValue: BuzzRenamed @@ -121,7 +123,7 @@ sap.ui.define( * validPropertyDefaultValueArrPattern */ validPropertyDefaultValueArrPattern: { - type: "sap.external.thirdparty.library", + type: "sap.external.thirdparty", group: "Misc", defaultValue: arrPattern }, @@ -130,7 +132,7 @@ sap.ui.define( * validPropertyDefaultValueArrPatternDeepDestruct */ validPropertyDefaultValueArrPatternDeepDestruct: { - type: "sap.external.thirdparty.library.arrWith.deep", + type: "sap.external.thirdparty.arrWith.deep", group: "Misc", defaultValue: arrPatternDeepDestruct }, @@ -139,7 +141,7 @@ sap.ui.define( * validPropertyDefaultValueArrPatternDeepDestruct */ validPropertyDefaultValueObjPatternDeepDestruct: { - type: "sap.external2.thirdparty.library.objPattern.deeply", + type: "sap.external2.thirdparty.objPattern.deeply", group: "Misc", defaultValue: objPatternDeepDestruct }, @@ -148,7 +150,7 @@ sap.ui.define( * validPropertyDefaultValueObjPatternNested */ validPropertyDefaultValueObjPatternNested: { - type: "sap.external2.thirdparty.library.objPattern", + type: "sap.external2.thirdparty.objPattern", group: "Misc", defaultValue: objPattern1Lvl }, @@ -157,7 +159,7 @@ sap.ui.define( * validPropertyDefaultValueArrPatternVarDef */ validPropertyDefaultValueArrPatternVarDef: { - type: "sap.external2.thirdparty.library", + type: "sap.external2.thirdparty", group: "Misc", defaultValue: arrPatternVarDef }, @@ -166,7 +168,7 @@ sap.ui.define( * validPropertyDefaultValueArrPatternVarDef */ validPropertyDefaultValueArrPatternVarDefNestedAndRenamed: { - type: "sap.external2.thirdparty.library.nested", + type: "sap.external2.thirdparty.nested", group: "Misc", defaultValue: arrPatternVarDefNestedAndRenamed } diff --git a/test/fixtures/library.j/main/src/library/j/ValidPropertyDefaultValue.js b/test/fixtures/library.j/main/src/library/j/ValidPropertyDefaultValue.js index a5b32b73b..b54d5bb63 100644 --- a/test/fixtures/library.j/main/src/library/j/ValidPropertyDefaultValue.js +++ b/test/fixtures/library.j/main/src/library/j/ValidPropertyDefaultValue.js @@ -8,13 +8,15 @@ sap.ui.define( "./core/library", "sap/external/thirdparty/library", "sap/external2/thirdparty/library", + "sap/external3/thirdparty/library", ], ( Control, { MyValidEnum, ThisIsEnumToo: RenamedEnum }, coreLibrary, [arrPattern, {arrWith: {deep: arrPatternDeepDestruct}}], - { objPattern: {deeply: {destructured: objPatternDeepDestruct}, objPattern1Lvl}, ...libraryExt } + { objPattern: {deeply: {destructured: objPatternDeepDestruct}, objPattern1Lvl} }, + libraryExt ) => { const { AnotherValidEnum } = coreLibrary; const { Buzz } = AnotherValidEnum; @@ -63,7 +65,7 @@ sap.ui.define( /** * validPropertyDefaultValueEnumNestedDestructuring */ - validPropertyDefaultValueEnumChainedDestructuring: { + validPropertyDefaultValueEnumNestedDestructuring: { type: "library.j.core.AnotherValidEnum", group: "Misc", defaultValue: BuzzRenamed @@ -121,7 +123,7 @@ sap.ui.define( * validPropertyDefaultValueArrPattern */ validPropertyDefaultValueArrPattern: { - type: "sap.external.thirdparty.library", + type: "sap.external.thirdparty", group: "Misc", defaultValue: arrPattern }, @@ -130,7 +132,7 @@ sap.ui.define( * validPropertyDefaultValueArrPatternDeepDestruct */ validPropertyDefaultValueArrPatternDeepDestruct: { - type: "sap.external.thirdparty.library.arrWith.deep", + type: "sap.external.thirdparty.arrWith.deep", group: "Misc", defaultValue: arrPatternDeepDestruct }, @@ -139,7 +141,7 @@ sap.ui.define( * validPropertyDefaultValueArrPatternDeepDestruct */ validPropertyDefaultValueObjPatternDeepDestruct: { - type: "sap.external2.thirdparty.library.objPattern.deeply", + type: "sap.external2.thirdparty.objPattern.deeply", group: "Misc", defaultValue: objPatternDeepDestruct }, @@ -148,7 +150,7 @@ sap.ui.define( * validPropertyDefaultValueObjPatternNested */ validPropertyDefaultValueObjPatternNested: { - type: "sap.external2.thirdparty.library.objPattern", + type: "sap.external2.thirdparty.objPattern", group: "Misc", defaultValue: objPattern1Lvl }, @@ -157,7 +159,7 @@ sap.ui.define( * validPropertyDefaultValueArrPatternVarDef */ validPropertyDefaultValueArrPatternVarDef: { - type: "sap.external2.thirdparty.library", + type: "sap.external2.thirdparty", group: "Misc", defaultValue: arrPatternVarDef }, @@ -166,7 +168,7 @@ sap.ui.define( * validPropertyDefaultValueArrPatternVarDef */ validPropertyDefaultValueArrPatternVarDefNestedAndRenamed: { - type: "sap.external2.thirdparty.library.nested", + type: "sap.external2.thirdparty.nested", group: "Misc", defaultValue: arrPatternVarDefNestedAndRenamed } From fbbe10bb4ef745cd9b920d28795c67ca77a64cc5 Mon Sep 17 00:00:00 2001 From: Yavor Ivanov Date: Wed, 16 Nov 2022 10:06:09 +0200 Subject: [PATCH 53/69] Include "path" to the resolved variables --- lib/processors/jsdoc/lib/ui5/plugin.cjs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/processors/jsdoc/lib/ui5/plugin.cjs b/lib/processors/jsdoc/lib/ui5/plugin.cjs index f7a0f68a4..cd7b8e72e 100644 --- a/lib/processors/jsdoc/lib/ui5/plugin.cjs +++ b/lib/processors/jsdoc/lib/ui5/plugin.cjs @@ -277,7 +277,7 @@ function analyzeModuleDefinition(node) { if (keyNode.name !== valueNode.name) { result.renamed = valueNode.name; } - if (keyChain.length > 1 /*|| keyNode.name !== valueNode.name*/) { + if (keyChain.length > 1 || keyNode.name !== valueNode.name) { result.path = keyChain.join("."); } @@ -805,15 +805,15 @@ function checkVarRenaming(variable) { const defNode = getFuncArgumentDestructNode(varDefinition, variable.name) // (arrow) function argument || varDefinition.node.id; // variable definition - const varNode = resolveObjectPatternChain(defNode, null, []).find( + const resolvedOP = resolveObjectPatternChain(defNode, null, []).find( ({valueNode}) => valueNode.name === variable.name ); - if (varNode && varNode.keyNode.name !== varNode.valueNode.name) { // There's a rename - let result = { original: varNode.keyNode.name, renamed: varNode.valueNode.name }; + if (resolvedOP && resolvedOP.keyNode.name !== resolvedOP.valueNode.name) { // There's a rename + let result = { original: resolvedOP.keyNode.name, renamed: resolvedOP.valueNode.name }; - if (varNode.keyChain.length > 1 /*|| keyNode.name !== valueNode.name*/) { - result.path = varNode.keyChain.join("."); + if (resolvedOP.keyChain.length > 1 || resolvedOP.keyNode.name !== resolvedOP.valueNode.name) { + result.path = resolvedOP.keyChain.join("."); } return result; @@ -866,11 +866,11 @@ function resolveFullyQuantifiedName(node) { return (curNode && curNode.name) || ""; })[0]; - if (potentialRenaming && potentialRenaming.original !== potentialRenaming.renamed) { - renameMap[potentialRenaming.original] = potentialRenaming.renamed + if (potentialRenaming) { + renameMap[potentialRenaming.original] = potentialRenaming.renamed; - const renamedChunks = originalName.split(".") - renamedChunks.splice(0, 1, potentialRenaming.original) + const renamedChunks = originalName.split("."); + renamedChunks.splice(0, 1, potentialRenaming.path || potentialRenaming.original); originalName = renamedChunks.join("."); } From 99912e5f4427a39c184cdb3aef890d428d38f683 Mon Sep 17 00:00:00 2001 From: Yavor Ivanov Date: Wed, 16 Nov 2022 10:55:44 +0200 Subject: [PATCH 54/69] Refactor getFuncArgumentDestructNode() and include ArrayPattern in destructor detection --- lib/processors/jsdoc/lib/ui5/plugin.cjs | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/lib/processors/jsdoc/lib/ui5/plugin.cjs b/lib/processors/jsdoc/lib/ui5/plugin.cjs index cd7b8e72e..ba99a59e2 100644 --- a/lib/processors/jsdoc/lib/ui5/plugin.cjs +++ b/lib/processors/jsdoc/lib/ui5/plugin.cjs @@ -738,19 +738,9 @@ function resolvePotentialEnum(node, type) { * @param {Definition|ParameterDefinition} varDefinition * @returns {Node} */ -function getFuncArgumentDestructNode(varDefinition, varName) { +function getFuncArgumentDestructNode(varDefinition) { if (varDefinition.node.type === Syntax.ArrowFunctionExpression) { - // If destructuring happens as an ArrowFunction argument, then we need to find the exact argument. - // The structure is as follows: - // variable.defs.node.params[].properties[], where - // - node: ArrowFunctionExpression - // - node.params: ArrowFunctionExpression arguments - // - node.params[].properties: Destructured variables (Nodes). Represents 'b' and 'c' in: (a, {b, c}) => {} - return varDefinition.node.params.find( - (arg) => - arg.properties && - arg.properties.some((prop) => prop.value.name === varName) - ); + return varDefinition.node.params[varDefinition.index]; } // return undefined; @@ -766,10 +756,10 @@ function isVarDestructuring(variable) { const defNode = variable && variable.defs && - ( getFuncArgumentDestructNode(variable.defs[0], variable.name) // (arrow) function argument + ( getFuncArgumentDestructNode(variable.defs[0]) // (arrow) function argument || variable.defs[0].node.id ); // variable definition - return defNode && defNode.type === Syntax.ObjectPattern; + return defNode && [Syntax.ObjectPattern, Syntax.ArrayPattern].includes( defNode.type ); } /** @@ -802,7 +792,7 @@ function checkVarRenaming(variable) { } const varDefinition = variable.defs[0]; - const defNode = getFuncArgumentDestructNode(varDefinition, variable.name) // (arrow) function argument + const defNode = getFuncArgumentDestructNode(varDefinition) // (arrow) function argument || varDefinition.node.id; // variable definition const resolvedOP = resolveObjectPatternChain(defNode, null, []).find( @@ -877,7 +867,7 @@ function resolveFullyQuantifiedName(node) { // This is a destructured function argument. // We'd need to determine the external module (getResolvedName() -> currentModule.localNames[]) // and append it to the argument's name. - if ( !!getFuncArgumentDestructNode(curVar.defs[0], curVar.name) ) { + if ( !!getFuncArgumentDestructNode(curVar.defs[0]) ) { const nameToResolve = renameMap[curVar.name] || curVar.name; originalName = [getResolvedName(nameToResolve, nameToResolve), originalName].join("."); From 66dc04373f185ba789d35c63e2beb7edcb2a830f Mon Sep 17 00:00:00 2001 From: Yavor Ivanov Date: Wed, 16 Nov 2022 10:55:56 +0200 Subject: [PATCH 55/69] Fix test cases --- .../dest/resources/library/j/ValidPropertyDefaultValue.js | 4 ++-- .../library.j/main/src/library/j/ValidPropertyDefaultValue.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/test/expected/build/library.j/dest/resources/library/j/ValidPropertyDefaultValue.js b/test/expected/build/library.j/dest/resources/library/j/ValidPropertyDefaultValue.js index b54d5bb63..65d114399 100644 --- a/test/expected/build/library.j/dest/resources/library/j/ValidPropertyDefaultValue.js +++ b/test/expected/build/library.j/dest/resources/library/j/ValidPropertyDefaultValue.js @@ -159,7 +159,7 @@ sap.ui.define( * validPropertyDefaultValueArrPatternVarDef */ validPropertyDefaultValueArrPatternVarDef: { - type: "sap.external2.thirdparty", + type: "sap.external3.thirdparty", group: "Misc", defaultValue: arrPatternVarDef }, @@ -168,7 +168,7 @@ sap.ui.define( * validPropertyDefaultValueArrPatternVarDef */ validPropertyDefaultValueArrPatternVarDefNestedAndRenamed: { - type: "sap.external2.thirdparty.nested", + type: "sap.external3.thirdparty.nested", group: "Misc", defaultValue: arrPatternVarDefNestedAndRenamed } diff --git a/test/fixtures/library.j/main/src/library/j/ValidPropertyDefaultValue.js b/test/fixtures/library.j/main/src/library/j/ValidPropertyDefaultValue.js index b54d5bb63..65d114399 100644 --- a/test/fixtures/library.j/main/src/library/j/ValidPropertyDefaultValue.js +++ b/test/fixtures/library.j/main/src/library/j/ValidPropertyDefaultValue.js @@ -159,7 +159,7 @@ sap.ui.define( * validPropertyDefaultValueArrPatternVarDef */ validPropertyDefaultValueArrPatternVarDef: { - type: "sap.external2.thirdparty", + type: "sap.external3.thirdparty", group: "Misc", defaultValue: arrPatternVarDef }, @@ -168,7 +168,7 @@ sap.ui.define( * validPropertyDefaultValueArrPatternVarDef */ validPropertyDefaultValueArrPatternVarDefNestedAndRenamed: { - type: "sap.external2.thirdparty.nested", + type: "sap.external3.thirdparty.nested", group: "Misc", defaultValue: arrPatternVarDefNestedAndRenamed } From a6528f56f7e07bbd8c2f07b283152216168b8cb8 Mon Sep 17 00:00:00 2001 From: Yavor Ivanov Date: Wed, 16 Nov 2022 15:58:26 +0200 Subject: [PATCH 56/69] Fix tests --- .../dest/resources/library/j/ValidPropertyDefaultValue.js | 2 +- .../library.j/main/src/library/j/ValidPropertyDefaultValue.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/expected/build/library.j/dest/resources/library/j/ValidPropertyDefaultValue.js b/test/expected/build/library.j/dest/resources/library/j/ValidPropertyDefaultValue.js index 65d114399..e4a31fded 100644 --- a/test/expected/build/library.j/dest/resources/library/j/ValidPropertyDefaultValue.js +++ b/test/expected/build/library.j/dest/resources/library/j/ValidPropertyDefaultValue.js @@ -132,7 +132,7 @@ sap.ui.define( * validPropertyDefaultValueArrPatternDeepDestruct */ validPropertyDefaultValueArrPatternDeepDestruct: { - type: "sap.external.thirdparty.arrWith.deep", + type: "sap.external.thirdparty.arrWith", group: "Misc", defaultValue: arrPatternDeepDestruct }, diff --git a/test/fixtures/library.j/main/src/library/j/ValidPropertyDefaultValue.js b/test/fixtures/library.j/main/src/library/j/ValidPropertyDefaultValue.js index 65d114399..e4a31fded 100644 --- a/test/fixtures/library.j/main/src/library/j/ValidPropertyDefaultValue.js +++ b/test/fixtures/library.j/main/src/library/j/ValidPropertyDefaultValue.js @@ -132,7 +132,7 @@ sap.ui.define( * validPropertyDefaultValueArrPatternDeepDestruct */ validPropertyDefaultValueArrPatternDeepDestruct: { - type: "sap.external.thirdparty.arrWith.deep", + type: "sap.external.thirdparty.arrWith", group: "Misc", defaultValue: arrPatternDeepDestruct }, From f53d53ddb6b750e1d17f4f7a8080f9edb5c15fb6 Mon Sep 17 00:00:00 2001 From: Yavor Ivanov Date: Wed, 16 Nov 2022 15:59:38 +0200 Subject: [PATCH 57/69] Fix for path resolving --- lib/processors/jsdoc/lib/ui5/plugin.cjs | 43 +++++++++++++++---------- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/lib/processors/jsdoc/lib/ui5/plugin.cjs b/lib/processors/jsdoc/lib/ui5/plugin.cjs index ba99a59e2..635ce8062 100644 --- a/lib/processors/jsdoc/lib/ui5/plugin.cjs +++ b/lib/processors/jsdoc/lib/ui5/plugin.cjs @@ -272,17 +272,27 @@ function analyzeModuleDefinition(node) { if ( [Syntax.ObjectPattern, Syntax.ArrayPattern].includes(currentModule.factory.params[i].type) ) { // ObjectPattern/ArrayPattern means destructuring of the parameter of a function names = resolveObjectPatternChain(currentModule.factory.params[i], null, []) - .map(({valueNode, keyNode, keyChain}) => { - let result = { original: keyNode.name, } - if (keyNode.name !== valueNode.name) { + .reduce((acc, {valueNode, keyNode, keyChain}) => { + const isRename = keyNode.name !== valueNode.name; + // keyChain > 1 means deep destructuring and we need to expose the outermost segment + // No renaming is possible in such case, so we don't need to take care of this + const isDeepDestructuring = keyChain.length > 1; + + let result = { original: keyNode.name, }; + if ( isRename ) { result.renamed = valueNode.name; } - if (keyChain.length > 1 || keyNode.name !== valueNode.name) { + if ( isDeepDestructuring ) { + acc.push({ original: keyChain[0] }); + } + if (isRename || isDeepDestructuring) { result.path = keyChain.join("."); } - return result; - }); + acc.push(result); + + return acc; + }, []); } else if (currentModule.factory.params[i].type === Syntax.Identifier) { // simple Identifier names = [{original: currentModule.factory.params[i].name}]; @@ -864,22 +874,21 @@ function resolveFullyQuantifiedName(node) { originalName = renamedChunks.join("."); } - // This is a destructured function argument. - // We'd need to determine the external module (getResolvedName() -> currentModule.localNames[]) - // and append it to the argument's name. - if ( !!getFuncArgumentDestructNode(curVar.defs[0]) ) { - const nameToResolve = renameMap[curVar.name] || curVar.name; - originalName = - [getResolvedName(nameToResolve, nameToResolve), originalName].join("."); - } else if (leftMostName) { + if (leftMostName) { originalName = leftMostName + "." + originalName; } } const originalNameChunks = originalName.split("."); - const resolvedNamespace = getResolvedName(originalNameChunks[0], originalNameChunks[0]).split("."); - - return resolvedNamespace.concat(originalNameChunks.slice(1)); + const nameToResolve = renameMap[originalNameChunks[0]] || originalNameChunks[0]; + const localName = currentModule.localNames[originalNameChunks[0]]; + if (localName && !localName.path) { + return [getResolvedName(nameToResolve, nameToResolve), originalName] + .join(".") + .split("."); + } else { + return getResolvedName(originalName, nameToResolve).split("."); + } } /** From 2c61a8214b85e3d0a24b52993a2cf386be3958f5 Mon Sep 17 00:00:00 2001 From: Yavor Ivanov Date: Wed, 16 Nov 2022 16:02:27 +0200 Subject: [PATCH 58/69] Enahnce with the new test cases --- .../library/j/designtime/api.json | 273 ++++++++++++++++++ 1 file changed, 273 insertions(+) diff --git a/test/expected/build/library.j/dest/test-resources/library/j/designtime/api.json b/test/expected/build/library.j/dest/test-resources/library/j/designtime/api.json index 181630a66..8f5bcaaa2 100644 --- a/test/expected/build/library.j/dest/test-resources/library/j/designtime/api.json +++ b/test/expected/build/library.j/dest/test-resources/library/j/designtime/api.json @@ -268,6 +268,18 @@ "setValidPropertyDefaultValueEnumChainedDestructuring" ] }, + { + "name": "validPropertyDefaultValueEnumNestedDestructuring", + "type": "library.j.core.AnotherValidEnum", + "defaultValue": "Buzz", + "group": "Misc", + "visibility": "public", + "description": "validPropertyDefaultValueEnumNestedDestructuring", + "methods": [ + "getValidPropertyDefaultValueEnumNestedDestructuring", + "setValidPropertyDefaultValueEnumNestedDestructuring" + ] + }, { "name": "validPropertyDefaultValueEnumDestructuringWithRename", "type": "library.j.core.AnotherValidEnum", @@ -327,6 +339,78 @@ "getValidPropertyDefaultValueEnumViaDestructuringGlobal", "setValidPropertyDefaultValueEnumViaDestructuringGlobal" ] + }, + { + "name": "validPropertyDefaultValueArrPattern", + "type": "sap.external.thirdparty", + "defaultValue": "arrPattern", + "group": "Misc", + "visibility": "public", + "description": "validPropertyDefaultValueArrPattern", + "methods": [ + "getValidPropertyDefaultValueArrPattern", + "setValidPropertyDefaultValueArrPattern" + ] + }, + { + "name": "validPropertyDefaultValueArrPatternDeepDestruct", + "type": "sap.external.thirdparty.arrWith", + "defaultValue": "deep", + "group": "Misc", + "visibility": "public", + "description": "validPropertyDefaultValueArrPatternDeepDestruct", + "methods": [ + "getValidPropertyDefaultValueArrPatternDeepDestruct", + "setValidPropertyDefaultValueArrPatternDeepDestruct" + ] + }, + { + "name": "validPropertyDefaultValueObjPatternDeepDestruct", + "type": "sap.external2.thirdparty.objPattern.deeply", + "defaultValue": "destructured", + "group": "Misc", + "visibility": "public", + "description": "validPropertyDefaultValueArrPatternDeepDestruct", + "methods": [ + "getValidPropertyDefaultValueObjPatternDeepDestruct", + "setValidPropertyDefaultValueObjPatternDeepDestruct" + ] + }, + { + "name": "validPropertyDefaultValueObjPatternNested", + "type": "sap.external2.thirdparty.objPattern", + "defaultValue": "objPattern1Lvl", + "group": "Misc", + "visibility": "public", + "description": "validPropertyDefaultValueObjPatternNested", + "methods": [ + "getValidPropertyDefaultValueObjPatternNested", + "setValidPropertyDefaultValueObjPatternNested" + ] + }, + { + "name": "validPropertyDefaultValueArrPatternVarDef", + "type": "sap.external3.thirdparty", + "defaultValue": "arrPatternVarDef", + "group": "Misc", + "visibility": "public", + "description": "validPropertyDefaultValueArrPatternVarDef", + "methods": [ + "getValidPropertyDefaultValueArrPatternVarDef", + "setValidPropertyDefaultValueArrPatternVarDef" + ] + }, + { + "name": "validPropertyDefaultValueArrPatternVarDefNestedAndRenamed", + "type": "sap.external3.thirdparty.nested", + "defaultValue": "arrPatternVarDef", + "group": "Misc", + "visibility": "public", + "description": "validPropertyDefaultValueArrPatternVarDef", + "methods": [ + "getValidPropertyDefaultValueArrPatternVarDefNestedAndRenamed", + "setValidPropertyDefaultValueArrPatternVarDefNestedAndRenamed" + ] } ] }, @@ -375,6 +459,42 @@ }, "description": "Returns a metadata object for class library.j.ValidPropertyDefaultValue." }, + { + "name": "getValidPropertyDefaultValueArrPattern", + "visibility": "public", + "returnValue": { + "type": "sap.external.thirdparty", + "description": "Value of property validPropertyDefaultValueArrPattern" + }, + "description": "Gets current value of property {@link #getValidPropertyDefaultValueArrPattern validPropertyDefaultValueArrPattern}.\n\nvalidPropertyDefaultValueArrPattern\n\nDefault value is arrPattern." + }, + { + "name": "getValidPropertyDefaultValueArrPatternDeepDestruct", + "visibility": "public", + "returnValue": { + "type": "sap.external.thirdparty.arrWith", + "description": "Value of property validPropertyDefaultValueArrPatternDeepDestruct" + }, + "description": "Gets current value of property {@link #getValidPropertyDefaultValueArrPatternDeepDestruct validPropertyDefaultValueArrPatternDeepDestruct}.\n\nvalidPropertyDefaultValueArrPatternDeepDestruct\n\nDefault value is deep." + }, + { + "name": "getValidPropertyDefaultValueArrPatternVarDef", + "visibility": "public", + "returnValue": { + "type": "sap.external3.thirdparty", + "description": "Value of property validPropertyDefaultValueArrPatternVarDef" + }, + "description": "Gets current value of property {@link #getValidPropertyDefaultValueArrPatternVarDef validPropertyDefaultValueArrPatternVarDef}.\n\nvalidPropertyDefaultValueArrPatternVarDef\n\nDefault value is arrPatternVarDef." + }, + { + "name": "getValidPropertyDefaultValueArrPatternVarDefNestedAndRenamed", + "visibility": "public", + "returnValue": { + "type": "sap.external3.thirdparty.nested", + "description": "Value of property validPropertyDefaultValueArrPatternVarDefNestedAndRenamed" + }, + "description": "Gets current value of property {@link #getValidPropertyDefaultValueArrPatternVarDefNestedAndRenamed validPropertyDefaultValueArrPatternVarDefNestedAndRenamed}.\n\nvalidPropertyDefaultValueArrPatternVarDef\n\nDefault value is arrPatternVarDef." + }, { "name": "getValidPropertyDefaultValueEnumChainedDestructuring", "visibility": "public", @@ -411,6 +531,15 @@ }, "description": "Gets current value of property {@link #getValidPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar validPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar}.\n\nvalidPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar\n\nDefault value is Value2." }, + { + "name": "getValidPropertyDefaultValueEnumNestedDestructuring", + "visibility": "public", + "returnValue": { + "type": "library.j.core.AnotherValidEnum", + "description": "Value of property validPropertyDefaultValueEnumNestedDestructuring" + }, + "description": "Gets current value of property {@link #getValidPropertyDefaultValueEnumNestedDestructuring validPropertyDefaultValueEnumNestedDestructuring}.\n\nvalidPropertyDefaultValueEnumNestedDestructuring\n\nDefault value is Buzz." + }, { "name": "getValidPropertyDefaultValueEnumSimpleDestructuring", "visibility": "public", @@ -438,6 +567,96 @@ }, "description": "Gets current value of property {@link #getValidPropertyDefaultValueEnumViaDestructuringInArrowFn validPropertyDefaultValueEnumViaDestructuringInArrowFn}.\n\nvalidPropertyDefaultValueEnumViaDestructuringInArrowFn\n\nDefault value is Foo." }, + { + "name": "getValidPropertyDefaultValueObjPatternDeepDestruct", + "visibility": "public", + "returnValue": { + "type": "sap.external2.thirdparty.objPattern.deeply", + "description": "Value of property validPropertyDefaultValueObjPatternDeepDestruct" + }, + "description": "Gets current value of property {@link #getValidPropertyDefaultValueObjPatternDeepDestruct validPropertyDefaultValueObjPatternDeepDestruct}.\n\nvalidPropertyDefaultValueArrPatternDeepDestruct\n\nDefault value is destructured." + }, + { + "name": "getValidPropertyDefaultValueObjPatternNested", + "visibility": "public", + "returnValue": { + "type": "sap.external2.thirdparty.objPattern", + "description": "Value of property validPropertyDefaultValueObjPatternNested" + }, + "description": "Gets current value of property {@link #getValidPropertyDefaultValueObjPatternNested validPropertyDefaultValueObjPatternNested}.\n\nvalidPropertyDefaultValueObjPatternNested\n\nDefault value is objPattern1Lvl." + }, + { + "name": "setValidPropertyDefaultValueArrPattern", + "visibility": "public", + "returnValue": { + "type": "this", + "description": "Reference to this in order to allow method chaining" + }, + "parameters": [ + { + "name": "sValidPropertyDefaultValueArrPattern", + "type": "sap.external.thirdparty", + "optional": true, + "defaultValue": "arrPattern", + "description": "New value for property validPropertyDefaultValueArrPattern" + } + ], + "description": "Sets a new value for property {@link #getValidPropertyDefaultValueArrPattern validPropertyDefaultValueArrPattern}.\n\nvalidPropertyDefaultValueArrPattern\n\nWhen called with a value of null or undefined, the default value of the property will be restored.\n\nDefault value is arrPattern." + }, + { + "name": "setValidPropertyDefaultValueArrPatternDeepDestruct", + "visibility": "public", + "returnValue": { + "type": "this", + "description": "Reference to this in order to allow method chaining" + }, + "parameters": [ + { + "name": "sValidPropertyDefaultValueArrPatternDeepDestruct", + "type": "sap.external.thirdparty.arrWith", + "optional": true, + "defaultValue": "deep", + "description": "New value for property validPropertyDefaultValueArrPatternDeepDestruct" + } + ], + "description": "Sets a new value for property {@link #getValidPropertyDefaultValueArrPatternDeepDestruct validPropertyDefaultValueArrPatternDeepDestruct}.\n\nvalidPropertyDefaultValueArrPatternDeepDestruct\n\nWhen called with a value of null or undefined, the default value of the property will be restored.\n\nDefault value is deep." + }, + { + "name": "setValidPropertyDefaultValueArrPatternVarDef", + "visibility": "public", + "returnValue": { + "type": "this", + "description": "Reference to this in order to allow method chaining" + }, + "parameters": [ + { + "name": "sValidPropertyDefaultValueArrPatternVarDef", + "type": "sap.external3.thirdparty", + "optional": true, + "defaultValue": "arrPatternVarDef", + "description": "New value for property validPropertyDefaultValueArrPatternVarDef" + } + ], + "description": "Sets a new value for property {@link #getValidPropertyDefaultValueArrPatternVarDef validPropertyDefaultValueArrPatternVarDef}.\n\nvalidPropertyDefaultValueArrPatternVarDef\n\nWhen called with a value of null or undefined, the default value of the property will be restored.\n\nDefault value is arrPatternVarDef." + }, + { + "name": "setValidPropertyDefaultValueArrPatternVarDefNestedAndRenamed", + "visibility": "public", + "returnValue": { + "type": "this", + "description": "Reference to this in order to allow method chaining" + }, + "parameters": [ + { + "name": "sValidPropertyDefaultValueArrPatternVarDefNestedAndRenamed", + "type": "sap.external3.thirdparty.nested", + "optional": true, + "defaultValue": "arrPatternVarDef", + "description": "New value for property validPropertyDefaultValueArrPatternVarDefNestedAndRenamed" + } + ], + "description": "Sets a new value for property {@link #getValidPropertyDefaultValueArrPatternVarDefNestedAndRenamed validPropertyDefaultValueArrPatternVarDefNestedAndRenamed}.\n\nvalidPropertyDefaultValueArrPatternVarDef\n\nWhen called with a value of null or undefined, the default value of the property will be restored.\n\nDefault value is arrPatternVarDef." + }, { "name": "setValidPropertyDefaultValueEnumChainedDestructuring", "visibility": "public", @@ -510,6 +729,24 @@ ], "description": "Sets a new value for property {@link #getValidPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar validPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar}.\n\nvalidPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar\n\nWhen called with a value of null or undefined, the default value of the property will be restored.\n\nDefault value is Value2." }, + { + "name": "setValidPropertyDefaultValueEnumNestedDestructuring", + "visibility": "public", + "returnValue": { + "type": "this", + "description": "Reference to this in order to allow method chaining" + }, + "parameters": [ + { + "name": "sValidPropertyDefaultValueEnumNestedDestructuring", + "type": "library.j.core.AnotherValidEnum", + "optional": true, + "defaultValue": "Buzz", + "description": "New value for property validPropertyDefaultValueEnumNestedDestructuring" + } + ], + "description": "Sets a new value for property {@link #getValidPropertyDefaultValueEnumNestedDestructuring validPropertyDefaultValueEnumNestedDestructuring}.\n\nvalidPropertyDefaultValueEnumNestedDestructuring\n\nWhen called with a value of null or undefined, the default value of the property will be restored.\n\nDefault value is Buzz." + }, { "name": "setValidPropertyDefaultValueEnumSimpleDestructuring", "visibility": "public", @@ -563,6 +800,42 @@ } ], "description": "Sets a new value for property {@link #getValidPropertyDefaultValueEnumViaDestructuringInArrowFn validPropertyDefaultValueEnumViaDestructuringInArrowFn}.\n\nvalidPropertyDefaultValueEnumViaDestructuringInArrowFn\n\nWhen called with a value of null or undefined, the default value of the property will be restored.\n\nDefault value is Foo." + }, + { + "name": "setValidPropertyDefaultValueObjPatternDeepDestruct", + "visibility": "public", + "returnValue": { + "type": "this", + "description": "Reference to this in order to allow method chaining" + }, + "parameters": [ + { + "name": "sValidPropertyDefaultValueObjPatternDeepDestruct", + "type": "sap.external2.thirdparty.objPattern.deeply", + "optional": true, + "defaultValue": "destructured", + "description": "New value for property validPropertyDefaultValueObjPatternDeepDestruct" + } + ], + "description": "Sets a new value for property {@link #getValidPropertyDefaultValueObjPatternDeepDestruct validPropertyDefaultValueObjPatternDeepDestruct}.\n\nvalidPropertyDefaultValueArrPatternDeepDestruct\n\nWhen called with a value of null or undefined, the default value of the property will be restored.\n\nDefault value is destructured." + }, + { + "name": "setValidPropertyDefaultValueObjPatternNested", + "visibility": "public", + "returnValue": { + "type": "this", + "description": "Reference to this in order to allow method chaining" + }, + "parameters": [ + { + "name": "sValidPropertyDefaultValueObjPatternNested", + "type": "sap.external2.thirdparty.objPattern", + "optional": true, + "defaultValue": "objPattern1Lvl", + "description": "New value for property validPropertyDefaultValueObjPatternNested" + } + ], + "description": "Sets a new value for property {@link #getValidPropertyDefaultValueObjPatternNested validPropertyDefaultValueObjPatternNested}.\n\nvalidPropertyDefaultValueObjPatternNested\n\nWhen called with a value of null or undefined, the default value of the property will be restored.\n\nDefault value is objPattern1Lvl." } ] } From 9cff1210a9f9e3738efa443f9c6a6aa11f4991bc Mon Sep 17 00:00:00 2001 From: Yavor Ivanov Date: Thu, 17 Nov 2022 09:57:06 +0200 Subject: [PATCH 59/69] Add FunctionDeclaration && FunctionExpression --- lib/processors/jsdoc/lib/ui5/plugin.cjs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/processors/jsdoc/lib/ui5/plugin.cjs b/lib/processors/jsdoc/lib/ui5/plugin.cjs index 635ce8062..bb420c838 100644 --- a/lib/processors/jsdoc/lib/ui5/plugin.cjs +++ b/lib/processors/jsdoc/lib/ui5/plugin.cjs @@ -749,7 +749,13 @@ function resolvePotentialEnum(node, type) { * @returns {Node} */ function getFuncArgumentDestructNode(varDefinition) { - if (varDefinition.node.type === Syntax.ArrowFunctionExpression) { + if ( + [ + Syntax.ArrowFunctionExpression, + Syntax.FunctionDeclaration, + Syntax.FunctionExpression, + ].includes(varDefinition.node.type) + ) { return varDefinition.node.params[varDefinition.index]; } From 4fdc9171b5022b460f5070efcbcd36bea3d6731c Mon Sep 17 00:00:00 2001 From: Yavor Ivanov Date: Thu, 17 Nov 2022 14:20:50 +0200 Subject: [PATCH 60/69] Revise ArrayPattern handling --- lib/processors/jsdoc/lib/ui5/plugin.cjs | 40 ++++++++++--------------- 1 file changed, 16 insertions(+), 24 deletions(-) diff --git a/lib/processors/jsdoc/lib/ui5/plugin.cjs b/lib/processors/jsdoc/lib/ui5/plugin.cjs index bb420c838..9fb18630f 100644 --- a/lib/processors/jsdoc/lib/ui5/plugin.cjs +++ b/lib/processors/jsdoc/lib/ui5/plugin.cjs @@ -273,20 +273,16 @@ function analyzeModuleDefinition(node) { if ( [Syntax.ObjectPattern, Syntax.ArrayPattern].includes(currentModule.factory.params[i].type) ) { // ObjectPattern/ArrayPattern means destructuring of the parameter of a function names = resolveObjectPatternChain(currentModule.factory.params[i], null, []) .reduce((acc, {valueNode, keyNode, keyChain}) => { - const isRename = keyNode.name !== valueNode.name; - // keyChain > 1 means deep destructuring and we need to expose the outermost segment - // No renaming is possible in such case, so we don't need to take care of this - const isDeepDestructuring = keyChain.length > 1; + let result = { original: keyNode.name, path: keyChain.join(".") }; - let result = { original: keyNode.name, }; - if ( isRename ) { + if ( keyNode.name !== valueNode.name ) { // Renaming result.renamed = valueNode.name; } - if ( isDeepDestructuring ) { - acc.push({ original: keyChain[0] }); - } - if (isRename || isDeepDestructuring) { - result.path = keyChain.join("."); + + // keyChain > 1 means deep destructuring and we need to expose the outermost segment + // No renaming is possible in such case, so we don't need to take care of this + if ( keyChain.length > 1 ) { + acc.push({ original: keyChain[0], path: keyChain[0] }); } acc.push(result); @@ -704,7 +700,10 @@ function resolveObjectPatternChain (valueNode, keyNode, keyChain) { resolveObjectPatternChain( valueNode.elements[i], valueNode.elements[i], - keyChain ) + ( valueNode.elements[i].name + ? [...keyChain, valueNode.elements[i].name] + : keyChain ) + ) ); } } else { @@ -815,11 +814,11 @@ function checkVarRenaming(variable) { ({valueNode}) => valueNode.name === variable.name ); - if (resolvedOP && resolvedOP.keyNode.name !== resolvedOP.valueNode.name) { // There's a rename - let result = { original: resolvedOP.keyNode.name, renamed: resolvedOP.valueNode.name }; + if ( resolvedOP ) { + let result = { original: resolvedOP.keyNode.name, path: resolvedOP.keyChain.join(".") }; - if (resolvedOP.keyChain.length > 1 || resolvedOP.keyNode.name !== resolvedOP.valueNode.name) { - result.path = resolvedOP.keyChain.join("."); + if (resolvedOP.keyNode.name !== resolvedOP.valueNode.name) { + result.renamed = resolvedOP.valueNode.name; } return result; @@ -887,14 +886,7 @@ function resolveFullyQuantifiedName(node) { const originalNameChunks = originalName.split("."); const nameToResolve = renameMap[originalNameChunks[0]] || originalNameChunks[0]; - const localName = currentModule.localNames[originalNameChunks[0]]; - if (localName && !localName.path) { - return [getResolvedName(nameToResolve, nameToResolve), originalName] - .join(".") - .split("."); - } else { - return getResolvedName(originalName, nameToResolve).split("."); - } + return getResolvedName(originalName, nameToResolve).split("."); } /** From d547a6b51fdc775df33cdd2841dce657f39abd2d Mon Sep 17 00:00:00 2001 From: Yavor Ivanov Date: Thu, 17 Nov 2022 20:50:45 +0200 Subject: [PATCH 61/69] Include indices in the path for the ArrayPattern --- lib/processors/jsdoc/lib/ui5/plugin.cjs | 32 ++++++++++++++++--------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/lib/processors/jsdoc/lib/ui5/plugin.cjs b/lib/processors/jsdoc/lib/ui5/plugin.cjs index 9fb18630f..0de60700c 100644 --- a/lib/processors/jsdoc/lib/ui5/plugin.cjs +++ b/lib/processors/jsdoc/lib/ui5/plugin.cjs @@ -279,12 +279,6 @@ function analyzeModuleDefinition(node) { result.renamed = valueNode.name; } - // keyChain > 1 means deep destructuring and we need to expose the outermost segment - // No renaming is possible in such case, so we don't need to take care of this - if ( keyChain.length > 1 ) { - acc.push({ original: keyChain[0], path: keyChain[0] }); - } - acc.push(result); return acc; @@ -702,7 +696,7 @@ function resolveObjectPatternChain (valueNode, keyNode, keyChain) { valueNode.elements[i], ( valueNode.elements[i].name ? [...keyChain, valueNode.elements[i].name] - : keyChain ) + : [...keyChain, String(i)] ) ) ); } @@ -841,6 +835,17 @@ function resolveFullyQuantifiedName(node) { const currentScope = getEnclosingVariableScope(node); let renameMap = {}; + const buildResult = (name, namespace) => { + let result = getResolvedName(name, namespace); + // Cleanup the merge from getResolvedName(); + // Strips the redundant parts of the name in the path + name + if ( result.includes(name) && !result.endsWith(name) ) { + result = result.replace(name.slice(name.indexOf(".")), ""); + } + + return result.split("."); + }; + if (!currentScope) { return null; } @@ -854,7 +859,7 @@ function resolveFullyQuantifiedName(node) { if ( !isVarDestructuring(curVar) ) { // Not a destructuring - return getResolvedName(originalName, leftMostName).split("."); + return buildResult(originalName, leftMostName); } const potentialRenaming = checkVarRenaming(curVar); @@ -872,7 +877,8 @@ function resolveFullyQuantifiedName(node) { })[0]; if (potentialRenaming) { - renameMap[potentialRenaming.original] = potentialRenaming.renamed; + renameMap[potentialRenaming.path || potentialRenaming.original] = + potentialRenaming.renamed /* local name */ || potentialRenaming.original /* no renaming */; const renamedChunks = originalName.split("."); renamedChunks.splice(0, 1, potentialRenaming.path || potentialRenaming.original); @@ -885,8 +891,12 @@ function resolveFullyQuantifiedName(node) { } const originalNameChunks = originalName.split("."); - const nameToResolve = renameMap[originalNameChunks[0]] || originalNameChunks[0]; - return getResolvedName(originalName, nameToResolve).split("."); + const nameToResolve = + renameMap[originalNameChunks[0]] || + renameMap[originalName] || + originalNameChunks[0]; + + return buildResult(originalName, nameToResolve); } /** From 41f8f589117937d20f1a9f396c31ae5228560552 Mon Sep 17 00:00:00 2001 From: Yavor Ivanov Date: Thu, 17 Nov 2022 20:51:05 +0200 Subject: [PATCH 62/69] Fix test cases for ArrayPattern --- .../resources/library/j/ValidPropertyDefaultValue.js | 4 ++-- .../test-resources/library/j/designtime/api.json | 12 ++++++------ .../main/src/library/j/ValidPropertyDefaultValue.js | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/test/expected/build/library.j/dest/resources/library/j/ValidPropertyDefaultValue.js b/test/expected/build/library.j/dest/resources/library/j/ValidPropertyDefaultValue.js index e4a31fded..7a3b66a89 100644 --- a/test/expected/build/library.j/dest/resources/library/j/ValidPropertyDefaultValue.js +++ b/test/expected/build/library.j/dest/resources/library/j/ValidPropertyDefaultValue.js @@ -132,7 +132,7 @@ sap.ui.define( * validPropertyDefaultValueArrPatternDeepDestruct */ validPropertyDefaultValueArrPatternDeepDestruct: { - type: "sap.external.thirdparty.arrWith", + type: "sap.external.thirdparty.1.arrWith", group: "Misc", defaultValue: arrPatternDeepDestruct }, @@ -168,7 +168,7 @@ sap.ui.define( * validPropertyDefaultValueArrPatternVarDef */ validPropertyDefaultValueArrPatternVarDefNestedAndRenamed: { - type: "sap.external3.thirdparty.nested", + type: "sap.external3.thirdparty.1.nested", group: "Misc", defaultValue: arrPatternVarDefNestedAndRenamed } diff --git a/test/expected/build/library.j/dest/test-resources/library/j/designtime/api.json b/test/expected/build/library.j/dest/test-resources/library/j/designtime/api.json index 8f5bcaaa2..eb9116177 100644 --- a/test/expected/build/library.j/dest/test-resources/library/j/designtime/api.json +++ b/test/expected/build/library.j/dest/test-resources/library/j/designtime/api.json @@ -354,7 +354,7 @@ }, { "name": "validPropertyDefaultValueArrPatternDeepDestruct", - "type": "sap.external.thirdparty.arrWith", + "type": "sap.external.thirdparty.1.arrWith", "defaultValue": "deep", "group": "Misc", "visibility": "public", @@ -402,7 +402,7 @@ }, { "name": "validPropertyDefaultValueArrPatternVarDefNestedAndRenamed", - "type": "sap.external3.thirdparty.nested", + "type": "sap.external3.thirdparty.1.nested", "defaultValue": "arrPatternVarDef", "group": "Misc", "visibility": "public", @@ -472,7 +472,7 @@ "name": "getValidPropertyDefaultValueArrPatternDeepDestruct", "visibility": "public", "returnValue": { - "type": "sap.external.thirdparty.arrWith", + "type": "sap.external.thirdparty.1.arrWith", "description": "Value of property validPropertyDefaultValueArrPatternDeepDestruct" }, "description": "Gets current value of property {@link #getValidPropertyDefaultValueArrPatternDeepDestruct validPropertyDefaultValueArrPatternDeepDestruct}.\n\nvalidPropertyDefaultValueArrPatternDeepDestruct\n\nDefault value is deep." @@ -490,7 +490,7 @@ "name": "getValidPropertyDefaultValueArrPatternVarDefNestedAndRenamed", "visibility": "public", "returnValue": { - "type": "sap.external3.thirdparty.nested", + "type": "sap.external3.thirdparty.1.nested", "description": "Value of property validPropertyDefaultValueArrPatternVarDefNestedAndRenamed" }, "description": "Gets current value of property {@link #getValidPropertyDefaultValueArrPatternVarDefNestedAndRenamed validPropertyDefaultValueArrPatternVarDefNestedAndRenamed}.\n\nvalidPropertyDefaultValueArrPatternVarDef\n\nDefault value is arrPatternVarDef." @@ -613,7 +613,7 @@ "parameters": [ { "name": "sValidPropertyDefaultValueArrPatternDeepDestruct", - "type": "sap.external.thirdparty.arrWith", + "type": "sap.external.thirdparty.1.arrWith", "optional": true, "defaultValue": "deep", "description": "New value for property validPropertyDefaultValueArrPatternDeepDestruct" @@ -649,7 +649,7 @@ "parameters": [ { "name": "sValidPropertyDefaultValueArrPatternVarDefNestedAndRenamed", - "type": "sap.external3.thirdparty.nested", + "type": "sap.external3.thirdparty.1.nested", "optional": true, "defaultValue": "arrPatternVarDef", "description": "New value for property validPropertyDefaultValueArrPatternVarDefNestedAndRenamed" diff --git a/test/fixtures/library.j/main/src/library/j/ValidPropertyDefaultValue.js b/test/fixtures/library.j/main/src/library/j/ValidPropertyDefaultValue.js index e4a31fded..7a3b66a89 100644 --- a/test/fixtures/library.j/main/src/library/j/ValidPropertyDefaultValue.js +++ b/test/fixtures/library.j/main/src/library/j/ValidPropertyDefaultValue.js @@ -132,7 +132,7 @@ sap.ui.define( * validPropertyDefaultValueArrPatternDeepDestruct */ validPropertyDefaultValueArrPatternDeepDestruct: { - type: "sap.external.thirdparty.arrWith", + type: "sap.external.thirdparty.1.arrWith", group: "Misc", defaultValue: arrPatternDeepDestruct }, @@ -168,7 +168,7 @@ sap.ui.define( * validPropertyDefaultValueArrPatternVarDef */ validPropertyDefaultValueArrPatternVarDefNestedAndRenamed: { - type: "sap.external3.thirdparty.nested", + type: "sap.external3.thirdparty.1.nested", group: "Misc", defaultValue: arrPatternVarDefNestedAndRenamed } From 171746eef68a32489a30dfbd0b87b1b3a499794a Mon Sep 17 00:00:00 2001 From: Yavor Ivanov Date: Thu, 24 Nov 2022 10:09:47 +0200 Subject: [PATCH 63/69] Refactor resolveFullyQuantifiedName() --- lib/processors/jsdoc/lib/ui5/plugin.cjs | 89 +++++++++++-------------- 1 file changed, 39 insertions(+), 50 deletions(-) diff --git a/lib/processors/jsdoc/lib/ui5/plugin.cjs b/lib/processors/jsdoc/lib/ui5/plugin.cjs index 0de60700c..d4de21d20 100644 --- a/lib/processors/jsdoc/lib/ui5/plugin.cjs +++ b/lib/processors/jsdoc/lib/ui5/plugin.cjs @@ -694,6 +694,7 @@ function resolveObjectPatternChain (valueNode, keyNode, keyChain) { resolveObjectPatternChain( valueNode.elements[i], valueNode.elements[i], + // TODO: not a valid case. Check it! ( valueNode.elements[i].name ? [...keyChain, valueNode.elements[i].name] : [...keyChain, String(i)] ) @@ -715,15 +716,7 @@ function resolveObjectPatternChain (valueNode, keyNode, keyChain) { * @returns {Object} */ function resolvePotentialEnum(node, type) { - const varsDestructuringStack = resolveFullyQuantifiedName(node); - - if (!varsDestructuringStack || !varsDestructuringStack.length) { - return null; - } - - // When the fully quantified name gets resolved, we could try the "old" approach by checking - // the type + key - let value = varsDestructuringStack.join("."); + let value = resolveFullyQuantifiedName(node); if ( value.startsWith(type + ".") ) { // starts with fully qualified enum name -> cut off name @@ -793,9 +786,9 @@ function checkVarRenaming(variable) { // // So, we'd not able to analyze which "a" to which console.log to map if ( - !variable || !variable.defs - || (variable.defs && variable.defs.length !== 1) - || !isVarDestructuring(variable) + !variable + || !variable.defs + || variable.defs.length !== 1 ) { return null; } @@ -833,18 +826,6 @@ function resolveFullyQuantifiedName(node) { let leftMostName = getLeftmostName(node); let originalName = getObjectName(node) || ""; const currentScope = getEnclosingVariableScope(node); - let renameMap = {}; - - const buildResult = (name, namespace) => { - let result = getResolvedName(name, namespace); - // Cleanup the merge from getResolvedName(); - // Strips the redundant parts of the name in the path + name - if ( result.includes(name) && !result.endsWith(name) ) { - result = result.replace(name.slice(name.indexOf(".")), ""); - } - - return result.split("."); - }; if (!currentScope) { return null; @@ -859,44 +840,52 @@ function resolveFullyQuantifiedName(node) { if ( !isVarDestructuring(curVar) ) { // Not a destructuring - return buildResult(originalName, leftMostName); + return getResolvedName(originalName, leftMostName); } const potentialRenaming = checkVarRenaming(curVar); - leftMostName = curVar.references - .filter((ref) => ref.writeExpr) - .map((ref) => { - const curNode = ref.writeExpr; - if ( curNode.type === Syntax.MemberExpression && !curNode.computed && curNode.object.type === Syntax.Identifier ) { - return curNode.object.name; - } else if (curNode.type === Syntax.MemberExpression && curNode.object.type === Syntax.MemberExpression) { // Standalone variable without leading dot notation namespace - return getResolvedObjectName(curNode); - } - - return (curNode && curNode.name) || ""; - })[0]; - if (potentialRenaming) { - renameMap[potentialRenaming.path || potentialRenaming.original] = - potentialRenaming.renamed /* local name */ || potentialRenaming.original /* no renaming */; + let renamedChunks = originalName.split("."); + renamedChunks = getResolvedName( originalName, renamedChunks[0] ).split("."); + + // when getResolvedName() was not able to resolve the renaming of a variable + // with currentModule.localNames[].path i.e. in "chained" destructuring where + // the variable is not within localNames registry + if ( potentialRenaming.renamed === renamedChunks[0] ) { + renamedChunks.splice(0, 1, potentialRenaming.path || potentialRenaming.original); + } - const renamedChunks = originalName.split("."); - renamedChunks.splice(0, 1, potentialRenaming.path || potentialRenaming.original); originalName = renamedChunks.join("."); } + const writeExpr = curVar.references.filter((ref) => ref.writeExpr); + + // The same case as variable.defs- we're not able to determine the correct chain in case of multiple writeExpr + if (writeExpr.length !== 1) { + break; + } + + const writeExprNode = writeExpr[0].writeExpr; + + if ( writeExprNode.type === Syntax.MemberExpression && !writeExprNode.computed && writeExprNode.object.type === Syntax.Identifier ) { + leftMostName = writeExprNode.object.name; + + } else if (writeExprNode.type === Syntax.MemberExpression && writeExprNode.object.type === Syntax.MemberExpression) { // Standalone variable without leading dot notation namespace + leftMostName = getResolvedObjectName(writeExprNode); + + } else if (writeExprNode.type === Syntax.Identifier) { + leftMostName = writeExprNode.name; + + } else { + leftMostName = ""; + } + if (leftMostName) { originalName = leftMostName + "." + originalName; } } - const originalNameChunks = originalName.split("."); - const nameToResolve = - renameMap[originalNameChunks[0]] || - renameMap[originalName] || - originalNameChunks[0]; - - return buildResult(originalName, nameToResolve); + return originalName; } /** @@ -1052,7 +1041,7 @@ function convertValueWithRaw(node, type, propertyName) { }; } - // This could be an ENUM which has been destructed up to the entity part. In that case the node.type === Syntax.Identifier + // This could be an ENUM which has been destructured up to the enum value part. In that case the node.type === Syntax.Identifier // For example, the `Solid` const in the following snippet: // sap.ui.define(["sap/m/library"], ( { BackgroundDesign } ) => { // const { Solid } = BackgroundDesign; From a9761bda9291e91b5fcb20db2f7376dbecf31a4e Mon Sep 17 00:00:00 2001 From: Yavor Ivanov Date: Thu, 24 Nov 2022 10:41:22 +0200 Subject: [PATCH 64/69] Refactor resolveObjectPatternChain() --- lib/processors/jsdoc/lib/ui5/plugin.cjs | 40 ++++++++----------------- 1 file changed, 13 insertions(+), 27 deletions(-) diff --git a/lib/processors/jsdoc/lib/ui5/plugin.cjs b/lib/processors/jsdoc/lib/ui5/plugin.cjs index d4de21d20..fc5d509f0 100644 --- a/lib/processors/jsdoc/lib/ui5/plugin.cjs +++ b/lib/processors/jsdoc/lib/ui5/plugin.cjs @@ -271,18 +271,7 @@ function analyzeModuleDefinition(node) { let names = []; if ( [Syntax.ObjectPattern, Syntax.ArrayPattern].includes(currentModule.factory.params[i].type) ) { // ObjectPattern/ArrayPattern means destructuring of the parameter of a function - names = resolveObjectPatternChain(currentModule.factory.params[i], null, []) - .reduce((acc, {valueNode, keyNode, keyChain}) => { - let result = { original: keyNode.name, path: keyChain.join(".") }; - - if ( keyNode.name !== valueNode.name ) { // Renaming - result.renamed = valueNode.name; - } - - acc.push(result); - - return acc; - }, []); + names = resolveObjectPatternChain(currentModule.factory.params[i], null, []); } else if (currentModule.factory.params[i].type === Syntax.Identifier) { // simple Identifier names = [{original: currentModule.factory.params[i].name}]; @@ -702,7 +691,15 @@ function resolveObjectPatternChain (valueNode, keyNode, keyChain) { ); } } else { - chainSequence.push({ valueNode, keyNode, keyChain }); + + let result = { original: keyNode.name, path: keyChain.join(".") }; + + if (keyNode.name !== valueNode.name) { + // Renaming + result.renamed = valueNode.name; + } + + chainSequence.push(result); } return chainSequence; @@ -797,21 +794,10 @@ function checkVarRenaming(variable) { const defNode = getFuncArgumentDestructNode(varDefinition) // (arrow) function argument || varDefinition.node.id; // variable definition - const resolvedOP = resolveObjectPatternChain(defNode, null, []).find( - ({valueNode}) => valueNode.name === variable.name + return resolveObjectPatternChain(defNode, null, []).find( + ({ original, renamed }) => + renamed === variable.name || original === variable.name ); - - if ( resolvedOP ) { - let result = { original: resolvedOP.keyNode.name, path: resolvedOP.keyChain.join(".") }; - - if (resolvedOP.keyNode.name !== resolvedOP.valueNode.name) { - result.renamed = resolvedOP.valueNode.name; - } - - return result; - } else { - return null; - } }; /** From 41d4e20f5f6968da44e7bebcb313befa487341c5 Mon Sep 17 00:00:00 2001 From: Yavor Ivanov Date: Thu, 24 Nov 2022 14:07:30 +0200 Subject: [PATCH 65/69] Remove names from ArrayPattern: makes no sense --- lib/processors/jsdoc/lib/ui5/plugin.cjs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/processors/jsdoc/lib/ui5/plugin.cjs b/lib/processors/jsdoc/lib/ui5/plugin.cjs index fc5d509f0..36196229b 100644 --- a/lib/processors/jsdoc/lib/ui5/plugin.cjs +++ b/lib/processors/jsdoc/lib/ui5/plugin.cjs @@ -683,10 +683,7 @@ function resolveObjectPatternChain (valueNode, keyNode, keyChain) { resolveObjectPatternChain( valueNode.elements[i], valueNode.elements[i], - // TODO: not a valid case. Check it! - ( valueNode.elements[i].name - ? [...keyChain, valueNode.elements[i].name] - : [...keyChain, String(i)] ) + [...keyChain, String(i)] ) ); } @@ -835,10 +832,14 @@ function resolveFullyQuantifiedName(node) { renamedChunks = getResolvedName( originalName, renamedChunks[0] ).split("."); // when getResolvedName() was not able to resolve the renaming of a variable - // with currentModule.localNames[].path i.e. in "chained" destructuring where + // with currentModule.localNames[].path i.e. in "chained" destructuring, where // the variable is not within localNames registry - if ( potentialRenaming.renamed === renamedChunks[0] ) { - renamedChunks.splice(0, 1, potentialRenaming.path || potentialRenaming.original); + if ( potentialRenaming.renamed === renamedChunks[0] ) { // Checks for direct renaming + renamedChunks.splice(0, 1, potentialRenaming.original); + } + // Considers the 'path' if it differs from the original name i.e. there's some namespace before it + if ( potentialRenaming.original === renamedChunks[0] && potentialRenaming.path !== potentialRenaming.original ) { + renamedChunks.splice(0, 1, potentialRenaming.path); } originalName = renamedChunks.join("."); From 5a6b32831bdcbf03668d7d239501f978006bf9a5 Mon Sep 17 00:00:00 2001 From: Yavor Ivanov Date: Thu, 24 Nov 2022 14:07:43 +0200 Subject: [PATCH 66/69] Fix tests --- .../resources/library/j/ValidPropertyDefaultValue.js | 8 ++++---- .../test-resources/library/j/designtime/api.json | 12 ++++++------ .../main/src/library/j/ValidPropertyDefaultValue.js | 8 ++++---- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/test/expected/build/library.j/dest/resources/library/j/ValidPropertyDefaultValue.js b/test/expected/build/library.j/dest/resources/library/j/ValidPropertyDefaultValue.js index 7a3b66a89..61dbf44db 100644 --- a/test/expected/build/library.j/dest/resources/library/j/ValidPropertyDefaultValue.js +++ b/test/expected/build/library.j/dest/resources/library/j/ValidPropertyDefaultValue.js @@ -14,7 +14,7 @@ sap.ui.define( Control, { MyValidEnum, ThisIsEnumToo: RenamedEnum }, coreLibrary, - [arrPattern, {arrWith: {deep: arrPatternDeepDestruct}}], + [ {arrPattern}, {arrWith: {deep: arrPatternDeepDestruct}}], { objPattern: {deeply: {destructured: objPatternDeepDestruct}, objPattern1Lvl} }, libraryExt ) => { @@ -24,7 +24,7 @@ sap.ui.define( const { AnotherValidEnum: AnotherRenamedEnum } = coreLibrary; const { H1 } = sap.ui.core.TitleLevel; const { Value2: RenamedValue2 } = RenamedEnum; - const [ arrPatternVarDef, {nested: {arrPatternVarDef: arrPatternVarDefNestedAndRenamed}} ] = libraryExt; + const [ {arrPatternVarDef}, {nested: {arrPatternVarDef: arrPatternVarDefNestedAndRenamed}} ] = libraryExt; /** * @class @@ -123,7 +123,7 @@ sap.ui.define( * validPropertyDefaultValueArrPattern */ validPropertyDefaultValueArrPattern: { - type: "sap.external.thirdparty", + type: "sap.external.thirdparty.0", group: "Misc", defaultValue: arrPattern }, @@ -159,7 +159,7 @@ sap.ui.define( * validPropertyDefaultValueArrPatternVarDef */ validPropertyDefaultValueArrPatternVarDef: { - type: "sap.external3.thirdparty", + type: "sap.external3.thirdparty.0", group: "Misc", defaultValue: arrPatternVarDef }, diff --git a/test/expected/build/library.j/dest/test-resources/library/j/designtime/api.json b/test/expected/build/library.j/dest/test-resources/library/j/designtime/api.json index eb9116177..c58991419 100644 --- a/test/expected/build/library.j/dest/test-resources/library/j/designtime/api.json +++ b/test/expected/build/library.j/dest/test-resources/library/j/designtime/api.json @@ -342,7 +342,7 @@ }, { "name": "validPropertyDefaultValueArrPattern", - "type": "sap.external.thirdparty", + "type": "sap.external.thirdparty.0", "defaultValue": "arrPattern", "group": "Misc", "visibility": "public", @@ -390,7 +390,7 @@ }, { "name": "validPropertyDefaultValueArrPatternVarDef", - "type": "sap.external3.thirdparty", + "type": "sap.external3.thirdparty.0", "defaultValue": "arrPatternVarDef", "group": "Misc", "visibility": "public", @@ -463,7 +463,7 @@ "name": "getValidPropertyDefaultValueArrPattern", "visibility": "public", "returnValue": { - "type": "sap.external.thirdparty", + "type": "sap.external.thirdparty.0", "description": "Value of property validPropertyDefaultValueArrPattern" }, "description": "Gets current value of property {@link #getValidPropertyDefaultValueArrPattern validPropertyDefaultValueArrPattern}.\n\nvalidPropertyDefaultValueArrPattern\n\nDefault value is arrPattern." @@ -481,7 +481,7 @@ "name": "getValidPropertyDefaultValueArrPatternVarDef", "visibility": "public", "returnValue": { - "type": "sap.external3.thirdparty", + "type": "sap.external3.thirdparty.0", "description": "Value of property validPropertyDefaultValueArrPatternVarDef" }, "description": "Gets current value of property {@link #getValidPropertyDefaultValueArrPatternVarDef validPropertyDefaultValueArrPatternVarDef}.\n\nvalidPropertyDefaultValueArrPatternVarDef\n\nDefault value is arrPatternVarDef." @@ -595,7 +595,7 @@ "parameters": [ { "name": "sValidPropertyDefaultValueArrPattern", - "type": "sap.external.thirdparty", + "type": "sap.external.thirdparty.0", "optional": true, "defaultValue": "arrPattern", "description": "New value for property validPropertyDefaultValueArrPattern" @@ -631,7 +631,7 @@ "parameters": [ { "name": "sValidPropertyDefaultValueArrPatternVarDef", - "type": "sap.external3.thirdparty", + "type": "sap.external3.thirdparty.0", "optional": true, "defaultValue": "arrPatternVarDef", "description": "New value for property validPropertyDefaultValueArrPatternVarDef" diff --git a/test/fixtures/library.j/main/src/library/j/ValidPropertyDefaultValue.js b/test/fixtures/library.j/main/src/library/j/ValidPropertyDefaultValue.js index 7a3b66a89..61dbf44db 100644 --- a/test/fixtures/library.j/main/src/library/j/ValidPropertyDefaultValue.js +++ b/test/fixtures/library.j/main/src/library/j/ValidPropertyDefaultValue.js @@ -14,7 +14,7 @@ sap.ui.define( Control, { MyValidEnum, ThisIsEnumToo: RenamedEnum }, coreLibrary, - [arrPattern, {arrWith: {deep: arrPatternDeepDestruct}}], + [ {arrPattern}, {arrWith: {deep: arrPatternDeepDestruct}}], { objPattern: {deeply: {destructured: objPatternDeepDestruct}, objPattern1Lvl} }, libraryExt ) => { @@ -24,7 +24,7 @@ sap.ui.define( const { AnotherValidEnum: AnotherRenamedEnum } = coreLibrary; const { H1 } = sap.ui.core.TitleLevel; const { Value2: RenamedValue2 } = RenamedEnum; - const [ arrPatternVarDef, {nested: {arrPatternVarDef: arrPatternVarDefNestedAndRenamed}} ] = libraryExt; + const [ {arrPatternVarDef}, {nested: {arrPatternVarDef: arrPatternVarDefNestedAndRenamed}} ] = libraryExt; /** * @class @@ -123,7 +123,7 @@ sap.ui.define( * validPropertyDefaultValueArrPattern */ validPropertyDefaultValueArrPattern: { - type: "sap.external.thirdparty", + type: "sap.external.thirdparty.0", group: "Misc", defaultValue: arrPattern }, @@ -159,7 +159,7 @@ sap.ui.define( * validPropertyDefaultValueArrPatternVarDef */ validPropertyDefaultValueArrPatternVarDef: { - type: "sap.external3.thirdparty", + type: "sap.external3.thirdparty.0", group: "Misc", defaultValue: arrPatternVarDef }, From f4db252e99d9248bdb8b19c41981f709ea7394cc Mon Sep 17 00:00:00 2001 From: Yavor Ivanov Date: Thu, 24 Nov 2022 14:27:47 +0200 Subject: [PATCH 67/69] Aquire proper scope (bugfix) --- lib/processors/jsdoc/lib/ui5/plugin.cjs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/processors/jsdoc/lib/ui5/plugin.cjs b/lib/processors/jsdoc/lib/ui5/plugin.cjs index 36196229b..ce6d5a8c8 100644 --- a/lib/processors/jsdoc/lib/ui5/plugin.cjs +++ b/lib/processors/jsdoc/lib/ui5/plugin.cjs @@ -894,8 +894,11 @@ function resolveFullyQuantifiedName(node) { nearestScope = scopeManager.acquire(nearestScopeableNode); } - // Get the scope of the nearest scopeable node - return nearestScope; + // FunctionExpression with a name hold the value of the name in its scope. + // So, we need to unwrap to get to the real scope with var definitions + return nearestScope.functionExpressionScope + ? nearestScope.childScopes[0] + : nearestScope; }; function isCompileTimeConstant(node) { From 98875ae8c72a359207d9fd7c61904b478eb4a1bb Mon Sep 17 00:00:00 2001 From: Yavor Ivanov Date: Mon, 28 Nov 2022 09:47:21 +0200 Subject: [PATCH 68/69] Formatting fixes & minor refactoring --- lib/processors/jsdoc/lib/ui5/plugin.cjs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/processors/jsdoc/lib/ui5/plugin.cjs b/lib/processors/jsdoc/lib/ui5/plugin.cjs index ce6d5a8c8..fc19d1ad6 100644 --- a/lib/processors/jsdoc/lib/ui5/plugin.cjs +++ b/lib/processors/jsdoc/lib/ui5/plugin.cjs @@ -700,7 +700,7 @@ function resolveObjectPatternChain (valueNode, keyNode, keyChain) { } return chainSequence; -}; +} /** * Tries to resolve an ENUM, regardless where it is defined and being destructured. @@ -795,7 +795,7 @@ function checkVarRenaming(variable) { ({ original, renamed }) => renamed === variable.name || original === variable.name ); -}; +} /** * Builds the fully quantified name when there's a destructuring of a variable @@ -835,11 +835,11 @@ function resolveFullyQuantifiedName(node) { // with currentModule.localNames[].path i.e. in "chained" destructuring, where // the variable is not within localNames registry if ( potentialRenaming.renamed === renamedChunks[0] ) { // Checks for direct renaming - renamedChunks.splice(0, 1, potentialRenaming.original); + renamedChunks[0] = potentialRenaming.original; } // Considers the 'path' if it differs from the original name i.e. there's some namespace before it if ( potentialRenaming.original === renamedChunks[0] && potentialRenaming.path !== potentialRenaming.original ) { - renamedChunks.splice(0, 1, potentialRenaming.path); + renamedChunks[0] = potentialRenaming.path; } originalName = renamedChunks.join("."); @@ -849,7 +849,9 @@ function resolveFullyQuantifiedName(node) { // The same case as variable.defs- we're not able to determine the correct chain in case of multiple writeExpr if (writeExpr.length !== 1) { - break; + // writeExpr.length === 0 means an function argument and then we need + // just to return the already build originalName + return writeExpr.length === 0 ? originalName : ""; } const writeExprNode = writeExpr[0].writeExpr; @@ -899,7 +901,7 @@ function resolveFullyQuantifiedName(node) { return nearestScope.functionExpressionScope ? nearestScope.childScopes[0] : nearestScope; -}; +} function isCompileTimeConstant(node) { return node && node.type === Syntax.Literal; From fd369cffddfa31b738f0fb504755589499edba67 Mon Sep 17 00:00:00 2001 From: Yavor Ivanov Date: Mon, 28 Nov 2022 20:49:53 +0200 Subject: [PATCH 69/69] Consistent returns --- lib/processors/jsdoc/lib/ui5/plugin.cjs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/processors/jsdoc/lib/ui5/plugin.cjs b/lib/processors/jsdoc/lib/ui5/plugin.cjs index fc19d1ad6..b762e130f 100644 --- a/lib/processors/jsdoc/lib/ui5/plugin.cjs +++ b/lib/processors/jsdoc/lib/ui5/plugin.cjs @@ -801,7 +801,7 @@ function checkVarRenaming(variable) { * Builds the fully quantified name when there's a destructuring of a variable * * @param {Node} node - * @returns {Object} + * @returns {string} */ function resolveFullyQuantifiedName(node) { // The missing part is on the left side. The right side is clear. @@ -811,7 +811,7 @@ function resolveFullyQuantifiedName(node) { const currentScope = getEnclosingVariableScope(node); if (!currentScope) { - return null; + return ""; } while (leftMostName) {