Skip to content

Commit feabaca

Browse files
committed
[INTERNAL] lib/processors/jsdoc: fix calculation of fully qualified names
When destructuring was used to create a shortcut for an enum type and when the RHS of the destructuring was a member expression, not a simple identifier, then the calculated name was incomplete and the enum was not recognized properly, e.g. when used for a property default value. Example: const {SimpleFormLayout} = layoutLibrary.form; was mistakenly resolved to `sap.ui.layout.SimpleFormLayout` instead of `sap.ui.layout.form.SimpleFormLayout`. Cherry-picked from UI5/openui5@0f4d13da6
1 parent d2fe495 commit feabaca

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

lib/processors/jsdoc/lib/ui5/plugin.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -872,13 +872,13 @@ function resolveFullyQuantifiedName(node) {
872872

873873
const writeExprNode = writeExpr[0].writeExpr;
874874

875-
if ( writeExprNode.type === Syntax.MemberExpression && !writeExprNode.computed && writeExprNode.object.type === Syntax.Identifier ) {
876-
leftMostName = writeExprNode.object.name;
877-
878-
} else if (writeExprNode.type === Syntax.MemberExpression && writeExprNode.object.type === Syntax.MemberExpression) { // Standalone variable without leading dot notation namespace
875+
// determine from write expression how to replace the leftmost name
876+
if (writeExprNode.type === Syntax.MemberExpression) {
877+
// replacement is a qualified name (its leftmost part will be resolved in the next round)
879878
leftMostName = getResolvedObjectName(writeExprNode);
880879

881880
} else if (writeExprNode.type === Syntax.Identifier) {
881+
// leftMostName was an alias only
882882
leftMostName = writeExprNode.name;
883883

884884
} else {
@@ -887,6 +887,8 @@ function resolveFullyQuantifiedName(node) {
887887

888888
if (leftMostName) {
889889
originalName = leftMostName + "." + originalName;
890+
// determine new leftMostName to resolve next
891+
leftMostName = leftMostName.split(".")[0];
890892
}
891893
}
892894

0 commit comments

Comments
 (0)