feat: Laravel string key completion, hover, and diagnostics#231
feat: Laravel string key completion, hover, and diagnostics#231calebdw wants to merge 2 commits into
Conversation
9bdf8d3 to
8701e88
Compare
|
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
8701e88 to
ce5e6cc
Compare
|
Fixed — trans diagnostics now skip entirely when no
Added in 268bce6. Both completion and diagnostics now scan
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
Keeping the warning — a default value is a safety net, not an indication the key is intentionally wrong. A typo like Also split the single
|
65fe16a to
e947041
Compare
|
@AJenbo, thoughts on merging this? |
f13159e to
ed106e1
Compare
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.
ed106e1 to
4219692
Compare
Scan service providers for mergeConfigFrom(), loadViewsFrom(),
loadTranslationsFrom(), loadJsonTranslationsFrom(), and
loadRoutesFrom() calls. Resolve __DIR__-relative paths to the
actual package files on disk and feed the results into the
existing string key infrastructure.
This enables completion, go-to-definition, and hover for config
keys, view templates, translation keys, and named routes that
are registered by installed packages rather than defined in the
app itself. For example, config("horizon.environments") now
completes and jumps to the key in vendor/laravel/horizon/config/
horizon.php, and view("horizon::layout") resolves to the
package view directory.
The scanner reuses the same provider list and one-level-deep
helper class traversal already used by macro discovery.
Discovered resources are cached on Backend and invalidate the
string key caches when populated.
Key changes:
- New provider_resources.rs with ProviderResource,
ProviderResources, and extract_provider_resources()
- extract_dir_concat_path() moved from route_names.rs to
helpers.rs for shared use
- build_provider_resources() in server.rs walks providers
and their referenced classes
- enumerate_all_{config_keys,view_names,trans_keys}() and
enumerate_all_route_names() extended to include package
resources
- resolve_{config_key,view,trans,route}_definitions() extended
to handle namespaced package keys (ns::key, ns.key)
4219692 to
2cd7f6d
Compare
|
One of my regression test projects died and maybe this is a good time to update them all to the latest version. This will take a bit of time to align everything and so I would rather we delay this as a merge right after the release of 0.9.0. |
Summary
Add autocompletion, hover, and invalid-key diagnostics for route names, config keys, view names, and translation keys. Also discovers package-registered resources from service providers.
Completion
route('|')/to_route('|')— route names fromroutes/*.phpconfig('|')/Config::get('|')— config keys fromconfig/*.phpview('|')/View::make('|')— view templates fromresources/views/__('|')/trans('|')/Lang::get('|')— translation keys fromlang/Route::resource()/apiResource()with->only()/->except()Route::group([], __DIR__ . '/sub.php')file includes with prefix propagation#[Config],#[Database],#[Cache],#[Log],#[Storage],#[Auth]) with FQN-verified importsAuth::guard(),DB::connection(),Cache::store(),Log::channel(),Storage::disk()) andauth()helperHover
Diagnostics
Unknown route: 'dashbaord')invalid_laravel_route,invalid_laravel_config,invalid_laravel_view,invalid_laravel_trans) so each can be independently disabledlang/translation files exist (avoids false positives in WordPress/GetText projects)Package Resource Discovery
Scans all registered service providers for resource registration calls and feeds the results into the string key infrastructure:
mergeConfigFrom(path, 'ns')config('ns.key')loadViewsFrom(path, 'ns')view('ns::template')loadTranslationsFrom(path, 'ns')trans('ns::file.key')loadJsonTranslationsFrom(path)loadRoutesFrom(path)__DIR__.'/../../config/foo.php'paths to actual package files on diskconfig('horizon.environments')) and namespaced views/translationsAlso
to_route()added to extraction spans for go-to-def and find-referencesRoute::group([], __DIR__ . '/sub.php')file includes with prefix propagationRoute::resource()/apiResource()routes