[tsserver] add support to fetch symbol references from only the current file.Β #60763
Open
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
- This wouldn't be a breaking change in existing TypeScript/JavaScript code
- This wouldn't change the runtime behavior of existing JavaScript code
- This could be implemented without emitting different JS based on the types of the expressions
- This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
- This isn't a request to add a new utility type: https://github.com/microsoft/TypeScript/wiki/No-New-Utility-Types
- This feature would agree with the rest of our Design Goals: https://github.com/Microsoft/TypeScript/wiki/TypeScript-Design-Goals
β 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
- What do you want to use this for?
- rewriting js files accurately.
- What shortcomings exist with current approaches?
- performance issues.
- 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.