-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Add API option to getCompletionsAtPosition
to expose completion symbol
information
#52560
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add API option to getCompletionsAtPosition
to expose completion symbol
information
#52560
Conversation
getCompletionsAtPosition
to expose completion symbol information
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
symbol
may retain a wholeTypeChecker
in it, so don’t store it longer than you need it!) - Is it worth it to make a
getCompletionsAtPosition
overload for when the option istrue
that changes the return type? - Should the
symbol
go right onCompletionEntry
, or should it be wrapped in anapiData
property 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 <[email protected]>
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 <[email protected]>
…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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.