lifeart/ember-language-server

Reference provider

godric3 opened this issue · 1 comments

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?

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 - #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