Add API option to getCompletionsAtPosition to expose completion symbol information #52560
Add API option to getCompletionsAtPosition to expose completion symbol information #52560andrewbranch merged 11 commits intomicrosoft:mainfrom
getCompletionsAtPosition to expose completion symbol information #52560Conversation
getCompletionsAtPosition to expose completion symbol information
There was a problem hiding this comment.
I think I’m ok with this if the implementation can be restructured to conditionally assign rather than always assign and conditionally delete. Beyond that, the API might need a little bikeshedding. Some things to consider:
- The name of the option
- Once we settle on the API shape, we will want to add JSDoc explaining the functionality and caveats (e.g. the
symbolmay retain a wholeTypeCheckerin it, so don’t store it longer than you need it!) - Is it worth it to make a
getCompletionsAtPositionoverload for when the option istruethat changes the return type? - Should the
symbolgo right onCompletionEntry, or should it be wrapped in anapiDataproperty or something?
@jakebailey @gabritto do you have any input or overall concerns?
|
I don't think I have any concerns, this looks fine besides the comments you already left. @andrewbranch I do have a question though: if we make the |
src/services/stringCompletions.ts
Outdated
| /*symbolToSortTextMap*/ undefined, | ||
| /*isJsxIdentifierExpected*/ undefined, | ||
| /*isRightOfOpenTag*/ undefined, | ||
| includeApiData |
There was a problem hiding this comment.
In first version this case wasn't handled, now fixed to be consistent
From my perpective it is easiest solution for us and most convenient for consumer Also feel free to edit jsdoc |
|
The TypeScript team hasn't accepted the linked issue #51936. If you can get it accepted, this PR will have a better chance of being reviewed. |
Co-authored-by: Andrew Branch <andrewbranch@users.noreply.github.com>
That’s not an issue for this particular change, since still every completion has at most one symbol. The only way this property could break a future API change is if individual completions started being derived from multiple symbols 🤔. Thinking about it this morning, though, I’m wondering if the change needs to be so generic. What additional data might someone need on a completion item in the future? Maybe we should just call the option |
tbh I more like general name, as idea can be extended without adding new properties. Like what if also
It will change already existing calls so plugin devs might start wondering what is new |
getCompletionsAtPosition to expose completion symbol information getCompletionsAtPosition to expose completion symbol information
|
To summarize requested changes here:
@andrewbranch Is that right and anything else to consider? I don't really care of typings and so on, I'm only interested in adding a way to use P.S. feel free to make quick edits directly! |
Discussed this in #52790 and yes, along with my suggested JSDoc change, if you do these two things it should be good to go 👍 |
Co-authored-by: Andrew Branch <andrewbranch@users.noreply.github.com>
…d someone might not know about added option
| * Included for non-string completions only when `includeSymbol: true` option is passed to `getCompletionsAtPosition`. | ||
| * @example Get declaration of completion: `symbol.valueDeclaration` | ||
| */ | ||
| symbol?: Symbol |
There was a problem hiding this comment.
@andrewbranch All done, but decided to also add jsdoc on symbol property itself (since its always visible to user even if option is off). Anyway, don't see anything bad in extra documentation 😄
andrewbranch
left a comment
There was a problem hiding this comment.
Looks good, just run the 'Public API' test and accept the baselines to make the tests green
Fixes #51936
#51936 (comment)
Only 2 tests fail: The baseline file api/typescript.d.ts has changed.
@andrewbranch Let me know if I'm going here into right direction.