You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add way to differentiate references for definitions at requesting location 聽#42889
We use the references request to power VS Code's references code lens feature. References returned by TS have an optional isDefinition property that tells if the reference is to a definition or not. We use this to avoid showing multiple references for a case such as:
We'd like a new property on the references response that tells us if the reference belongs to definition from the requesting location (not yet sure what the name of this should be).
I'm also open for alternative proposals on how to handle this. The main issue is that can't handle these cases reliably on the VS Code side today for the references code lens, and would like to improve this
One of the ideas here was to instead add an argument to the find-all-references request, and the language server could do the filtering on its own side. Naming will still be weird/hard here.
I'm going to mark this as a VS Code priority since it is a pretty annoying papercut. We still need to finalize the names in the api but I think agreed that the general concept of this api makes sense
This would be for the 4.4 timeframe, not for the current 4.3 release
Is there any case where the count would be wrong except for overloads? Maybe the solution is to have isDefinition: false for overloads, or all but the last overload for signatures?
From talking about this at the editor sync meeting:
It is difficult (or at least error-prone) for VS Code to identify the self-declaration in the list of references returned. The best solution for Code is
for Typescript to have a new property isSelfDeclaration which takes a declaration node, and only marks isSelfDeclaration: true for declarations of the symbol (and any overloads).
Nobody thought of any cases besides overloads.
Nobody was sure if/how VS uses isDefinition, or something else. There may be related, or even duplicate code here.
This was discussed previously and concluded
If we just had both isDefinition and isReference, VS Code could accomplish what it wants and no one else would be broken.
I'll think about how hard it is to calculate isReference versus isSelfDeclaration.
Activity
mjbvz commentedon Feb 19, 2021
I'm also open for alternative proposals on how to handle this. The main issue is that can't handle these cases reliably on the VS Code side today for the references code lens, and would like to improve this
DanielRosenwasser commentedon Feb 19, 2021
Let's chat about this on Wednesday at the next editor sync.
This is a great test case, but it also maybe speaks to how we name things here.
DanielRosenwasser commentedon Feb 24, 2021
One of the ideas here was to instead add an argument to the find-all-references request, and the language server could do the filtering on its own side. Naming will still be weird/hard here.
mjbvz commentedon Mar 30, 2021
I'm going to mark this as a VS Code priority since it is a pretty annoying papercut. We still need to finalize the names in the api but I think agreed that the general concept of this api makes sense
This would be for the 4.4 timeframe, not for the current 4.3 release
sandersn commentedon Aug 30, 2021
Is there any case where the count would be wrong except for overloads? Maybe the solution is to have
isDefinition: falsefor overloads, or all but the last overload for signatures?sandersn commentedon Sep 1, 2021
From talking about this at the editor sync meeting:
for Typescript to have a new property
isSelfDeclarationwhich takes a declaration node, and only marksisSelfDeclaration: truefor declarations of the symbol (and any overloads).isDefinition, or something else. There may be related, or even duplicate code here.I'll think about how hard it is to calculate
isReferenceversusisSelfDeclaration.