mirror of
https://github.com/jsdoc/jsdoc.git
synced 2025-12-08 19:46:11 +00:00
refactor(jsdoc-doclet): clean up DocletStore private methods
This commit is contained in:
parent
fe806ddbba
commit
e8340994fd
@ -120,13 +120,14 @@ export class DocletStore {
|
|||||||
newDoclet,
|
newDoclet,
|
||||||
newValue,
|
newValue,
|
||||||
oldValue,
|
oldValue,
|
||||||
|
property,
|
||||||
setFnName: isVisible ? 'add' : 'delete',
|
setFnName: isVisible ? 'add' : 'delete',
|
||||||
visibilityChanged,
|
visibilityChanged,
|
||||||
wasVisible,
|
wasVisible,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (newDoclet) {
|
if (newDoclet) {
|
||||||
this.#trackAllDocletsByLongname(doclet);
|
this.#trackAllDocletsByLongname(doclet, {});
|
||||||
this.#trackDocletByNodeId(doclet);
|
this.#trackDocletByNodeId(doclet);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -143,7 +144,7 @@ export class DocletStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Update all watchable properties.
|
// Update all watchable properties.
|
||||||
this.#updateWatchableProperties(doclet, property, docletInfo);
|
this.#updateWatchableProperties(doclet, docletInfo);
|
||||||
|
|
||||||
// Update list of source paths for visible doclets.
|
// Update list of source paths for visible doclets.
|
||||||
if (visibilityChanged) {
|
if (visibilityChanged) {
|
||||||
@ -165,10 +166,10 @@ export class DocletStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Updates `this.allDocletsByLongname` _only_.
|
// Updates `this.allDocletsByLongname` _only_.
|
||||||
#trackAllDocletsByLongname(doclet, eventProp, oldValue, newValue) {
|
#trackAllDocletsByLongname(doclet, { property, oldValue, newValue }) {
|
||||||
newValue ??= doclet.longname;
|
newValue ??= doclet.longname;
|
||||||
|
|
||||||
if (eventProp && eventProp !== 'longname') {
|
if (property && property !== 'longname') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -188,13 +189,17 @@ export class DocletStore {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#updateMapProperty(realProp, eventProp, oldKey, newKey, doclet, { isVisible, wasVisible }) {
|
#updateMapProperty(
|
||||||
const map = this[DocletStore.#propertyToMapName.get(realProp)];
|
requestedProp,
|
||||||
|
doclet,
|
||||||
|
{ property: eventProp, oldValue: oldKey, newValue: newKey, isVisible, wasVisible }
|
||||||
|
) {
|
||||||
|
const map = this[DocletStore.#propertyToMapName.get(requestedProp)];
|
||||||
|
|
||||||
// If the event didn't specify the property name that we're interested in, then ignore the new
|
// If the event didn't specify the property name that we're interested in, then ignore the new
|
||||||
// key; it doesn't apply to this property. Instead, get the key from the doclet.
|
// key; it doesn't apply to this property. Instead, get the key from the doclet.
|
||||||
if (realProp !== eventProp) {
|
if (requestedProp !== eventProp) {
|
||||||
newKey = doclet[realProp];
|
newKey = doclet[requestedProp];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wasVisible && oldKey) {
|
if (wasVisible && oldKey) {
|
||||||
@ -205,7 +210,7 @@ export class DocletStore {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#updateSetProperty(prop, value, setFnName) {
|
#updateSetProperty(prop, value, { setFnName }) {
|
||||||
const set = this[DocletStore.#propertyToSetName.get(prop)];
|
const set = this[DocletStore.#propertyToSetName.get(prop)];
|
||||||
|
|
||||||
if (Object.hasOwn(value, prop) && value[prop]?.length) {
|
if (Object.hasOwn(value, prop) && value[prop]?.length) {
|
||||||
@ -228,32 +233,32 @@ export class DocletStore {
|
|||||||
this.#commonPathPrefix = null;
|
this.#commonPathPrefix = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
#updateWatchableProperties(doclet, property, docletInfo) {
|
#updateWatchableProperties(doclet, docletInfo) {
|
||||||
const {
|
const {
|
||||||
isGlobal,
|
isGlobal,
|
||||||
isVisible,
|
isVisible,
|
||||||
newDoclet,
|
newDoclet,
|
||||||
newValue,
|
newValue,
|
||||||
oldValue,
|
oldValue,
|
||||||
setFnName,
|
property,
|
||||||
visibilityChanged,
|
visibilityChanged,
|
||||||
wasVisible,
|
wasVisible,
|
||||||
} = docletInfo;
|
} = docletInfo;
|
||||||
|
|
||||||
// `access` only affects visibility, which is handled above, so we ignore it here.
|
// `access` only affects visibility, which is handled above, so we ignore it here.
|
||||||
if (visibilityChanged || property === 'augments') {
|
if (visibilityChanged || property === 'augments') {
|
||||||
this.#updateSetProperty('augments', doclet, setFnName);
|
this.#updateSetProperty('augments', doclet, docletInfo);
|
||||||
}
|
}
|
||||||
if (visibilityChanged || property === 'borrowed') {
|
if (visibilityChanged || property === 'borrowed') {
|
||||||
this.#updateSetProperty('borrowed', doclet, setFnName);
|
this.#updateSetProperty('borrowed', doclet, docletInfo);
|
||||||
}
|
}
|
||||||
// `ignore` only affects visibility, which is handled above, so we ignore it here.
|
// `ignore` only affects visibility, which is handled above, so we ignore it here.
|
||||||
if (visibilityChanged || property === 'implements') {
|
if (visibilityChanged || property === 'implements') {
|
||||||
this.#updateSetProperty('implements', doclet, setFnName);
|
this.#updateSetProperty('implements', doclet, docletInfo);
|
||||||
}
|
}
|
||||||
if (visibilityChanged || property === 'kind') {
|
if (visibilityChanged || property === 'kind') {
|
||||||
this.#toggleGlobal(doclet, { isGlobal, isVisible });
|
this.#toggleGlobal(doclet, { isGlobal, isVisible });
|
||||||
this.#updateMapProperty('kind', property, oldValue, newValue, doclet, docletInfo);
|
this.#updateMapProperty('kind', doclet, docletInfo);
|
||||||
}
|
}
|
||||||
if (visibilityChanged || property === 'listens') {
|
if (visibilityChanged || property === 'listens') {
|
||||||
let added;
|
let added;
|
||||||
@ -277,17 +282,17 @@ export class DocletStore {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (visibilityChanged || property === 'longname') {
|
if (visibilityChanged || property === 'longname') {
|
||||||
this.#updateMapProperty('longname', property, oldValue, newValue, doclet, docletInfo);
|
this.#updateMapProperty('longname', doclet, docletInfo);
|
||||||
this.#trackAllDocletsByLongname(doclet, property, oldValue, newValue);
|
this.#trackAllDocletsByLongname(doclet, docletInfo);
|
||||||
}
|
}
|
||||||
if (visibilityChanged || property === 'memberof') {
|
if (visibilityChanged || property === 'memberof') {
|
||||||
this.#updateMapProperty('memberof', property, oldValue, newValue, doclet, docletInfo);
|
this.#updateMapProperty('memberof', doclet, docletInfo);
|
||||||
}
|
}
|
||||||
if (visibilityChanged || property === 'mixes') {
|
if (visibilityChanged || property === 'mixes') {
|
||||||
this.#updateSetProperty('mixes', doclet, setFnName);
|
this.#updateSetProperty('mixes', doclet, docletInfo);
|
||||||
}
|
}
|
||||||
if (visibilityChanged || property === 'scope') {
|
if (visibilityChanged || property === 'scope') {
|
||||||
this.#toggleGlobal(doclet, { isGlobal, isVisible });
|
this.#toggleGlobal(doclet, docletInfo);
|
||||||
}
|
}
|
||||||
// `undocumented` only affects visibility, which is handled above, so we ignore it here.
|
// `undocumented` only affects visibility, which is handled above, so we ignore it here.
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user