sublimelsp / LSP-typescript

TypeScript, JavaScript support for Sublime LSP plugin
MIT License
136 stars 11 forks source link

Implement a custom "find callers" command #90

Closed rchl closed 3 years ago

rchl commented 3 years ago

typescript-language-server implements a custom "textDocument/calls" request which is a lot like normal "find references" but it skips all references that are not calling the symbol. So it filters a lot of noise like references to function being imported or just passed around.

The "textDocument/calls" request supports finding both callers (implemented here) and a sort of an opposite mode of operation where it finds all functions called inside the selected symbol (function). I find that kinda useless so didn't implement it but it can be easily added by creating another lsp_typescript_calls command and passing "direction": "outgoing" argument to it.

rchl commented 3 years ago

As @predragnikolic pointed out, this is basically the "call hierarchy" feature (LSP issue: https://github.com/sublimelsp/LSP/issues/1429) but done through a custom request since the official one wasn't specified at that point.

Having a proper UI for it, like VSCode has for example, is either not doable with the current ST APIs or would require some hacky panel implementation.

I think that just exposing this functionality to find callers is useful enough on its own.