mirror of
https://github.com/jsdoc/jsdoc.git
synced 2025-12-08 19:46:11 +00:00
clarify logic for resolving property parents
This commit is contained in:
parent
79a3be132c
commit
2b34c5167a
@ -444,28 +444,28 @@ Parser.prototype.resolveThis = function(node) {
|
|||||||
* an empty array if no doclets are found.
|
* an empty array if no doclets are found.
|
||||||
*/
|
*/
|
||||||
Parser.prototype.resolvePropertyParents = function(node) {
|
Parser.prototype.resolvePropertyParents = function(node) {
|
||||||
var currentNode = node;
|
var currentAncestor = node.parent;
|
||||||
|
var nextAncestor = currentAncestor ? currentAncestor.parent : null;
|
||||||
var doclet;
|
var doclet;
|
||||||
var doclets = [];
|
var doclets = [];
|
||||||
|
|
||||||
do {
|
while (currentAncestor) {
|
||||||
if (currentNode.parent) {
|
doclet = this._getDoclet(currentAncestor.nodeId);
|
||||||
doclet = this._getDoclet(currentNode.parent.nodeId);
|
if (doclet) {
|
||||||
if (doclet) {
|
doclets.push(doclet);
|
||||||
doclets.push(doclet);
|
|
||||||
}
|
|
||||||
|
|
||||||
// if the parent is an assignment expression (for example, `exports.FOO` in
|
|
||||||
// `var foo = exports.FOO = { x: 1 }`, keep walking upwards
|
|
||||||
if (currentNode.parent.parent.type === Syntax.AssignmentExpression) {
|
|
||||||
currentNode = currentNode.parent;
|
|
||||||
}
|
|
||||||
// otherwise, we're done
|
|
||||||
else {
|
|
||||||
currentNode = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} while (currentNode);
|
|
||||||
|
// if the next ancestor's parent is an assignment expression (for example, `exports.FOO` in
|
||||||
|
// `var foo = exports.FOO = { x: 1 }`, keep walking upwards
|
||||||
|
if (nextAncestor && nextAncestor.type === Syntax.AssignmentExpression) {
|
||||||
|
nextAncestor = nextAncestor.parent;
|
||||||
|
currentAncestor = currentAncestor.parent;
|
||||||
|
}
|
||||||
|
// otherwise, we're done
|
||||||
|
else {
|
||||||
|
currentAncestor = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return doclets;
|
return doclets;
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user