-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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 containerName to CallHierarchyItem #38997
Conversation
Thanks for the PR! It looks like you've changed the TSServer protocol in some way. Please ensure that any changes here don't break consumers of the current TSServer API. For some extra review, we'll ping @sheetalkamat, @amcasey, @mjbvz, @minestarks for you. Feel free to loop in other consumers/maintainers if necessary |
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.
Do we know what the ux displaying this info in vscode looks like yet?
@@ -129,6 +129,31 @@ namespace ts.CallHierarchy { | |||
return { text, pos: declName.getStart(), end: declName.getEnd() }; | |||
} | |||
|
|||
function getCallHierarchItemContainerName(node: CallHierarchyDeclaration): string | undefined { | |||
if (isConstNamedExpression(node)) { | |||
if (isModuleBlock(node.parent.parent.parent.parent) && isIdentifier(node.parent.parent.parent.parent.parent.name)) { |
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.
Is it safe to do this many unguarded parent accesses?
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.
Yes—isConstNamedExpression
guarantees that the third-to-last .parent
is a VariableDeclarationList
or CatchClause
, so the second-to-last is VariableStatement | ForStatement | ForOfStatement | ForInStatement | TryStatement
, so one more .parent
is safe from there.
Should we have @typescript-bot pack this and let @mjbvz see if this is sufficient for him? |
Heya @weswigham, I've started to run the tarball bundle task on this PR at 6e0e065. You can monitor the build here. |
Hey @weswigham, I've packed this into an installable tgz. You can install it for testing by referencing it in your
and then running There is also a playground for this build. |
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.
Protocol changes look good to me. Thanks for looking into this!
* upstream/master: (22 commits) Small fix in `getIsContextSensitiveAssignmentOrContextType` Simplify `visitObjectLiteralExpression` Fix handling of `aruments` in the emitter Fix declaration emit for property references of imported object literal types (microsoft#39055) Fix casing for wild card keys for implicit globs to get wild card directories to watch (microsoft#39049) DOM update 2020-06-12 fix(a11y): make ISSUE_TEMPLATE/Bug_report.md more accessible for folks with screen readers (microsoft#39013) Update request-pr-review script to latest version of octokit (microsoft#39031) pin version of octokit skip implements types with no symbols isDynamicName skips parentheses for element access Allow `e: unknown` in `catch` arguments Serialize (noncontextual) keyword named namespace members with export declarations in both declaration emitters (microsoft#38982) Patch to use this.timeout() > 0 rather than this.enableTimeout() to work with mocha 8+ Handle missing return type nodes and nested type references missing type arguments in existing jsdoc node serialization (microsoft#39011) Add containerName to CallHierarchyItem (microsoft#38997) Fix isSameEntityName (microsoft#38999) Fix typo for 'blocklist' (microsoft#39001) remove errant tab Switch to isSymbolAccessible for both. ...
Adds a
containerName
to CallHierarchyItems:For all other CallHierarchyItems,
containerName
will be undefined. Note thatfileName
is already included separately on all items.Fixes #37061