Skip to content
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

feat: reference/implementation codelens #2378

Merged
merged 12 commits into from
Jul 30, 2024

Conversation

jasonlyu123
Copy link
Member

#2130 Porting VSCode's implementation/reference code lens. This is not enabled by default. To enable this, you'll need to enable the typescript.implementationsCodeLens.enabled config or the typescript.referencesCodeLens.enabled config for lang="ts" and javascript.referencesCodeLens.enabled for js components. Note that we reuse config for ts/js files so it'll also enable the feature in ts/js files.

For non-VSCode users

Due to protocol limitations, this feature only partly works on other LSP clients. A client middleware is required to map reference info to references UI. So LSP client author might need to add support for it. For neovim-lsp users, you'll need a similar solution for the typescript language server.

Screenshots

圖片
(Yes. this will work for Svelte 5 props if it's a separate interface)

dummdidumm pushed a commit that referenced this pull request May 29, 2024
#2353

The reason is that VSCode requested document symbols twice for the outline view and the sticky scroll. We cancelled one of them so the outline view shows "no symbols found in document 'A.svelte'". It seems the VSCode ts extension also caches the result from tsserver, mostly because it'll also be used in code lens. But the result is mostly fast enough. A 5000-line file takes like 100ms so we probably don't need it now. We can probably reconsider if #2378 lands and see if there is a large performance regression.
@dummdidumm
Copy link
Member

Impressive! Out of curiousity: Do you have any idea why TS doesn't provide the code lens feature through its language service API? Is this something we should request to be added?

@jasonlyu123
Copy link
Member Author

No idea why, I guess they just thought it was simple enough and could be achieved with existing API.

@dummdidumm dummdidumm merged commit 6192d75 into sveltejs:master Jul 30, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants