Support completions for JSDoc @param tag names#16299
Conversation
cff0089 to
117926a
Compare
| } | ||
|
|
||
| function finishNode<T extends Node>(node: T, end?: number): T { | ||
| node.end = end === undefined ? scanner.getStartPos() : end; |
There was a problem hiding this comment.
we use this all the time. the new code will result in two statements. please run perf tests to ensure we are not messing up the engine optimizations.
There was a problem hiding this comment.
Since this isn't necessary, reverted the change. Will do in a separate branch.
| // Include trailing whitespace inside the range of the `@param` tag. | ||
| // This way we can provide completions after `@param `. | ||
| let end = scanner.getStartPos(); | ||
| while (ts.isWhiteSpaceSingleLine(scanner.getText().charCodeAt(end))) end++; |
There was a problem hiding this comment.
we do not do that for other nodes. why do we need this?
There was a problem hiding this comment.
I was using it so that at @param /*completions here*/ you would get completions by being inside the @param node. But we can do this a different way by changing getJsDocTagAtPosition to handle ranges differently.
…e getJsDocTagAtPosition
|
|
||
| export function mapDefined<T>(array: ReadonlyArray<T>, mapFn: (x: T, i: number) => T | undefined): ReadonlyArray<T> { | ||
| const result: T[] = []; | ||
| export function mapDefined<T, U>(array: ReadonlyArray<T>, mapFn: (x: T, i: number) => U | undefined): U[] { |
There was a problem hiding this comment.
We always create a fresh array. If the caller wants a readonly array they can type it that way.
Can't just change this one to ReadonlyArray because services/types.ts currently uses mutable arrays. We should change that separately. #16312
Fixes #15853