-
Notifications
You must be signed in to change notification settings - Fork 24.8k
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): prune duplicate returned definitions #34995
Conversation
02af21a
to
69e1c34
Compare
const signature = `${textSpan.start}:${textSpan.length}@${fileName}`; | ||
if (seen.has(signature)) continue; |
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.
@kyliau I don't think we'll be able to use uniqueBySpan
because we need to sign the filename as well. I can make a util function extending uniqueBySpan
in either this or a future PR.
Sometimes, a request for definitions will return multiple of the same definition. This can happen in at least the cases of - two-way bindings (one of the same definition for the property and event binding) - multiple template binding expressions in the same attribute - something like "*ngFor="let i of items; trackBy: test" has two template bindings, resulting in two template binding ASTs at the same location (the attribute span). The language service then parses both of these bindings individually, resulting in two independent but identical definitions. For more context, see angular#34847 (comment). This commit prunes duplicate definitions by signing definitions with their location, and checking if that location signature has been seen in a previous definition returned to the client.
69e1c34
to
e5b3d16
Compare
Sometimes, a request for definitions will return multiple of the same definition. This can happen in at least the cases of - two-way bindings (one of the same definition for the property and event binding) - multiple template binding expressions in the same attribute - something like "*ngFor="let i of items; trackBy: test" has two template bindings, resulting in two template binding ASTs at the same location (the attribute span). The language service then parses both of these bindings individually, resulting in two independent but identical definitions. For more context, see #34847 (comment). This commit prunes duplicate definitions by signing definitions with their location, and checking if that location signature has been seen in a previous definition returned to the client. PR Close #34995
…34995) Sometimes, a request for definitions will return multiple of the same definition. This can happen in at least the cases of - two-way bindings (one of the same definition for the property and event binding) - multiple template binding expressions in the same attribute - something like "*ngFor="let i of items; trackBy: test" has two template bindings, resulting in two template binding ASTs at the same location (the attribute span). The language service then parses both of these bindings individually, resulting in two independent but identical definitions. For more context, see angular#34847 (comment). This commit prunes duplicate definitions by signing definitions with their location, and checking if that location signature has been seen in a previous definition returned to the client. PR Close angular#34995
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Sometimes, a request for definitions will return multiple of the same
definition. This can happen in at least the cases of
event binding)
template bindings, resulting in two template binding ASTs at the
same location (the attribute span). The language service then parses
both of these bindings individually, resulting in two independent
but identical definitions. For more context, see feat(language-service): provide hover for microsyntax in structural directive #34847 (comment).
This commit prunes duplicate definitions by signing definitions with
their location, and checking if that location signature has been seen in
a previous definition returned to the client.
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
Does this PR introduce a breaking change?