Skip to content
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

Feature request: Get references in template (getReferencesAtPosition) #29

Closed
kukjevov opened this issue Dec 19, 2016 · 29 comments
Closed
Assignees
Labels
feature ivy Feature / enhancement / bug fix in Ivy lib Relates to an issue in the @angular/language-service library

Comments

@kukjevov
Copy link

Hi,

as for now you can navigate to source by ctrl+click, or peek definition, but if you use find all usages template occurencies on methods or properties are not in result window.

This would be awesome, but i`m not sure that this is possible to do in VsCode, but it would be nice :). Especially while refactoring code, since right now this occurencies can be forgotten or must be string searched.

Thank you

@simonnagl
Copy link

This would also enabling symbols in templates (i.e. using F2)

@przemo098
Copy link

Someone is doing something with this?!

@EylonSu
Copy link

EylonSu commented Apr 29, 2019

anything new?

@ayazhafiz
Copy link
Member

We should be able to implement this by adding getReferencesAtPosition to the Language Service's TypeScript plugin. However, we will probably hold off on doing this until the language service is rewritten to use Angular's new Ivy compiler, which will make it easier to extract the class properties used in a template.

(note: perhaps we can use the Angular indexing API or similar for this)

@ayazhafiz ayazhafiz added the ivy Feature / enhancement / bug fix in Ivy label Sep 20, 2019
@kyliau kyliau changed the title Feature request: Find usages shows also occurencies in templates Feature request: getReferencesAtPosition Nov 11, 2019
@ayazhafiz ayazhafiz added the lib Relates to an issue in the @angular/language-service library label Feb 21, 2020
@abdulkareemnalband
Copy link

@kukjevov @kyliau Can you update title and content of this issue
many people are creating duplicates as this is not visible in search

Suggestion: Find property references in template from typescript

@kukjevov
Copy link
Author

It had different name Feature request: Find usages shows also occurencies in templates as you can see but it was changed by @kyliau

So you have to make agreement with him :).

@ayazhafiz ayazhafiz changed the title Feature request: getReferencesAtPosition Feature request: Get references in template (getReferencesAtPosition) Mar 14, 2020
@Niaro
Copy link

Niaro commented Jun 3, 2020

4 years?) I wonder how WebStorm got this faster than VScode O_o

@furmandev
Copy link

This would be a great feature. Is there any timeline or priority on this? I think this issue also relates to #252

ayazhafiz added a commit to ayazhafiz/angular that referenced this issue Jun 4, 2020
Keen and I were talking about what it would take to support getting
references at a position in the current language service, since it's
unclear when more investment in the Ivy LS will be available. Getting TS
references from a template is trivial -- we simply need to get the
definition of a symbol, which is already handled by the language
service, and ask the TS language service to give us the references for
that definition.

This doesn't handle references in templates, but that could be done in a
subsequent pass.

Part of angular/vscode-ng-language-service#29
@kyliau
Copy link
Contributor

kyliau commented Jun 4, 2020

We hear you! @ayazhafiz and I are thinking about ways to support this in Angular language service. @ayazhafiz already has a PR ready that partially* supports this feature.
We're currently looking into the best way to introduce get references without adding too much overhead, since much of this code will not be reused once we switch the backend to Ivy.

Re partial support:
References from template can be easily retrieved, whereas references from TS (for example a field in a class) is more difficult because we need to check the template. The former is what Ayaz's PR is for.

ayazhafiz added a commit to ayazhafiz/angular that referenced this issue Jun 7, 2020
Keen and I were talking about what it would take to support getting
references at a position in the current language service, since it's
unclear when more investment in the Ivy LS will be available. Getting TS
references from a template is trivial -- we simply need to get the
definition of a symbol, which is already handled by the language
service, and ask the TS language service to give us the references for
that definition.

This doesn't handle references in templates, but that could be done in a
subsequent pass.

Part of angular/vscode-ng-language-service#29
atscott pushed a commit to angular/angular that referenced this issue Jun 9, 2020
Keen and I were talking about what it would take to support getting
references at a position in the current language service, since it's
unclear when more investment in the Ivy LS will be available. Getting TS
references from a template is trivial -- we simply need to get the
definition of a symbol, which is already handled by the language
service, and ask the TS language service to give us the references for
that definition.

This doesn't handle references in templates, but that could be done in a
subsequent pass.

Part of angular/vscode-ng-language-service#29

PR Close #37437
atscott pushed a commit to angular/angular that referenced this issue Jun 9, 2020
Keen and I were talking about what it would take to support getting
references at a position in the current language service, since it's
unclear when more investment in the Ivy LS will be available. Getting TS
references from a template is trivial -- we simply need to get the
definition of a symbol, which is already handled by the language
service, and ask the TS language service to give us the references for
that definition.

This doesn't handle references in templates, but that could be done in a
subsequent pass.

Part of angular/vscode-ng-language-service#29

PR Close #37437
ngwattcos pushed a commit to ngwattcos/angular that referenced this issue Jun 25, 2020
)

Keen and I were talking about what it would take to support getting
references at a position in the current language service, since it's
unclear when more investment in the Ivy LS will be available. Getting TS
references from a template is trivial -- we simply need to get the
definition of a symbol, which is already handled by the language
service, and ask the TS language service to give us the references for
that definition.

This doesn't handle references in templates, but that could be done in a
subsequent pass.

Part of angular/vscode-ng-language-service#29

PR Close angular#37437
@webia1
Copy link

webia1 commented Jul 2, 2020

I would be very thankful for every process.

@Harpush
Copy link

Harpush commented Aug 4, 2020

Any news on this? Seems the PR wasn't merged

profanis pushed a commit to profanis/angular that referenced this issue Sep 5, 2020
)

Keen and I were talking about what it would take to support getting
references at a position in the current language service, since it's
unclear when more investment in the Ivy LS will be available. Getting TS
references from a template is trivial -- we simply need to get the
definition of a symbol, which is already handled by the language
service, and ask the TS language service to give us the references for
that definition.

This doesn't handle references in templates, but that could be done in a
subsequent pass.

Part of angular/vscode-ng-language-service#29

PR Close angular#37437
@AxiomeCG
Copy link

AxiomeCG commented Oct 5, 2020

Really excited about this feature, is there any news about it ?
Very painful to track down broken reference in the template while renaming the symbol in the typescript file.

@kyliau
Copy link
Contributor

kyliau commented Oct 5, 2020

We are going to launch Ivy version of the language service in version 11 (November 2020). Once it's achieve feature parity with the existing View Engine language service, we'll prioritize this feature! Switching to the Ivy backend enables us to implement features like this one, which was almost impossible previously.

@atscott
Copy link
Collaborator

atscott commented Jan 22, 2021

This has been fixed by the new Ivy-native language service, released in v11.1.0.
It's an opt-in feature for now, please give it a try and let us know if you have any feedback.
For the best editor experience, please make sure your project has strictTemplates enabled in angularCompilerOptions.
In case you run into similar bug, please file a new issue. I'll close this for now.

@atscott atscott closed this as completed Jan 22, 2021
@ic3guy
Copy link

ic3guy commented Jan 30, 2021

Should we be seeing the correct # of references via CodeLens too? Because Ctrl-Click / Find all References does work, but codelens references and a click on it does not show template refs. I'm assuming that CodeLens pulls these refs from somewhere else, or am I missing a config flag somewhere?

@atscott
Copy link
Collaborator

atscott commented Feb 1, 2021

Should we be seeing the correct # of references via CodeLens too?

Great question! It looks like there's additional configuration needed on our end for integrating with CodeLens. Could you open a new issue for this?

Edit: Re-opening #162

@kukjevov
Copy link
Author

@atscott @ic3guy Guys am I missing something, or is there something weird with configuration of project :)? Because i tried it in my own project and it does not work, I even tried latest version of Angular cli, generated new project, there is title property, but if i use find all references, reference from template is not displayed? Am I missing something :D ?

Thx

@kukjevov
Copy link
Author

kukjevov commented Feb 16, 2021

@atscott hmmm i have looked at it and i found out, that it needs to be turned on, but if i turn it on, it keeps crashing and restarting, should i open new issue or paste it here :) ?

@atscott
Copy link
Collaborator

atscott commented Feb 16, 2021

@atscott hmmm i have looked at it and i found out, that it needs to be turned on, but if i turn it on, it keeps crashing and restarting, should i open new issue or paste it here :) ?

@kukjevov yes, please submit a new issue for this.

@erosostolato
Copy link

Hey guys, I couldn't get it to work. What do I need to do? Do I need to enable any option?

@kukjevov
Copy link
Author

kukjevov commented Mar 1, 2021

@erosostolato if you have installed language server and vscode extensions for angular then in user preferences you can find Angular: Experimental-ivy, if you enable it it should start working, in my case it is crashing, i need to create new issue for it

@erosostolato
Copy link

erosostolato commented Mar 1, 2021

@kukjevov

The only thing that I can do is renaming a template variable like this:
image

But if I try to rename it directly in the interface, it doesn't work... it doesn't even show the reference count
image

This is my settings page:
image

@kukjevov
Copy link
Author

kukjevov commented Mar 1, 2021

If i saw it correctly, what should be working so far is only getting correct number of references in templates :), renaming is feature that i saw in Angular 12 beta.0 so it is not working, because it is still not there :), but it should be soon :).

@kukjevov
Copy link
Author

kukjevov commented Mar 1, 2021

Codelens also needs some work, so only find all references should be working, but still there is some problem in my project because if i turn it on, it crashes :).

@atscott
Copy link
Collaborator

atscott commented Mar 1, 2021

FYI - renaming for Angular is only available in external templates. There is now way to ensure that the Angular extension is used in TypeScript files so we opted to disable it there. See microsoft/vscode#115354. If you would like this feature, it could be worth upvoting the vscode issue so it gets prioritized sooner.

@erosostolato
Copy link

@kukjevov you're right, I saw it working for find all references.

@atscott got it! I already upvoted

@atscott
Copy link
Collaborator

atscott commented Mar 1, 2021

Codelens also needs some work, so only find all references should be working.

In reference to Codelens, there is no way to augment those results with ours. We can consider providing our own, separate lens in addition to the typescript one that could say something like “# references in templates” but we can’t include our results in the same one that’s already there.

@erosostolato
Copy link

erosostolato commented Mar 1, 2021

Codelens also needs some work, so only find all references should be working.

In reference to Codelens, there is no way to augment those results with ours. We can consider providing our own, separate lens in addition to the typescript one that could say something like “# references in templates” but we can’t include our results in the same one that’s already there.

@atscott I liked the idea of having “# references in templates”. That could work as a notice for the developer that wants to rename a variable, so he can go to the template and rename it from there.

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Apr 1, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature ivy Feature / enhancement / bug fix in Ivy lib Relates to an issue in the @angular/language-service library
Projects
None yet
Development

Successfully merging a pull request may close this issue.