Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions laravel-lsp/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15814,6 +15814,16 @@ return [
return out;
}
for r in route_refs {
// Wildcard patterns (e.g. `players.*`, `players.competitions.*`)
// reference a *family* of registered routes — `Route::has`,
// `routeIs`, Ziggy, etc. — and never appear verbatim in the index,
// so flagging them as "not found" is a false positive. Suppress the
// diagnostic for any name containing `*` (issue #209). Applied here,
// in the pure function before any I/O, so both the PHP and Blade
// call sites inherit it with no LSP restart or cache flush.
if r.name.contains('*') {
continue;
}
if index.get(&r.name).is_none() {
out.push(Diagnostic {
range: Range {
Expand Down
15 changes: 15 additions & 0 deletions laravel-lsp/src/tests/route_diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,18 @@ fn all_known_routes_flag_nothing() {
LaravelLanguageServer::route_not_found_diagnostics(Some(&idx), &[route_ref("home")]);
assert!(diags.is_empty());
}

#[test]
fn wildcard_route_names_flag_nothing() {
// Wildcard patterns (`players.*`, `players.competitions.*`) match a family
// of registered routes — `Route::has`, `routeIs`, Ziggy — and never appear
// verbatim in the index, so they must not be flagged as "not found" even
// against a non-empty index that holds no exact match for them (issue #209).
let idx = index_with(&["players.competitions.index", "players.competitions.create"]);
let refs = vec![route_ref("players.*"), route_ref("players.competitions.*")];
let diags = LaravelLanguageServer::route_not_found_diagnostics(Some(&idx), &refs);
assert!(
diags.is_empty(),
"wildcard route patterns must not be flagged as not found"
);
}