Skip to content

Deduplicate call hierarchy call-site ranges - #65566

Open
Daniel Rosenwasser (DanielRosenwasser) wants to merge 5 commits into
mainfrom
copilot/fix-duplicate-callsite-ranges
Open

Daniel Rosenwasser (DanielRosenwasser) wants to merge 5 commits into
mainfrom
copilot/fix-duplicate-callsite-ranges

Conversation

@DanielRosenwasser

@DanielRosenwasser Daniel Rosenwasser (DanielRosenwasser) commented Nov 18, 2026 •

Copy link
Copy Markdown
Member

Call hierarchy results could report the same source range multiple times when a call-site AST was reached through both a call expression and its target property access.

  • Behavior: Sort and compact incoming/outgoing fromRanges, preserving distinct source occurrences while removing exact duplicates.
  • Coverage: Add a fourslash regression test for an interface method call and verify it produces one outgoing range.

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
@typescript-automation typescript-automation Bot added For Uncommitted Bug PR for untriaged, rejected, closed or missing bug and removed For Milestone Bug PRs that fix a bug with a specific milestone labels Nov 18, 2026
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
@DanielRosenwasser Daniel Rosenwasser (DanielRosenwasser) changed the title [WIP] Fix duplicate callsite ranges for method call Deduplicate call hierarchy call-site ranges Nov 18, 2026
@DanielRosenwasser
Daniel Rosenwasser (DanielRosenwasser) marked this pull request as ready for review November 18, 2026 21:46
Copilot AI balanced review requested due to automatic review settings November 18, 2026 21:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues were identified in the call-hierarchy range deduplication change.

No open issues 🎉

What changed in this PR

Fixes #65526 by removing duplicate call-site ranges from the language server’s call hierarchy results while preserving distinct source occurrences.

Changes:

  • Compact sorted incoming and outgoing fromRanges to remove exact duplicates.
  • Add a fourslash regression test and baseline confirming one outgoing range for a single interface method call.
File Description
tsc/​testdata/​baselines/​reference/​fourslash/​callHierarchy/​callHierarchyOutgoingInterfaceMethod.callHierarchy.txt Records the expected single outgoing call-site range.
tsc/​internal/​ls/​callhierarchy.go Deduplicates incoming and outgoing call-site ranges after sorting.
tsc/​internal/​fourslash/​tests/​callHierarchyInterfaceMethod_test.go Adds regression coverage for an interface method call.

Review effort: Balanced

@DanielRosenwasser

Copy link
Copy Markdown
Member Author

Copilot this is probably fine in part, but part of the issue is that we doubly-add the same node based on how recordCallSite works. We shouldn't double up the work to then get rid of the duplicates.

Let's add an exception to when the parent of a property/element access expression is the target of a call-like node (or have a flag on collect to exempt the current child node for calls on the Expression()).

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>

Copilot AI commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

Copilot this is probably fine in part, but part of the issue is that we doubly-add the same node based on how recordCallSite works. We shouldn't double up the work to then get rid of the duplicates...

Updated the collector to avoid recording a property/element access already used as a call-like target, and removed outgoing-range compaction. The focused regression and full validation pass. Commit: 08a4582.

}

slices.SortFunc(fromRanges, lsproto.CompareRanges)
fromRanges = slices.Compact(fromRanges)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Copilot for symmetry both sides should still have the Compact call.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Restored slices.Compact for outgoing ranges to match incoming handling. Focused tests and npx hereby validate pass. Commit: fe07e61.

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Duplicate callsite ranges for a single method call in callHierarchy/outgoingCalls

4 participants