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

fix(language-service): Do not include $event parameter in reference r… #40158

Closed
wants to merge 1 commit into from

Conversation

atscott
Copy link
Contributor

@atscott atscott commented Dec 16, 2020

…esults

Given the template
<div (click)="doSomething($event)"></div>

If you request references for the $event, the results include both $event and (click)="doSomething($event)".

This happens because in the TCB, $event is passed to the subscribe/addEventListener
function as an argument. So when we ask typescript to give us the references, we
get the result from the usage in the subscribe body as well as the one passed in as an argument.

This commit adds an identifier to the $event parameter in the TCB so
that the result returned from getReferencesAtPosition can be
identified and filtered out.

fixes #40157

@atscott atscott added action: review The PR is still awaiting reviews from at least one requested reviewer area: language-service Issues related to Angular's VS Code language service area: compiler Issues related to `ngc`, Angular's template compiler target: minor This PR is targeted for the next minor release labels Dec 16, 2020
@ngbot ngbot bot added this to the Backlog milestone Dec 16, 2020
@google-cla google-cla bot added the cla: yes label Dec 16, 2020
packages/language-service/ivy/ts_utils.ts Outdated Show resolved Hide resolved
…esults

Given the template
`<div (click)="doSomething($event)"></div>`

If you request references for the `$event`, the results include both `$event` and `(click)="doSomething($event)"`.

This happens because in the TCB, `$event` is passed to the `subscribe`/`addEventListener`
function as an argument. So when we ask typescript to give us the references, we
get the result from the usage in the subscribe body as well as the one passed in as an argument.

This commit adds an identifier to the `$event` parameter in the TCB so
that the result returned from `getReferencesAtPosition` can be
identified and filtered out.

fixes angular#40157
Copy link
Contributor

@zarend zarend left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@@ -107,6 +107,22 @@ describe('find references', () => {
assertTextSpans(refs, ['title']);
});

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion

It gets a $event's reference to itself in a method call argument.

It's more helpful to maintainers to describe what the expected be behavior is, rather than say it should "work" :). What does "it works" mean.

Also, do you know if we have an official guide or code style on writing tests?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Taking the above describe, the full description of this test would read find references should work for $event in method call arguments. Is that not descriptive enough?

No, there's no explicit style guide for tests.

@atscott atscott added this to PRs In Review in Ivy Language Service Dec 17, 2020
@atscott atscott added the action: merge The PR is ready for merge by the caretaker label Jan 4, 2021
@ngbot
Copy link

ngbot bot commented Jan 4, 2021

I see that you just added the action: merge label, but the following checks are still failing:
    failure status "google3" is failing
    pending forbidden labels detected: action: review

If you want your PR to be merged, it has to pass all the CI checks.

If you can't get the PR to a green state due to flakes or broken master, please try rebasing to master and/or restarting the CI job. If that fails and you believe that the issue is not due to your change, please contact the caretaker and ask for help.

@atscott atscott removed the action: review The PR is still awaiting reviews from at least one requested reviewer label Jan 4, 2021
@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 Feb 5, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker area: compiler Issues related to `ngc`, Angular's template compiler area: language-service Issues related to Angular's VS Code language service cla: yes target: minor This PR is targeted for the next minor release
Projects
No open projects
Ivy Language Service
  
PRs In Review
4 participants