Skip to content

feat: Laravel string key completion, hover, and diagnostics#231

Open
calebdw wants to merge 2 commits into
mainfrom
calebdw/push-qsvttzqlxnsr
Open

feat: Laravel string key completion, hover, and diagnostics#231
calebdw wants to merge 2 commits into
mainfrom
calebdw/push-qsvttzqlxnsr

Conversation

@calebdw

@calebdw calebdw commented Jul 12, 2026

Copy link
Copy Markdown
Collaborator

Add autocompletion, hover, and invalid-key diagnostics for route names, config keys, view names, and translation keys.

Completion

  • route('|') / to_route('|') → route names from routes/*.php
  • config('|') / Config::get('|') → config keys from config/*.php
  • view('|') / View::make('|') → view templates from resources/views/
  • __('|') / trans('|') / Lang::get('|') → translation keys from lang/
  • Route::resource() / apiResource() with ->only() / ->except()
  • Route::group([], __DIR__ . '/sub.php') file includes with prefix propagation
  • Container attributes (#[Config], #[Database], #[Cache], #[Log], #[Storage], #[Auth]) with FQN-verified imports
  • Facade methods (Auth::guard(), DB::connection(), Cache::store(), Log::channel(), Storage::disk()) and auth() helper
  • TextEdit-based so dots don't break the completion popup

Hover

  • Shows key kind (Route/Config/View/Trans), the key value, and the file where it's defined

Diagnostics

  • Warns on unknown route names, config keys, view names, and translation keys (e.g. Unknown route: 'dashbaord')
  • Only flags plain string literals, not dynamic/interpolated keys

Also

  • to_route() added to extraction spans for go-to-def and find-references
  • Go-to-definition follows Route::group([], __DIR__ . '/sub.php') file includes with prefix propagation
  • Go-to-definition resolves Route::resource() / apiResource() routes

@calebdw calebdw requested a review from AJenbo July 12, 2026 01:40
@calebdw calebdw force-pushed the calebdw/push-qsvttzqlxnsr branch 2 times, most recently from 9bdf8d3 to 8701e88 Compare July 12, 2026 01:44
@codecov-commenter

codecov-commenter commented Jul 12, 2026

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 36.99706% with 642 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/virtual_members/laravel/route_names.rs 13.29% 300 Missing ⚠️
src/completion/laravel_string_keys.rs 62.55% 167 Missing ⚠️
src/diagnostics/mod.rs 16.94% 98 Missing ⚠️
src/hover/mod.rs 1.72% 57 Missing ⚠️
src/symbol_map/extraction.rs 45.00% 11 Missing ⚠️
src/virtual_members/laravel/trans_keys.rs 69.23% 8 Missing ⚠️
src/completion/handler.rs 80.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@calebdw calebdw force-pushed the calebdw/push-qsvttzqlxnsr branch from 8701e88 to ce5e6cc Compare July 12, 2026 01:55
@calebdw calebdw changed the title feat: Laravel string key completion (route, config, view, trans) feat: Laravel string key completion, hover, and diagnostics Jul 12, 2026
@AJenbo

AJenbo commented Jul 12, 2026

Copy link
Copy Markdown
Contributor
  • We should make sure that __() is actually the one from Laravel and not GetText or WordPress.
  • Should we also check `lang/en.json`` style translations?
  • Will it flag translations as missing if I use a DB provider rather then static json?
  • Should config('unknown', 'default') still produce a warning?

@calebdw

calebdw commented Jul 13, 2026

Copy link
Copy Markdown
Collaborator Author

We should make sure that __() is actually the one from Laravel and not GetText or WordPress.

Fixed — trans diagnostics now skip entirely when no lang/ translation files are found in the project. This prevents false-positive "Unknown translation key" warnings in WordPress/GetText projects that also use __(). Completion already returned nothing when no keys exist, so this just brings diagnostics in line.

Should we also check lang/en.json style translations?

Added in 268bce6. Both completion and diagnostics now scan lang/*.json and resources/lang/*.json on disk for flat JSON translations ({"Some phrase": "Translated phrase"}). Go-to-definition also resolves JSON translation keys.

Will it flag translations as missing if I use a DB provider rather than static json?

If there are no file-based translation files at all (PHP or JSON), trans diagnostics are skipped entirely (see point 1). If you have some file-based translations alongside a DB provider, keys only in the DB will be flagged. To handle that case, the diagnostic code is now invalid_laravel_trans (see below) which can be individually disabled in config.

Should config('unknown', 'default') still produce a warning?

Keeping the warning — a default value is a safety net, not an indication the key is intentionally wrong. A typo like config('app.tiemzone', 'UTC') should still be caught.


Also split the single invalid_laravel_key diagnostic code into per-kind codes so each category can be independently disabled:

  • invalid_laravel_route
  • invalid_laravel_config
  • invalid_laravel_view
  • invalid_laravel_trans

@calebdw calebdw force-pushed the calebdw/push-qsvttzqlxnsr branch from 268bce6 to 017a134 Compare July 13, 2026 00:28
calebdw added 2 commits July 12, 2026 19:32
Add autocompletion, hover, and invalid-key diagnostics for route names,
config keys, view names, and translation keys.

Completion:
- route('|') / to_route('|') -> route names from routes/*.php
- config('|') / Config::get('|') -> config keys from config/*.php
- view('|') / View::make('|') -> view templates from resources/views/
- __('|') / trans('|') / Lang::get('|') -> translation keys from lang/
- Route::resource() / apiResource() with ->only() / ->except()
- Route::group([], __DIR__ . '/sub.php') file includes with prefix
- Container attributes (#[Config], #[Database], #[Cache], #[Log],
  #[Storage], #[Auth]) with FQN-verified imports
- Facade methods (Auth::guard(), DB::connection(), Cache::store(),
  Log::channel(), Storage::disk()) and auth() helper
- TextEdit-based so dots don't break the completion popup

Hover:
- Shows key kind (Route/Config/View/Trans), the key value, and
  the file where it's defined

Diagnostics:
- Warns on unknown route names, config keys, view names, and
  translation keys (e.g. Unknown route: 'dashbaord')
- Only flags plain string literals, not dynamic/interpolated keys

Also adds to_route() to extraction spans for go-to-def/references.
…afety

- Add lang/en.json support for completion, diagnostics, and go-to-definition
  (Laravel JSON translations are flat {"key": "value"} objects)
- Skip trans diagnostics when no lang files exist, avoiding false positives
  in WordPress/GetText projects that also use __() / trans()
- Split diagnostic code into per-kind codes (invalid_laravel_route,
  invalid_laravel_config, invalid_laravel_view, invalid_laravel_trans)
  so users can selectively disable categories via config
@calebdw calebdw force-pushed the calebdw/push-qsvttzqlxnsr branch from 017a134 to 99e375e Compare July 13, 2026 00:32
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.

3 participants