microsoft / microsoft/TypeScript

[tsserver] add support to fetch symbol references from only the current file.

Open
#60,763 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Awaiting More Feedback Suggestion
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
2d 4h
Merged PRs (30d)
132

Description

🔍 Search Terms

Hey.
it will be awesome if the "references" command can only get references of a symbol at position (x,y) but only inside the current file.

✅ Viability Checklist
⭐ Suggestion

this can be added using currentFileOnly?: boolean; (like that inside interface NavtoRequestArgs).

📃 Motivating Example

i use it mainly for rewriting javascript files (usually obfuscated ones), so for each symbol i need to get all references but only for the currently opened file, so i wish there was a flag for it. as i thought it will be more performant (i.e. instead of searching references all across the project, if we restricted it to the current file - by a flag in a the request - then it can be more performant due to reduced search space?)

💻 Use Cases
  1. What do you want to use this for?
  • rewriting js files accurately.
  1. What shortcomings exist with current approaches?
  • performance issues.
  1. What workarounds are you using in the meantime?
  • requesting references then filtering them if the ref['file'] key is the same as that supplied in references request. however, i think tsserver can be more performant than this approach.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the tsserver references request and compare its arguments with NavtoRequestArgs, which the issue cites as a precedent. Determine the request and response paths affected, then add and validate a current-file-only option so references can be limited to the supplied file without changing existing behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.