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

Reference provider #341

Open
godric3 opened this issue Nov 12, 2021 · 1 comment
Open

Reference provider #341

godric3 opened this issue Nov 12, 2021 · 1 comment

Comments

@godric3
Copy link

godric3 commented Nov 12, 2021

I thought about rename symbol functionality for translations, but came to conclusion that it will be nice to first have references for them.
First idea is to get all project files(project.registry?) and for all of them create AST, then find all nodes that are localization helpers, and then return those that have matching translation key. On first look it seems it should be working, but I'm concerned about performance of that solution.

  1. Is there better idea how to implement reference provider?
  2. If not, should I be concerned about performance?
@lifeart
Copy link
Owner

lifeart commented Nov 12, 2021

We already have extract template tokens functionality for "component usages" provider - https://github.com/lifeart/ember-language-server/blob/component-context-info-origin/src/utils/template-tokens-collector.ts#L171 and https://github.com/lifeart/ember-language-server/blob/component-context-info-origin/src/utils/usages-api.ts#L161

  1. I think we could add one more store, especially for "translations" to keep it in a same way as we do for component names today, also, we could extend it to store token location (shape - to be defined, because we should keep it mind refactoring support)

may be:

{
   'token.name': [
       locales: [
          {name, file, range (position) }
       ],
       usages: [
         { file, range (position) }
       ]
    ]
}
  1. token collection performed using "setTimeout" and not block main loop, but we have an side task for it - collect template tokens in a new process [perf-improvement] #261 (I not consider it as urgent right now, and we have to be able to keep same-process-implementation to work in web-worker)

Also, we could land refactoring provider as part of addon API, right now LS does not support it

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

No branches or pull requests

2 participants