Skip to content
Open
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
13 changes: 11 additions & 2 deletions php-templates/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@ public function all()
->merge($this->getFolioRoutes());
}

protected function getRelativePath($path)
{
$basePath = base_path() . DIRECTORY_SEPARATOR;
if (str_starts_with($path, $basePath)) {
return substr($path, strlen($basePath));
}
return $path;
}

protected function getFolioRoutes()
{
try {
Expand Down Expand Up @@ -43,7 +52,7 @@ protected function getFolioRoute($route, $mountPaths)
'name' => $route['name'],
'action' => null,
'parameters' => [],
'filename' => $path,
'filename' => $this->getRelativePath($path),
'line' => 0,
];
}
Expand All @@ -64,7 +73,7 @@ protected function getRoute(\Illuminate\Routing\Route $route)
'name' => $route->getName(),
'action' => $route->getActionName(),
'parameters' => $route->parameterNames(),
'filename' => $reflection ? $reflection->getFileName() : null,
'filename' => $reflection ? $this->getRelativePath($reflection->getFileName()) : null,
'line' => $reflection ? $reflection->getStartLine() : null,
];
}
Expand Down
2 changes: 1 addition & 1 deletion src/features/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export const linkProvider: LinkProvider = (doc: vscode.TextDocument) => {

return new vscode.DocumentLink(
detectedRange(param),
vscode.Uri.file(route.filename).with({
vscode.Uri.file(projectPath(route.filename)).with({
fragment: `L${route.line ?? 0}`,
}),
);
Expand Down
13 changes: 11 additions & 2 deletions src/templates/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@ $routes = new class {
->merge($this->getFolioRoutes());
}

protected function getRelativePath($path)
{
$basePath = base_path() . DIRECTORY_SEPARATOR;
if (str_starts_with($path, $basePath)) {
return substr($path, strlen($basePath));
}
return $path;
}

protected function getFolioRoutes()
{
try {
Expand Down Expand Up @@ -43,7 +52,7 @@ $routes = new class {
'name' => $route['name'],
'action' => null,
'parameters' => [],
'filename' => $path,
'filename' => $this->getRelativePath($path),
'line' => 0,
];
}
Expand All @@ -64,7 +73,7 @@ $routes = new class {
'name' => $route->getName(),
'action' => $route->getActionName(),
'parameters' => $route->parameterNames(),
'filename' => $reflection ? $reflection->getFileName() : null,
'filename' => $reflection ? $this->getRelativePath($reflection->getFileName()) : null,
'line' => $reflection ? $reflection->getStartLine() : null,
];
}
Expand Down