For consistency with method parameters, this change extends our unfortunate practice of adding type properties to the parent of the `type` object, rather than the object itself.
Replace an O(n^2) algorithm (indexOf + insert) * n with a much faster
algorithm, depending on what is supported by the JS engine.
I prefer the Set version as it is similar in spirit to the original
code and does not need to change the walked tree, but the flag setting
approach has the advantage that it works with current Node versions
without needing commandline flags.
Without the fix, we get the following when running ./jsdoc -T:
Failures:
jsdoc/src/filter Filter isIncluded
1) should be able to exclude descendants of excluded subdirectories
Message:
Expected 4 to be 2.
Stacktrace:
undefined
2) should be able to exclude descendants of excluded subdirectories
Message:
Expected 1 to be -1.
Stacktrace:
undefined
3) should be able to exclude descendants of excluded subdirectories
Message:
Expected 3 to be -1.
Stacktrace:
undefined
Finished in 6.696 seconds
849 tests, 2050 assertions, 3 failures
This test passes with the fix.
There were three separate problems here:
1. The visitor called `trackVars` at the wrong time for `AssignmentExpression` and `VariableDeclarator` nodes, which prevented JSDoc from setting the `funcscope` property correctly.
2. The `funcscope` property was being added to `VariableDeclarator` nodes. It should only be added to `AssignmentExpression` nodes.
3. We were trying to resolve the variable name `____` in `AssignmentExpression` nodes. This is a special value we add to the source code so that the `lends` tag will work, and it should never be resolved against the enclosing scope.
The previous, buggy behavior looked reasonable in most cases, but it didn't work for closures that contain multiple `lends` tags.