├── .eslintrc.json ├── .gitignore ├── .vscodeignore ├── CHANGELOG.md ├── LICENSE ├── README.md ├── build └── node-extension.webpack.config.js ├── icon.png ├── package-lock.json ├── package.json ├── src ├── extension.ts ├── hoverProvider.ts ├── linkProvider.ts ├── test │ ├── runTest.ts │ └── suite │ │ ├── extension.test.ts │ │ └── index.ts └── utils.ts └── tsconfig.json /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "root": true, 3 | "parser": "@typescript-eslint/parser", 4 | "parserOptions": { 5 | "ecmaVersion": 6, 6 | "sourceType": "module" 7 | }, 8 | "plugins": [ 9 | "@typescript-eslint" 10 | ], 11 | "rules": { 12 | "@typescript-eslint/naming-convention": "warn", 13 | "@typescript-eslint/semi": "warn", 14 | "curly": "warn", 15 | "eqeqeq": "warn", 16 | "no-throw-literal": "warn", 17 | "semi": "off" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | out 2 | dist 3 | node_modules 4 | .vscode-test/ 5 | *.vsix 6 | -------------------------------------------------------------------------------- /.vscodeignore: -------------------------------------------------------------------------------- 1 | .vscode/** 2 | .vscode-test/** 3 | out/** 4 | src/** 5 | .gitignore 6 | .yarnrc 7 | vsc-extension-quickstart.md 8 | **/tsconfig.json 9 | **/.eslintrc.json 10 | **/*.map 11 | **/*.ts 12 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | ## [v1.2.0](https://github.com/naoray/laravel-factory-prefill/tree/v1.2.0) (2021-28-10) 4 | **Added** 5 | - support for anynomous component detection 6 | 7 | ## [v1.1.0](https://github.com/naoray/laravel-factory-prefill/tree/v1.1.0) (2020-12-10) 8 | 9 | **Added** 10 | - quick navigation for nested components like `x-input.button` 11 | 12 | ## [v1.0.0](https://github.com/naoray/laravel-factory-prefill/tree/v1.0.0) (2020-12-09) 13 | 14 | **Added** 15 | - `CTRL` + `click` to navigate `x-components` in the `components` directory 16 | - display existing components in `blade.php` files as links 17 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Krishan König 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Laravel-goto-components 2 | 3 | ![Installs](https://img.shields.io/visual-studio-marketplace/i/naoray.laravel-goto-components) 4 | 5 | ![go_to_component](https://user-images.githubusercontent.com/10154100/101707926-88ce8380-3a8c-11eb-9933-afd138ee69b8.gif) 6 | 7 | - :rocket: quick jump to components with `CTRL` + `click` 8 | - :mag: visual highlight of component links in `.blade` files 9 | -------------------------------------------------------------------------------- /build/node-extension.webpack.config.js: -------------------------------------------------------------------------------- 1 | //@ts-check 2 | 3 | 'use strict'; 4 | 5 | const path = require('path'); 6 | 7 | /**@type {import('webpack').Configuration}*/ 8 | const config = { 9 | target: 'node', // vscode extensions run in a Node.js-context 📖 -> https://webpack.js.org/configuration/node/ 10 | mode: 'none', // this leaves the source code as close as possible to the original (when packaging we set this to 'production') 11 | 12 | entry: './src/extension.ts', // the entry point of this extension, 📖 -> https://webpack.js.org/configuration/entry-context/ 13 | output: { 14 | // the bundle is stored in the 'dist' folder (check package.json), 📖 -> https://webpack.js.org/configuration/output/ 15 | path: path.resolve(__dirname, '..', 'dist'), 16 | filename: 'extension.js', 17 | libraryTarget: 'commonjs2' 18 | }, 19 | devtool: 'nosources-source-map', 20 | externals: { 21 | vscode: 'commonjs vscode' // the vscode-module is created on-the-fly and must be excluded. Add other modules that cannot be webpack'ed, 📖 -> https://webpack.js.org/configuration/externals/ 22 | }, 23 | resolve: { 24 | // support reading TypeScript and JavaScript files, 📖 -> https://github.com/TypeStrong/ts-loader 25 | extensions: ['.ts', '.js'] 26 | }, 27 | module: { 28 | rules: [ 29 | { 30 | test: /\.ts$/, 31 | exclude: /node_modules/, 32 | use: [ 33 | { 34 | loader: 'ts-loader' 35 | } 36 | ] 37 | } 38 | ] 39 | } 40 | }; 41 | module.exports = config; -------------------------------------------------------------------------------- /icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Naoray/laravel-goto-components/976dee31bb1259bcdf356ec8cc99d11c0ce7b83b/icon.png -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "laravel-goto-components", 3 | "displayName": "laravel-goto-components", 4 | "description": "Quick jump to components", 5 | "icon": "icon.png", 6 | "version": "1.2.0", 7 | "publisher": "naoray", 8 | "repository": "https://github.com/naoray/laravel-goto-components.git", 9 | "engines": { 10 | "vscode": "^1.51.0" 11 | }, 12 | "categories": [ 13 | "Other" 14 | ], 15 | "keywords": [ 16 | "PHP", 17 | "Laravel" 18 | ], 19 | "activationEvents": [ 20 | "onLanguage:blade" 21 | ], 22 | "main": "./dist/extension.js", 23 | "contributes": { 24 | "configuration": { 25 | "type": "object", 26 | "title": "Laravel goto components configuration", 27 | "properties": { 28 | "laravel_goto_components.regex": { 29 | "type": "string", 30 | "default": "(?<= { 19 | const config = workspace.getConfiguration("laravel_goto_components"); 20 | const regex = new RegExp(config.regex); 21 | const range = doc.getWordRangeAtPosition(position, regex); 22 | 23 | if (!range) { 24 | return; 25 | } 26 | 27 | const componentName = doc.getText(range); 28 | const workspacePath = workspace.getWorkspaceFolder(doc.uri)?.uri.fsPath; 29 | let componentPath = nameToPath(componentName); 30 | 31 | if (!existsSync(workspacePath + componentPath)) { 32 | componentPath = nameToIndexPath(componentName); 33 | 34 | if (!existsSync(workspacePath + componentPath)) { 35 | return; 36 | } 37 | } 38 | 39 | const lookUpUri = `[${componentPath}](${Uri.file( 40 | workspacePath + componentPath 41 | )})`; 42 | 43 | return new Hover(new MarkdownString(`*${componentName}*: ${lookUpUri}`)); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/linkProvider.ts: -------------------------------------------------------------------------------- 1 | import { existsSync } from "fs"; 2 | import { 3 | DocumentLinkProvider, 4 | Hover, 5 | MarkdownString, 6 | Position, 7 | TextDocument, 8 | Uri, 9 | workspace, 10 | ProviderResult, 11 | DocumentLink, 12 | Range, 13 | } from "vscode"; 14 | import { nameToIndexPath, nameToPath } from "./utils"; 15 | 16 | export default class LinkProvider implements DocumentLinkProvider { 17 | public provideDocumentLinks( 18 | doc: TextDocument 19 | ): ProviderResult { 20 | const documentLinks: DocumentLink[] = []; 21 | 22 | const config = workspace.getConfiguration("laravel_goto_components"); 23 | const workspacePath = workspace.getWorkspaceFolder(doc.uri)?.uri.fsPath; 24 | 25 | const reg = new RegExp(config.regex); 26 | let linesCount = doc.lineCount; 27 | 28 | let index = 0; 29 | while (index < linesCount) { 30 | let line = doc.lineAt(index); 31 | let result = line.text.match(reg); 32 | 33 | if (result !== null) { 34 | for (let componentName of result) { 35 | let componentPath = nameToPath(componentName); 36 | 37 | if (!existsSync(workspacePath + componentPath)) { 38 | componentPath = nameToIndexPath(componentName); 39 | 40 | if (!existsSync(workspacePath + componentPath)) { 41 | continue; 42 | } 43 | } 44 | 45 | let start = new Position( 46 | line.lineNumber, 47 | line.text.indexOf(componentName) 48 | ); 49 | let end = start.translate(0, componentName.length); 50 | let documentlink = new DocumentLink( 51 | new Range(start, end), 52 | Uri.file(workspacePath + componentPath) 53 | ); 54 | documentLinks.push(documentlink); 55 | } 56 | } 57 | 58 | index++; 59 | } 60 | 61 | return documentLinks; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/test/runTest.ts: -------------------------------------------------------------------------------- 1 | import * as path from 'path'; 2 | 3 | import { runTests } from 'vscode-test'; 4 | 5 | async function main() { 6 | try { 7 | // The folder containing the Extension Manifest package.json 8 | // Passed to `--extensionDevelopmentPath` 9 | const extensionDevelopmentPath = path.resolve(__dirname, '../../'); 10 | 11 | // The path to test runner 12 | // Passed to --extensionTestsPath 13 | const extensionTestsPath = path.resolve(__dirname, './suite/index'); 14 | 15 | // Download VS Code, unzip it and run the integration test 16 | await runTests({ extensionDevelopmentPath, extensionTestsPath }); 17 | } catch (err) { 18 | console.error('Failed to run tests'); 19 | process.exit(1); 20 | } 21 | } 22 | 23 | main(); 24 | -------------------------------------------------------------------------------- /src/test/suite/extension.test.ts: -------------------------------------------------------------------------------- 1 | import * as assert from 'assert'; 2 | 3 | // You can import and use all API from the 'vscode' module 4 | // as well as import your extension to test it 5 | import * as vscode from 'vscode'; 6 | // import * as myExtension from '../../extension'; 7 | 8 | suite('Extension Test Suite', () => { 9 | vscode.window.showInformationMessage('Start all tests.'); 10 | 11 | test('Sample test', () => { 12 | assert.strictEqual(-1, [1, 2, 3].indexOf(5)); 13 | assert.strictEqual(-1, [1, 2, 3].indexOf(0)); 14 | }); 15 | }); 16 | -------------------------------------------------------------------------------- /src/test/suite/index.ts: -------------------------------------------------------------------------------- 1 | import * as path from 'path'; 2 | import * as Mocha from 'mocha'; 3 | import * as glob from 'glob'; 4 | 5 | export function run(): Promise { 6 | // Create the mocha test 7 | const mocha = new Mocha({ 8 | ui: 'tdd', 9 | color: true 10 | }); 11 | 12 | const testsRoot = path.resolve(__dirname, '..'); 13 | 14 | return new Promise((c, e) => { 15 | glob('**/**.test.js', { cwd: testsRoot }, (err, files) => { 16 | if (err) { 17 | return e(err); 18 | } 19 | 20 | // Add files to the test suite 21 | files.forEach(f => mocha.addFile(path.resolve(testsRoot, f))); 22 | 23 | try { 24 | // Run the mocha test 25 | mocha.run(failures => { 26 | if (failures > 0) { 27 | e(new Error(`${failures} tests failed.`)); 28 | } else { 29 | c(); 30 | } 31 | }); 32 | } catch (err) { 33 | console.error(err); 34 | e(err); 35 | } 36 | }); 37 | }); 38 | } 39 | -------------------------------------------------------------------------------- /src/utils.ts: -------------------------------------------------------------------------------- 1 | export function nameToPath(path: string): string { 2 | return `/resources/views/components/${path.replace(/\./g, "/")}.blade.php`; 3 | } 4 | 5 | export function nameToIndexPath(path: string): string { 6 | return `/resources/views/components/${path.replace(/\./g, "/")}/index.blade.php`; 7 | } -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "target": "es6", 5 | "outDir": "out", 6 | "lib": [ 7 | "es6" 8 | ], 9 | "sourceMap": true, 10 | "rootDir": "src", 11 | "strict": true 12 | }, 13 | "exclude": [ 14 | "node_modules", 15 | ".vscode-test" 16 | ] 17 | } 18 | --------------------------------------------------------------------------------