Skip to content

Commit 32d4755

Browse files
committed
support volt routes
1 parent c7fd315 commit 32d4755

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

src/features/route.ts

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import { notFound } from "@src/diagnostic";
22
import AutocompleteResult from "@src/parser/AutocompleteResult";
33
import { getRoutes } from "@src/repositories/routes";
4+
import { getViews } from "@src/repositories/views";
45
import { config } from "@src/support/config";
56
import { findHoverMatchesInDoc } from "@src/support/doc";
67
import { detectedRange, detectInDoc } from "@src/support/parser";
78
import { wordMatchRegex } from "@src/support/patterns";
8-
import { relativePath } from "@src/support/project";
9+
import { projectPath, relativePath } from "@src/support/project";
910
import { facade } from "@src/support/util";
1011
import { AutocompleteParsingResult } from "@src/types";
1112
import * as vscode from "vscode";
@@ -17,6 +18,11 @@ const toFind: FeatureTag = [
1718
class: [...facade("Redirect"), ...facade("URL"), "redirect", "url"],
1819
method: ["route", "signedRoute", "temporarySignedRoute"],
1920
},
21+
{
22+
class: ["Livewire\\Volt\\Volt"],
23+
method: ["route"],
24+
argumentIndex: 1,
25+
},
2026
];
2127

2228
const isCorrectIndexForMethod = (
@@ -28,6 +34,11 @@ const isCorrectIndexForMethod = (
2834
return index === 0;
2935
}
3036

37+
// @ts-ignore
38+
if (item.className === "Livewire\\Volt\\Volt") {
39+
return index === 1;
40+
}
41+
3142
return true;
3243
};
3344

@@ -41,6 +52,22 @@ export const linkProvider: LinkProvider = (doc: vscode.TextDocument) => {
4152
return null;
4253
}
4354

55+
// @ts-ignore
56+
if (item.className === "Livewire\\Volt\\Volt") {
57+
const view = getViews().items.find(
58+
(v) => v.key === `livewire.${param.value}`,
59+
);
60+
61+
if (!view) {
62+
return null;
63+
}
64+
65+
return new vscode.DocumentLink(
66+
detectedRange(param),
67+
vscode.Uri.file(projectPath(view.path)),
68+
);
69+
}
70+
4471
const route = getRoutes().items.find(
4572
(route) => route.name === param.value,
4673
);

0 commit comments

Comments
 (0)