diff --git a/lib/place.py b/lib/place.py index 24cf444..1e01569 100644 --- a/lib/place.py +++ b/lib/place.py @@ -22,6 +22,8 @@ class_controller_pattern = compile(r"(.+)\.php\s*,\s*[\"']{1}(.+)") +component_pattern = compile(r"<\/?x-([^\/>]*)") + extensions = [] @@ -159,6 +161,10 @@ def env_place(path, line, selected): def view_place(path, line, selected): + matched = component_pattern.search(line) + if matched: + path = matched.group(1).strip() + split = path.split(':') vendor = '' # vendor or namespace @@ -168,7 +174,12 @@ def view_place(path, line, selected): vendor = split[0] + '/' path = split[-1] - path = vendor + path.replace('.', '/') + '.blade.php' + path = vendor + path.replace('.', '/') + if matched: + path += '.php' + else: + path += '.blade.php' + return Place(path) diff --git a/lib/selection.py b/lib/selection.py index cc7b6c9..7f6055d 100644 --- a/lib/selection.py +++ b/lib/selection.py @@ -29,7 +29,7 @@ def get_selection(self): selected = self.view.extract_scope(start) if self.line.contains(selected): if self.is_class: - selected = self.get_selected_by_delimiters(selected, ',[', '])') + selected = self.get_selected_by_delimiters(selected, ',[<', '>])') return selected return self.get_selected_by_delimiters(selected, self.delimiters) diff --git a/readme.md b/readme.md index 0e90a7d..3e8b01b 100644 --- a/readme.md +++ b/readme.md @@ -10,11 +10,15 @@ Goto various Laravel files ## Feature -- Go to Blade Template files *(EX. hello.blade.php)* +- Go to Blade Template files (EX. hello.blade.php) -- Go to Controller and highlight method *(EX. \Namespace\Controller.php@Method)* +- Go to Blade Component files (EX. <x-alert>) -- Go to Static files (*EX. hello.js*) +- Go to Blade Template files (EX. hello.blade.php) + +- Go to Controller and highlight method (EX. \Namespace\Controller.php@Method) + +- Go to Static files (EX. hello.js) - Go to Config files and highlight option (EX. config/app.php) diff --git a/tests/sample.php b/tests/sample.php index 8c3d036..9b08855 100644 --- a/tests/sample.php +++ b/tests/sample.php @@ -83,4 +83,10 @@ Route::group(['namespace' => 'L8'], function () { Route::get('/', [EightController::class, 'index']); -}); \ No newline at end of file +}); + + + + + + diff --git a/tests/test_place.py b/tests/test_place.py index f220c69..286103e 100644 --- a/tests/test_place.py +++ b/tests/test_place.py @@ -17,6 +17,30 @@ def test_controller(self): self.assertEqual(True, place.is_controller) self.assertEqual("HelloController.php@index", place.path) + def test_component(self): + self.fixture("""""") + + selection = Selection(self.view) + place = get_place(selection) + + self.assertEqual("form/input.php", place.path) + + def test_closing_tag_component(self): + self.fixture("""""") + + selection = Selection(self.view) + place = get_place(selection) + + self.assertEqual("alert.php", place.path) + + def test_component_with_namespace(self): + self.fixture("""""") + + selection = Selection(self.view) + place = get_place(selection) + + self.assertEqual("namespace/alert.php", place.path) + def test_view(self): self.fixture("""Route::get('/', function () { return view('hello|_view');