Expand find-all-references to more keywords #51232
Labels
Domain: Symbol Navigation
Relates to go-to-definition, find-all-references, highlighting/occurrences.
In Discussion
Not yet reached consensus
Suggestion
An idea for TypeScript
Background
Today, document highlights/occurrences has special support for when a developer's cursor is over a keyword.
For example, let's say you had your cursor
/*$*/
in the following code.TypeScript is able to provide what's called "document highlights" (formerly called "occurrences") for the editor to highlight as visual clues. Typically, these keywords will be displayed with a lighter background/foreground in the editor, and the highlights we provide in the above case are denoted with
[|
these range markers|]
.It would be great if find-all-references worked similarly. Editors often has key bindings for iterating through the current set of document highlights (on VS Code this is Go to Next Symbol Highlight - for Windows, the keybinding is F7 and Shift+F7, and in VS, it's Ctrl+Shift+Up/Down); however, these keyboard shortcuts are pretty undiscoverable. Document highlights are a subtle enough hint that users may not even know they exist. So find-all-references has the potential to be a nice delighter for a more-often-used action.
What Would it Support?
I don't know the full list of things document highlights currently supports; however, from what I do know, here's a list of what I think would be useful, ranked loosely by utility.
return
keywords in a specific function scopethrow
keywords in a specific function ortry
block scopebreak
andcontinue
keywords in a specific loop construct,switch
statement, or labeled statementawait
keywords in a specific function scopeyield
keywords in a specific function scopeexport
keywords in a module or namespacecase
anddefault
clauses in aswitch
statementif
/else
branchesimport
keywords in a module or namespacepublic
,private
,protected
,readonly
)Specifics
Many of these are already implemented in document highights/occurrences. The only place I could think that these might differ is whether find-all-references would include the "owning" node in many of these contexts.
For example, today, find-all-references on a
case
keyword in aswitch
highlights all of the following:case
clause keywordsdefault
keyword for thedefault
clauseswitch
keyword itselfbreak
statementsSo in the following document highlights request
you would get
So should find-all-references on that
case
actually return all of those? Or should it provide only the othercase
clauses?The text was updated successfully, but these errors were encountered: