Now only the immediately preceding jsdoc of a node is retrieved by
getJSDoc, although it still does the correct non-local lookup for nodes
like ParameterDeclaration.
This doesn't change parsing or binding, which use the per-node Node.jsdoc
property directly. But it does change everything that relies on getJSDoc,
which includes the checker and language service.
Fixes#32062, which contains the analysis that justifies the change.
Previously, getJSDocCommentAndTags could recur up to four times if any
of four predicates matched. However, to avoid duplicates, the predicates
have been tuned to be mutually exclusive, which means that the recursion
can be turned into a while loop. The while loop is much simpler and
safer, since it is guaranteed to only walk up the tree one time. In
addition, the extra check that adds jsdoc from initializers only runs
once, before the loop, further reducing the opportunity for duplicate
jsdocs.
I thought about further simplifying the code that gets the next node to
check, but to know when to stop the loop, I'd need a predicate that is
as complicated as the code in `getNextJSDocCommentLocation`, so I kept
the existing code, just reordering it for compactness.
* Refactor declaration emitter into declaration transformer
* Slight cleanup from code review feedback
* Incorporate fix for new test
* Swaths of PR feedback
* Merge public methods
* Per-file output
* Preserve input import ordering more often
* Unify jsdoc comment start detection under more lenient rule
* Move to per-file transformations to reduce the memory that msut be retained
* Fix typo
* Support completions for JSDoc @param tag names
* Undo change to finishNode
* Don't include trailing whitespace in @param range; instead, specialize getJsDocTagAtPosition
i.e. use "var v: string" instead of "(var) v: string".
The parens case should only be used when we're using an english description instead of
an actual language construct.