MCPcopy
hub / github.com/jsdoc/jsdoc / _getParentClass

Method _getParentClass

lib/jsdoc/src/parser.js:456–491  ·  view source on GitHub ↗

* Get the doclet for the lowest-level class, if any, that is in the scope chain for a given node. * * @param {Object} node - The node whose scope chain will be searched. * @return {module:jsdoc/doclet.Doclet?} The doclet for the lowest-level class in the node's scope * chain.

({enclosingScope})

Source from the content-addressed store, hash-verified

454 * chain.
455 */
456 _getParentClass({enclosingScope}) {
457 let doclet;
458 let nameAtoms;
459 let scope = enclosingScope;
460
461 function isClass(d) {
462 return d && d.kind === 'class';
463 }
464
465 while (scope) {
466 // get the doclet, if any, for the parent scope
467 doclet = this._getDocletById(scope.nodeId);
468
469 if (doclet) {
470 // is the doclet for a class? if so, we're done
471 if ( isClass(doclet) ) {
472 break;
473 }
474
475 // is the doclet for an instance member of a class? if so, try to get the doclet for the
476 // owning class
477 nameAtoms = jsdoc.name.shorten(doclet.longname);
478 if (nameAtoms.scope === jsdoc.name.SCOPE.PUNC.INSTANCE) {
479 doclet = this._getDocletByLongname(nameAtoms.memberof);
480 if ( isClass(doclet) ) {
481 break;
482 }
483 }
484 }
485
486 // move up to the next parent scope
487 scope = scope.enclosingScope;
488 }
489
490 return (isClass(doclet) ? doclet : null);
491 }
492
493 // TODO: docs
494 /**

Callers 1

resolveThisMethod · 0.95

Calls 2

_getDocletByIdMethod · 0.95
_getDocletByLongnameMethod · 0.95

Tested by

no test coverage detected