Skip to content

feat: AppLocalizations CodeLens preview in Dart code#89

Open
Zensonaton wants to merge 8 commits into
google:mainfrom
Zensonaton:feat/applocalizations-codelens-preview
Open

feat: AppLocalizations CodeLens preview in Dart code#89
Zensonaton wants to merge 8 commits into
google:mainfrom
Zensonaton:feat/applocalizations-codelens-preview

Conversation

@Zensonaton
Copy link
Copy Markdown

@Zensonaton Zensonaton commented Apr 22, 2026

What is it?

This PR introduces CodeLens support for Dart files that use AppLocalizations class. The feature can be configured via VS Code settings:

image image

How it works

The current algorithm scans Dart code for usages of AppLocalizations. When it infers that a given symbol (e.g., a variable) might be an instance of the AppLocalizations class, it issues a Dart LSP request to verify the actual type.

Notes

  1. It’s unclear whether this feature should be enabled by default. You can easily disable it by changing the default value in package.json.
  2. The feature might introduce a slight performance overrhead. In practice, no issues were observed during testing on a real Flutter project, since CodeLens is only computed for the currently open file.

Future ideas

  1. Clicking a CodeLens currently has no effect. A reasonable next step would be to open the corresponding .arb file on click.
  2. Refactoring support from the Dart side. For example, renaming AppLocalizations.helloWorld could propagate the change to the helloWorld key across all .arb files.
  3. "Go to Implementation" in Dart code (Ctrl + Click) should navigate to the relevant .arb entry instead of AppLocalizations.dart.
  4. "Go to Implementation" in .arb files should navigate to the template .arb file.
  5. "Go to References" in .arb files (Shift + F12) should show all Dart code usages.

I'm not exactly sure if that setting is supposed to be enabled by default.
My "format on save" VSCode setting was removing those semicolons.
I've had to enable that in the eslint config so there wouldn't be a lot of unnecessary changes.
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.

1 participant