Variable should be reset on each loop but wasn't

The ancestors variable is always set once the first augmented doclet is found.
The incompleteDoclet variable is also not reset between loops.
This commit is contained in:
Maximilian Krög
2020-02-04 21:45:26 +01:00
parent 2e4f989d7b
commit c0f058f5cf

View File

@@ -42,62 +42,62 @@ exports.handlers = {
parseComplete: function(e) { parseComplete: function(e) {
let ancestors, candidate, candidates, doclet, i, j, k, l, key; let ancestors, candidate, candidates, doclet, i, j, k, l, key;
let incompleteDoclet, stability, incomplete, incompletes; let stability, incomplete, incompletes;
const doclets = e.doclets; const doclets = e.doclets;
for (i = doclets.length - 1; i >= 0; --i) { for (i = doclets.length - 1; i >= 0; --i) {
doclet = doclets[i]; doclet = doclets[i];
if (doclet.augments) {
ancestors = [].concat(doclet.augments);
}
incompletes = incompleteByClass[doclet.longname]; incompletes = incompleteByClass[doclet.longname];
if (ancestors && incompletes) { if (!doclet.augments || !incompletes) {
// collect ancestors from the whole hierarchy continue;
for (j = 0; j < ancestors.length; ++j) { }
candidates = lookup[ancestors[j]]; ancestors = doclet.augments.slice();
if (candidates) { // collect ancestors from the whole hierarchy
for (k = candidates.length - 1; k >= 0; --k) { for (j = 0; j < ancestors.length; ++j) {
candidate = candidates[k]; candidates = lookup[ancestors[j]];
if (candidate.augments) { if (candidates) {
ancestors = ancestors.concat(candidate.augments); for (k = candidates.length - 1; k >= 0; --k) {
} candidate = candidates[k];
if (candidate.augments) {
Array.prototype.push.apply(ancestors, candidate.augments);
} }
} }
} }
// walk through all inheritDoc members }
for (j = incompletes.length - 1; j >= 0; --j) { // walk through all inheritDoc members
incomplete = incompletes[j]; let incompleteDoclet;
candidates = lookup[doclet.longname + '#' + incomplete]; for (j = incompletes.length - 1; j >= 0; --j) {
if (candidates) { incomplete = incompletes[j];
// get the incomplete doclet that needs to be augmented candidates = lookup[doclet.longname + '#' + incomplete];
for (k = candidates.length - 1; k >= 0; --k) { if (candidates) {
incompleteDoclet = candidates[k]; // get the incomplete doclet that needs to be augmented
if (incompleteDoclet.inheritdoc) { for (k = candidates.length - 1; k >= 0; --k) {
break; incompleteDoclet = candidates[k];
} if (incompleteDoclet.inheritdoc) {
break;
} }
} }
// find the documented ancestor }
for (k = ancestors.length - 1; k >= 0; --k) { // find the documented ancestor
candidates = lookup[ancestors[k] + '#' + incomplete]; for (k = ancestors.length - 1; k >= 0; --k) {
if (candidates) { candidates = lookup[ancestors[k] + '#' + incomplete];
for (l = candidates.length - 1; l >= 0; --l) { if (candidates) {
candidate = candidates[l]; for (l = candidates.length - 1; l >= 0; --l) {
if (candidate && !candidate.inheritdoc) { candidate = candidates[l];
stability = candidate.stability || incompleteDoclet.stability; if (candidate && !candidate.inheritdoc) {
if (stability) { stability = candidate.stability || incompleteDoclet.stability;
incompleteDoclet.stability = stability; if (stability) {
for (key in candidate) { incompleteDoclet.stability = stability;
if (candidate.hasOwnProperty(key) && for (key in candidate) {
keepKeys.indexOf(key) == -1) { if (candidate.hasOwnProperty(key) &&
incompleteDoclet[key] = candidate[key]; keepKeys.indexOf(key) == -1) {
} incompleteDoclet[key] = candidate[key];
} }
// We have found a matching parent doc and applied it so we
// don't want to ignore this doclet anymore.
incompleteDoclet.ignore = false;
// We found a match so we can stop break
break;
} }
// We have found a matching parent doc and applied it so we
// don't want to ignore this doclet anymore.
incompleteDoclet.ignore = false;
// We found a match so we can stop break
break;
} }
} }
} }