Skip to content

Commit f973583

Browse files
committed
discover nested components
1 parent 1e7edd6 commit f973583

File tree

6 files changed

+22
-11
lines changed

6 files changed

+22
-11
lines changed

CHANGELOG.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
# Change Log
22

3-
All notable changes to the "laravel-goto-components" extension will be documented in this file.
3+
## [v1.1.0](https://github.com/naoray/laravel-factory-prefill/tree/v1.0.0) (2020-12-10)
44

5-
Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file.
5+
**Added**
6+
- quick navigation for nested components like `x-input.button`
67

7-
## [Unreleased]
8+
## [v1.0.0](https://github.com/naoray/laravel-factory-prefill/tree/v1.0.0) (2020-12-09)
89

9-
- Initial release
10+
**Added**
11+
- `CTRL` + `click` to navigate `x-components` in the `components` directory
12+
- display existing components in `blade.php` files as links

icon.png

1.6 KB
Loading

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"displayName": "laravel-goto-components",
44
"description": "Quick jump to components",
55
"icon": "icon.png",
6-
"version": "1.0.2",
6+
"version": "1.1.0",
77
"publisher": "naoray",
88
"repository": "https://github.com/naoray/laravel-goto-components.git",
99
"engines": {
@@ -27,7 +27,7 @@
2727
"properties": {
2828
"laravel_goto_components.regex": {
2929
"type": "string",
30-
"default": "(?<=<x-)(?!slot)[a-z-]+",
30+
"default": "(?<=<x-)(?!slot)[a-z.-]+",
3131
"description": "Custom regex for matching strings"
3232
}
3333
}

src/hoverProvider.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
workspace,
1010
ProviderResult,
1111
} from "vscode";
12+
import { nameToPath } from "./utils";
1213

1314
export default class HoverProvider implements BaseHoverProvider {
1415
public provideHover(
@@ -24,7 +25,7 @@ export default class HoverProvider implements BaseHoverProvider {
2425
}
2526

2627
const componentName = doc.getText(range);
27-
const componentPath = `/resources/views/components/${componentName}.blade.php`;
28+
const componentPath = nameToPath(componentName);
2829
const workspacePath = workspace.getWorkspaceFolder(doc.uri)?.uri.fsPath;
2930

3031
if (!existsSync(workspacePath + componentPath)) {

src/linkProvider.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
DocumentLink,
1212
Range,
1313
} from "vscode";
14+
import { nameToPath } from "./utils";
1415

1516
export default class LinkProvider implements DocumentLinkProvider {
1617
public provideDocumentLinks(
@@ -30,12 +31,15 @@ export default class LinkProvider implements DocumentLinkProvider {
3031
let result = line.text.match(reg);
3132

3233
if (result !== null) {
33-
for (let item of result) {
34-
const componentPath = `/resources/views/components/${item}.blade.php`;
34+
for (let componentName of result) {
35+
const componentPath = nameToPath(componentName);
3536

3637
if (existsSync(workspacePath + componentPath)) {
37-
let start = new Position(line.lineNumber, line.text.indexOf(item));
38-
let end = start.translate(0, item.length);
38+
let start = new Position(
39+
line.lineNumber,
40+
line.text.indexOf(componentName)
41+
);
42+
let end = start.translate(0, componentName.length);
3943
let documentlink = new DocumentLink(
4044
new Range(start, end),
4145
Uri.file(workspacePath + componentPath)

src/utils.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export function nameToPath(path: string): string {
2+
return `/resources/views/components/${path.replace(/\./g, "/")}.blade.php`;
3+
}

0 commit comments

Comments
 (0)