├── .eslintrc.json ├── .github └── workflows │ ├── ci.yml │ └── publish.yml ├── .gitignore ├── .vscodeignore ├── CHANGELOG.md ├── FUNDING.yml ├── LICENSE ├── README.md ├── images ├── add.gif ├── constructor.gif ├── customizable.gif ├── existing.gif ├── icon.png ├── multiline.gif ├── remove.gif ├── rename.gif └── type.gif ├── out ├── addPropertyStatement.js ├── addPropertyStatement.js.map ├── changePropertyType.js ├── changePropertyType.js.map ├── class.js ├── class.js.map ├── constants.js ├── constants.js.map ├── constructor.js ├── constructor.js.map ├── extension.js ├── extension.js.map ├── factory.js ├── factory.js.map ├── insertProperty.js ├── insertProperty.js.map ├── locator.js ├── locator.js.map ├── property.js ├── property.js.map ├── removeProperty.js ├── removeProperty.js.map ├── renameProperty.js ├── renameProperty.js.map ├── test │ ├── fixtures │ │ ├── breakConstructorIntoMultiline │ │ │ ├── inputs │ │ │ │ └── Constructor.php │ │ │ └── outputs │ │ │ │ └── Constructor.php │ │ ├── changePropertyType │ │ │ ├── inputs │ │ │ │ ├── ConstructorDocblock.php │ │ │ │ ├── ConstructorWithMultipleProperties.php │ │ │ │ ├── ConstructorWithMultiplePropertiesCursorInConstructorDocblock.php │ │ │ │ ├── OtherPropertiesStatementDocblock.php │ │ │ │ ├── PropertyStatementDocblock.php │ │ │ │ ├── PropertyWithoutType.php │ │ │ │ └── TypedPropertyStatement.php │ │ │ └── outputs │ │ │ │ ├── ConstructorDocblock.php │ │ │ │ ├── ConstructorWithMultipleProperties.php │ │ │ │ ├── ConstructorWithMultiplePropertiesCursorInConstructorDocblock.php │ │ │ │ ├── OtherPropertiesStatementDocblock.php │ │ │ │ ├── PropertyStatementDocblock.php │ │ │ │ ├── PropertyWithoutType.php │ │ │ │ └── TypedPropertyStatement.php │ │ ├── customizations │ │ │ ├── inputs │ │ │ │ ├── ConstructorBreakIntoMultiline.php │ │ │ │ ├── ConstructorBreakIntoMultilineLength.php │ │ │ │ ├── ConstructorDefaultVisibility.php │ │ │ │ ├── PropertyAddDocblock.php │ │ │ │ ├── PropertyDefaultVisibility.php │ │ │ │ └── PropertyMultilineDocblock.php │ │ │ └── outputs │ │ │ │ ├── ConstructorBreakIntoMultiline.php │ │ │ │ ├── ConstructorBreakIntoMultilineLength.php │ │ │ │ ├── ConstructorDefaultVisibility.php │ │ │ │ ├── PropertyAddDocblock.php │ │ │ │ ├── PropertyDefaultVisibility.php │ │ │ │ └── PropertyMultilineDocblock.php │ │ ├── existing │ │ │ ├── inputs │ │ │ │ ├── ConstructorDocblockUsingDocblock.php │ │ │ │ ├── DocblockTypeWithParameter.php │ │ │ │ ├── EmptyClass.php │ │ │ │ ├── EmptyConstructor.php │ │ │ │ ├── ExistingConstructor.php │ │ │ │ ├── NullableType.php │ │ │ │ ├── UseDocblock.php │ │ │ │ ├── UseNullableDocblock.php │ │ │ │ └── UseType.php │ │ │ └── outputs │ │ │ │ ├── ConstructorDocblockUsingDocblock.php │ │ │ │ ├── DocblockTypeWithParameter.php │ │ │ │ ├── EmptyClass.php │ │ │ │ ├── EmptyConstructor.php │ │ │ │ ├── ExistingConstructor.php │ │ │ │ ├── NullableType.php │ │ │ │ ├── UseDocblock.php │ │ │ │ ├── UseNullableDocblock.php │ │ │ │ └── UseType.php │ │ ├── new │ │ │ ├── inputs │ │ │ │ ├── AddConstructorDocblock.php │ │ │ │ ├── ClassKeyword.php │ │ │ │ ├── EmptyClass.php │ │ │ │ ├── EmptyConstructor.php │ │ │ │ ├── ExistingConstructor.php │ │ │ │ ├── ExistingProperty.php │ │ │ │ ├── ExistingPropertyAssignation.php │ │ │ │ ├── ExistingPropertyInConstructor.php │ │ │ │ ├── MultilineConstructor.php │ │ │ │ ├── MultipleClasses.php │ │ │ │ ├── MultipleClassesCursorInFirst.php │ │ │ │ ├── MultipleClassesCursorInLast.php │ │ │ │ ├── TabIndentation.php │ │ │ │ └── UpdateConstructorDocblock.php │ │ │ └── outputs │ │ │ │ ├── AddConstructorDocblock.php │ │ │ │ ├── ClassKeyword.php │ │ │ │ ├── EmptyClass.php │ │ │ │ ├── EmptyConstructor.php │ │ │ │ ├── ExistingConstructor.php │ │ │ │ ├── ExistingProperty.php │ │ │ │ ├── ExistingPropertyAssignation.php │ │ │ │ ├── ExistingPropertyInConstructor.php │ │ │ │ ├── MultilineConstructor.php │ │ │ │ ├── MultipleClasses.php │ │ │ │ ├── MultipleClassesCursorInFirst.php │ │ │ │ ├── MultipleClassesCursorInLast.php │ │ │ │ ├── TabIndentation.php │ │ │ │ └── UpdateConstructorDocblock.php │ │ ├── remove │ │ │ ├── inputs │ │ │ │ ├── ConstructorDocblock.php │ │ │ │ ├── ConstructorWithMultipleProperties.php │ │ │ │ ├── ConstructorWithMultiplePropertiesCursorInArgument.php │ │ │ │ ├── ConstructorWithMultiplePropertiesCursorInAssignment.php │ │ │ │ ├── ConstructorWithMultiplePropertiesCursorInConstructorDocblock.php │ │ │ │ ├── ConstructorWithMultiplePropertiesCursorInPropertyStatement.php │ │ │ │ ├── ConstructorWithOneProperty.php │ │ │ │ ├── ConstructorWithOtherArgument.php │ │ │ │ ├── ConstructorWithSingleProperty.php │ │ │ │ ├── ConstructorWithSinglePropertyAndDocblock.php │ │ │ │ ├── EmptyConstructor.php │ │ │ │ ├── PropertyWithDocblock.php │ │ │ │ └── TypedProperty.php │ │ │ └── outputs │ │ │ │ ├── ConstructorDocblock.php │ │ │ │ ├── ConstructorWithMultipleProperties.php │ │ │ │ ├── ConstructorWithMultiplePropertiesCursorInArgument.php │ │ │ │ ├── ConstructorWithMultiplePropertiesCursorInAssignment.php │ │ │ │ ├── ConstructorWithMultiplePropertiesCursorInConstructorDocblock.php │ │ │ │ ├── ConstructorWithMultiplePropertiesCursorInPropertyStatement.php │ │ │ │ ├── ConstructorWithOneProperty.php │ │ │ │ ├── ConstructorWithOtherArgument.php │ │ │ │ ├── ConstructorWithSingleProperty.php │ │ │ │ ├── ConstructorWithSinglePropertyAndDocblock.php │ │ │ │ ├── EmptyConstructor.php │ │ │ │ ├── PropertyWithDocblock.php │ │ │ │ └── TypedProperty.php │ │ └── rename │ │ │ ├── inputs │ │ │ ├── ConstructorDocblock.php │ │ │ ├── ConstructorWithMultipleProperties.php │ │ │ ├── ConstructorWithMultiplePropertiesCursorInArgument.php │ │ │ ├── ConstructorWithMultiplePropertiesCursorInAssignment.php │ │ │ ├── ConstructorWithMultiplePropertiesCursorInConstructorDocblock.php │ │ │ ├── ConstructorWithMultiplePropertiesCursorInPropertyStatement.php │ │ │ ├── ConstructorWithSingleProperty.php │ │ │ ├── MultiplePropertyStatements.php │ │ │ └── PropertyReferences.php │ │ │ └── outputs │ │ │ ├── ConstructorDocblock.php │ │ │ ├── ConstructorWithMultipleProperties.php │ │ │ ├── ConstructorWithMultiplePropertiesCursorInArgument.php │ │ │ ├── ConstructorWithMultiplePropertiesCursorInAssignment.php │ │ │ ├── ConstructorWithMultiplePropertiesCursorInConstructorDocblock.php │ │ │ ├── ConstructorWithMultiplePropertiesCursorInPropertyStatement.php │ │ │ ├── ConstructorWithSingleProperty.php │ │ │ ├── MultiplePropertyStatements.php │ │ │ └── PropertyReferences.php │ ├── runTest.js │ ├── runTest.js.map │ └── suite │ │ ├── RemoveProperty.test.js.map │ │ ├── addExistingProperty.test.js │ │ ├── addExistingProperty.test.js.map │ │ ├── addProperty.test.js │ │ ├── addProperty.test.js.map │ │ ├── breakConstructorIntoMultiline.test.js │ │ ├── breakConstructorIntoMultiline.test.js.map │ │ ├── changePropertyType.test.js │ │ ├── changePropertyType.test.js.map │ │ ├── customizations.test.js │ │ ├── customizations.test.js.map │ │ ├── index.js │ │ ├── index.js.map │ │ ├── removeProperty.test.js │ │ ├── removeProperty.test.js.map │ │ ├── renameProperty.test.js │ │ ├── renameProperty.test.js.map │ │ ├── utils.js │ │ └── utils.js.map ├── utils.js └── utils.js.map ├── package-lock.json ├── package.json ├── src ├── addPropertyStatement.ts ├── changePropertyType.ts ├── class.ts ├── constants.ts ├── constructor.ts ├── extension.ts ├── insertProperty.ts ├── locator.ts ├── property.ts ├── removeProperty.ts ├── renameProperty.ts ├── test │ ├── runTest.ts │ └── suite │ │ ├── addExistingProperty.test.ts │ │ ├── addProperty.test.ts │ │ ├── breakConstructorIntoMultiline.test.ts │ │ ├── changePropertyType.test.ts │ │ ├── customizations.test.ts │ │ ├── index.ts │ │ ├── removeProperty.test.ts │ │ ├── renameProperty.test.ts │ │ └── utils.ts └── utils.ts ├── tsconfig.json └── webviews └── 1.0.1 ├── css └── main.css ├── i ├── code.jpg └── icon.png └── index.html /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "browser": false, 4 | "commonjs": true, 5 | "es6": true, 6 | "node": true 7 | }, 8 | "parserOptions": { 9 | "ecmaFeatures": { 10 | "jsx": true 11 | }, 12 | "sourceType": "module" 13 | }, 14 | "rules": { 15 | "no-const-assign": "warn", 16 | "no-this-before-super": "warn", 17 | "no-undef": "warn", 18 | "no-unreachable": "warn", 19 | "no-unused-vars": "warn", 20 | "constructor-super": "warn", 21 | "valid-typeof": "warn" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: [pull_request] 4 | 5 | jobs: 6 | build: 7 | 8 | runs-on: ubuntu-latest 9 | 10 | strategy: 11 | matrix: 12 | node-version: [10.x] 13 | 14 | steps: 15 | - uses: actions/checkout@v2 16 | - name: Use Node.js ${{ matrix.node-version }} 17 | uses: actions/setup-node@v1 18 | with: 19 | node-version: ${{ matrix.node-version }} 20 | - run: npm install 21 | - run: xvfb-run npm test 22 | env: 23 | CI: true -------------------------------------------------------------------------------- /.github/workflows/publish.yml: -------------------------------------------------------------------------------- 1 | name: Publish 2 | 3 | on: 4 | release: 5 | types: [published] 6 | 7 | jobs: 8 | build: 9 | 10 | runs-on: ubuntu-latest 11 | 12 | strategy: 13 | matrix: 14 | node-version: [10.x] 15 | 16 | steps: 17 | - uses: actions/checkout@v2 18 | - name: Use Node.js ${{ matrix.node-version }} 19 | uses: actions/setup-node@v1 20 | with: 21 | node-version: ${{ matrix.node-version }} 22 | - run: npm install 23 | - run: npx vsce publish -p ${{ secrets.VSCE_TOKEN}} 24 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .vscode-test/ 3 | *.vsix 4 | out/test/user/ 5 | -------------------------------------------------------------------------------- /.vscodeignore: -------------------------------------------------------------------------------- 1 | .vscode/** 2 | .vscode-test/** 3 | test/** 4 | .gitignore 5 | vsc-extension-quickstart.md 6 | **/jsconfig.json 7 | **/*.map 8 | **/.eslintrc.json 9 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 1.1.0 (2020-09-05) 2 | 3 | ### Added 4 | - [#28](https://github.com/kotfire/vscode-php-add-property/issues/28) Add support for nullable property types 5 | 6 | ### Fixed 7 | - [#26](https://github.com/kotfire/vscode-php-add-property/issues/26) Do not add extra space using docblock with param 8 | 9 | ## 1.0.0 (2020-08-31) 10 | 11 | ### Added 12 | - Rewrite to use a PHP parser to reduce usage of RegExp 13 | - Rewrite to use typescript 14 | - Add a new command to remove properties 15 | - Add a new command to rename properties 16 | - Add a new command to change properties type 17 | - Add a new command to transform a constructor into multiline 18 | - Allow to configure the context menu commands via settings 19 | 20 | ### Fixed 21 | - [#22](https://github.com/kotfire/vscode-php-add-property/issues/22) Add existing properties does not work with typed properties 22 | - [#23](https://github.com/kotfire/vscode-php-add-property/issues/23) Decrease the minimum vscode version to 1.31.0 23 | 24 | ## 0.5.0 (2020-02-07) 25 | 26 | ### Added 27 | - Support to insert properties in different classes on the same file 28 | 29 | ### Fixed 30 | - The file indentation was not respected sometimes 31 | 32 | ## 0.4.1 (2020-02-06) 33 | 34 | ### Fixed 35 | - Property won't be added if the constructor exists but is empty 36 | - [#13](https://github.com/kotfire/vscode-php-add-property/issues/13) Adding a property does not work when using anonymous classes inside the class 37 | 38 | ## 0.4.0 (2020-02-04) 39 | 40 | ### Added 41 | - Add a new option to add/update @param in the constructor docblock 42 | 43 | ## 0.3.1 (2020-01-22) 44 | 45 | ### Added 46 | - Add a new command to add existing properties to the constructor 47 | - Add a new option to enable/disable the context menu options 48 | 49 | ## 0.2.1 (2019-12-19) 50 | 51 | ### Fixed 52 | - [#4](https://github.com/kotfire/vscode-php-add-property/issues/4) Cursor is sometimes placed in wrong location after generating property 53 | 54 | ## 0.2.0 (2019-12-19) 55 | 56 | ### Added 57 | - Add a new option to use multiline docblocks 58 | 59 | ## 0.1.0 (2019-10-04) 60 | 61 | ### Added 62 | - Break constructor into multiline if the given line length is exceeded (Configurable) 63 | 64 | ## 0.0.1 (2019-09-30) 65 | 66 | ### Initial release 67 | -------------------------------------------------------------------------------- /FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: kotfire 2 | ko_fi: kotfire 3 | custom: ["https://plant.treeware.earth/kotfire/vscode-php-add-property"] 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) [year] [fullname] 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. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Version](https://vsmarketplacebadge.apphb.com/version-short/kotfire.php-add-property.svg?style=for-the-badge)](https://marketplace.visualstudio.com/items?itemName=kotfire.php-add-property) 2 | [![Rating](https://vsmarketplacebadge.apphb.com/rating-short/kotfire.php-add-property.svg?style=for-the-badge)](https://marketplace.visualstudio.com/items?itemName=kotfire.php-add-property) 3 | [![Installs](https://vsmarketplacebadge.apphb.com/installs/kotfire.php-add-property.svg?style=for-the-badge)](https://marketplace.visualstudio.com/items?itemName=kotfire.php-add-property) 4 | 5 | # PHP Add Property 6 | 7 | Visual Code Studio extension to manage PHP class properties 8 | 9 | ## Support my work 10 | 11 | [![Github sponsors](https://img.shields.io/badge/Sponsor%20now-181717?style=for-the-badge&logo=github)](https://github.com/sponsors/kotfire) 12 | [![Buy me a tea](https://img.shields.io/badge/Buy%20me%20a%20tea-555555?style=for-the-badge&logo=Ko-fi)](https://ko-fi.com/M4M71TVH1) 13 | [![Buy the world a tree](https://img.shields.io/badge/Buy%20the%20world%20a%20tree-%F0%9F%8C%B3-242424?labelColor=276749&style=for-the-badge)](https://plant.treeware.earth/kotfire/vscode-php-add-property) 14 | 15 | ## Features 16 | 17 | ### Add a property 18 | 19 | ![Add a property demo](images/add.gif) 20 | 21 | ### Add existing properties 22 | 23 | > It gets the property type from the docblock! 24 | 25 | ![Add existing properties demo](images/existing.gif) 26 | 27 | ### Remove a property 28 | 29 | ![Remove a property demo](images/remove.gif) 30 | 31 | ### Rename a property 32 | 33 | ![Remove a property demo](images/rename.gif) 34 | 35 | ### Change property type 36 | 37 | ![Remove a property demo](images/type.gif) 38 | 39 | ### Insert constructor 40 | 41 | Automatically insert a constructor if it does not exist. 42 | 43 | ![Insert constructor demo](images/constructor.gif) 44 | 45 | ### Multi-line constructor support 46 | 47 | ![Multi-line constructor demo](images/multiline.gif) 48 | 49 | ### Highly customizable 50 | 51 | ![Highly customizable demo](images/customizable.gif) 52 | 53 | ## Extension Settings 54 | 55 | This extension contributes the following settings: 56 | 57 | * `phpAddProperty.property.visibility.choose`: Specifies whether to choose property visibility when inserting 58 | * `phpAddProperty.property.visibility.default`: Specifies the default property visibility 59 | * `phpAddProperty.property.stopToImport`: Specifies whether to stop after typing the type to refer to an external fully qualified name with an alias or importing 60 | * `phpAddProperty.property.docblock.add`: Specifies whether to add a docblock @var type to the property 61 | * `phpAddProperty.property.docblock.multiline`: Specifies whether to use a multiline docblock 62 | * `phpAddProperty.property.docblock.withParameter`: Specifies whether to add the docblock @var type to the property and the constructor parameter type at the same time 63 | * `phpAddProperty.property.docblock.stopToImport`: Specifies whether to stop after typing the type to refer to an external fully qualified name with an alias or importing 64 | * `phpAddProperty.property.types`: Specifies whether to enable PHP 7.4+ typed properties [More info](https://wiki.php.net/rfc/typed_properties_v2) 65 | * `phpAddProperty.constructor.docblock.enable`: Specifies whether to add/update the docblock to the constructor 66 | * `phpAddProperty.constructor.docblock.withParameter`: Specifies whether to add the docblock @param type together with the constructor parameter type 67 | * `phpAddProperty.constructor.docblock.stopToImport`: Specifies whether to stop after typing the @param type to refer to an external fully qualified name with an alias or importing 68 | * `phpAddProperty.constructor.docblock.stopForDescription`: Specifies whether to stop after typing the @var type to add a description 69 | * `phpAddProperty.constructor.visibility.choose`: Specifies whether to choose constructor visibility when inserting 70 | * `phpAddProperty.constructor.visibility.default`: Specifies the default constructor visibility 71 | * `phpAddProperty.constructor.breakIntoMultilineIfLengthExceeded.enabled`: Specifies whether to break the constructor into multiple lines if the given line length is exceeded 72 | * `phpAddProperty.constructor.breakIntoMultilineIfLengthExceeded.maxLineLength`: Specifies the maximum line length before using a multiline constructor 73 | * `phpAddProperty.showMessagesOnStatusBar`: Specifies whether to show messages on status bar instead of notification box 74 | * `phpAddProperty.contextMenuOptions.enable`: Specifies whether to show the context menu options 75 | * `phpAddProperty.contextMenuOptions.addProperty`: Specifies whether to show the add property command in the context menu options 76 | * `phpAddProperty.contextMenuOptions.appendProperty`: Specifies whether to show the append property command in the context menu options 77 | * `phpAddProperty.contextMenuOptions.renameProperty`: Specifies whether to show the rename property command in the context menu options 78 | * `phpAddProperty.contextMenuOptions.changePropertyType`: Specifies whether to show the change property type command in the context menu options 79 | * `phpAddProperty.contextMenuOptions.removeProperty`: Specifies whether to show the remove property command in the context menu options 80 | * `phpAddProperty.contextMenuOptions.breakConstructorIntoMultiline`: Specifies whether to show the break constructor into multiline command in the context menu options 81 | * `phpAddProperty.showVersionUpdates`: Specifies whether to show What's New after upgrading to a new version 82 | -------------------------------------------------------------------------------- /images/add.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kotfire/vscode-php-add-property/7eef6578ea265db9188ff3494efaa3f4d39d62ca/images/add.gif -------------------------------------------------------------------------------- /images/constructor.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kotfire/vscode-php-add-property/7eef6578ea265db9188ff3494efaa3f4d39d62ca/images/constructor.gif -------------------------------------------------------------------------------- /images/customizable.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kotfire/vscode-php-add-property/7eef6578ea265db9188ff3494efaa3f4d39d62ca/images/customizable.gif -------------------------------------------------------------------------------- /images/existing.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kotfire/vscode-php-add-property/7eef6578ea265db9188ff3494efaa3f4d39d62ca/images/existing.gif -------------------------------------------------------------------------------- /images/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kotfire/vscode-php-add-property/7eef6578ea265db9188ff3494efaa3f4d39d62ca/images/icon.png -------------------------------------------------------------------------------- /images/multiline.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kotfire/vscode-php-add-property/7eef6578ea265db9188ff3494efaa3f4d39d62ca/images/multiline.gif -------------------------------------------------------------------------------- /images/remove.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kotfire/vscode-php-add-property/7eef6578ea265db9188ff3494efaa3f4d39d62ca/images/remove.gif -------------------------------------------------------------------------------- /images/rename.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kotfire/vscode-php-add-property/7eef6578ea265db9188ff3494efaa3f4d39d62ca/images/rename.gif -------------------------------------------------------------------------------- /images/type.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kotfire/vscode-php-add-property/7eef6578ea265db9188ff3494efaa3f4d39d62ca/images/type.gif -------------------------------------------------------------------------------- /out/addPropertyStatement.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | const vscode = require("vscode"); 4 | const utils_1 = require("./utils"); 5 | function addPropertyStatement(document, phpClass, property, tabStops) { 6 | var _a; 7 | const phpClassRange = new vscode.Range(new vscode.Position(phpClass.ast.loc.start.line - 1, phpClass.ast.loc.start.column), new vscode.Position(phpClass.ast.loc.end.line - 1, phpClass.ast.loc.end.column)); 8 | let newDocumentText = utils_1.escapeForSnippet(document.getText(phpClassRange)); 9 | let lastProperty; 10 | let firstMethod; 11 | let lastNode; 12 | const astClassBody = phpClass.ast.body; 13 | for (let i = 0; i < astClassBody.length; i++) { 14 | const node = astClassBody[i]; 15 | lastNode = node; 16 | if (node.kind === 'propertystatement') { 17 | lastProperty = node; 18 | // Check that property does not already exist 19 | for (let j = 0; j < node.properties.length; j++) { 20 | const propertyNode = node.properties[j]; 21 | if (((_a = propertyNode.name) === null || _a === void 0 ? void 0 : _a.name) === property.getName()) { 22 | return newDocumentText; 23 | } 24 | } 25 | } 26 | else if (!firstMethod && node.kind === 'method' && node.name !== '__construct') { 27 | firstMethod = node; 28 | } 29 | } 30 | const propertyStatementText = property.getStatementText(tabStops); 31 | if (lastProperty) { 32 | const lastPropertyLine = document.lineAt(lastProperty.loc.start.line - 1); 33 | const newPropertyText = utils_1.escapeForSnippet(`${lastPropertyLine.text}`) + "\n\n" + utils_1.indentText(propertyStatementText, utils_1.calculateIndentationLevel(utils_1.getLineFirstNonIndentationCharacterIndex(lastPropertyLine.text))); 34 | newDocumentText = newDocumentText.replace(utils_1.escapeForSnippet(lastPropertyLine.text), newPropertyText); 35 | } 36 | else if (firstMethod) { 37 | const firstMethodLine = document.lineAt(firstMethod.loc.start.line - 1); 38 | const newPropertyText = utils_1.indentText(propertyStatementText, utils_1.calculateIndentationLevel(utils_1.getLineFirstNonIndentationCharacterIndex(firstMethodLine.text))) + "\n\n" + utils_1.escapeForSnippet(firstMethodLine.text); 39 | newDocumentText = newDocumentText.replace(utils_1.escapeForSnippet(firstMethodLine.text), newPropertyText); 40 | } 41 | else if (lastNode) { 42 | const lastNodeLine = document.lineAt(lastNode.loc.start.line - 1); 43 | const newPropertyText = utils_1.escapeForSnippet(lastNodeLine.text) + "\n\n" + utils_1.indentText(propertyStatementText, utils_1.calculateIndentationLevel(utils_1.getLineFirstNonIndentationCharacterIndex(lastNodeLine.text))); 44 | newDocumentText = newDocumentText.replace(utils_1.escapeForSnippet(lastNodeLine.text), newPropertyText); 45 | } 46 | else { 47 | const isOneLineClass = phpClass.ast.loc.start.line === phpClass.ast.loc.end.line; 48 | if (isOneLineClass) { 49 | const match = phpClass.ast.loc.source.match(/(.*)\}/); 50 | const newPropertyText = utils_1.escapeForSnippet(match[1]) + "\n" + utils_1.indentText(propertyStatementText, 1) + "\n" + '}'; 51 | newDocumentText = newDocumentText.replace(utils_1.escapeForSnippet(phpClass.ast.loc.source), newPropertyText); 52 | } 53 | else { 54 | const classBodyLine = document.lineAt(phpClass.ast.loc.start.line - 1); 55 | const classText = utils_1.escapeForSnippet(phpClass.ast.loc.source); 56 | const newPropertyText = classText.replace(/{(?:\s|[\r\n]|\s)*}/, "{\n" + utils_1.indentText(propertyStatementText, utils_1.calculateIndentationLevel(utils_1.getLineFirstNonIndentationCharacterIndex(classBodyLine.text)) + 1)) + "\n}"; 57 | newDocumentText = newDocumentText.replace(classText, newPropertyText); 58 | } 59 | } 60 | return newDocumentText; 61 | } 62 | exports.default = addPropertyStatement; 63 | //# sourceMappingURL=addPropertyStatement.js.map -------------------------------------------------------------------------------- /out/addPropertyStatement.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"addPropertyStatement.js","sourceRoot":"","sources":["../src/addPropertyStatement.ts"],"names":[],"mappings":";;AAAA,iCAAiC;AAGjC,mCAA4H;AAE5H,SAAwB,oBAAoB,CAAC,QAA6B,EAAE,QAAe,EAAE,QAAkB,EAAE,QAAa;;IAC7H,MAAM,aAAa,GAAG,IAAI,MAAM,CAAC,KAAK,CACrC,IAAI,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,EAAE,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,EACnF,IAAI,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,EAAE,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,CAC/E,CAAC;IAEF,IAAI,eAAe,GAAG,wBAAgB,CAAC,QAAQ,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC;IAExE,IAAI,YAAY,CAAC;IACjB,IAAI,WAAW,CAAC;IAChB,IAAI,QAAQ,CAAC;IAEb,MAAM,YAAY,GAAG,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC;IACvC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,YAAY,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QAC7C,MAAM,IAAI,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC;QAE7B,QAAQ,GAAG,IAAI,CAAC;QAEhB,IAAI,IAAI,CAAC,IAAI,KAAK,mBAAmB,EAAE;YACtC,YAAY,GAAG,IAAI,CAAC;YAEpB,6CAA6C;YAC7C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,UAAU,CAAC,MA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YACvE,MAAM,SAAS,GAAG,wBAAgB,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;YAE5D,MAAM,eAAe,GAAG,SAAS,CAAC,OAAO,CAAC,qBAAqB,EAAE,KAAK,GAAG,kBAAU,CAClF,qBAAqB,EACrB,iCAAyB,CACxB,gDAAwC,CAAC,aAAa,CAAC,IAAI,CAAC,CAC5D,GAAG,CAAC,CACL,CAAC,GAAG,KAAK,CAAC;YAEX,eAAe,GAAG,eAAe,CAAC,OAAO,CAAC,SAAS,EAAE,eAAe,CAAC,CAAC;SACtE;KACD;IAED,OAAO,eAAe,CAAC;AACxB,CAAC;AAjGD,uCAiGC"} -------------------------------------------------------------------------------- /out/changePropertyType.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | const vscode = require("vscode"); 4 | const utils_1 = require("./utils"); 5 | function changePropertyType(editor, property, newPropertyType, phpClass) { 6 | var _a, _b, _c, _d, _e; 7 | const document = editor.document; 8 | const phpClassRange = new vscode.Range(new vscode.Position(phpClass.ast.loc.start.line - 1, phpClass.ast.loc.start.column), new vscode.Position(phpClass.ast.loc.end.line - 1, phpClass.ast.loc.end.column)); 9 | let newDocumentText = document.getText(phpClassRange); 10 | const astClassBody = phpClass.ast.body; 11 | for (let i = 0; i < astClassBody.length; i++) { 12 | const node = astClassBody[i]; 13 | if (node.kind === 'propertystatement') { 14 | let newPropertyStatementText; 15 | for (let j = 0; j < node.properties.length; j++) { 16 | const propertyNode = node.properties[j]; 17 | if (((_a = propertyNode.name) === null || _a === void 0 ? void 0 : _a.name) == property.getName()) { 18 | const propertyStatementRange = new vscode.Range(new vscode.Position(node.loc.start.line - 1, 0), new vscode.Position(node.loc.end.line, 0)); 19 | const propertyStatementText = document.getText(propertyStatementRange); 20 | let newPropertyText = `\$${property.getName()}`; 21 | if (utils_1.config('phpAddProperty.property.types') === true || propertyNode.type) { 22 | newPropertyText = `${newPropertyType} ${newPropertyText}`; 23 | } 24 | newPropertyStatementText = propertyStatementText.replace(propertyNode.loc.source, newPropertyText); 25 | newDocumentText = newDocumentText.replace(propertyStatementText, newPropertyStatementText); 26 | } 27 | } 28 | if (newPropertyStatementText) { 29 | for (let i = 0; i < ((_b = node.leadingComments) === null || _b === void 0 ? void 0 : _b.length); i++) { 30 | const commentNode = node.leadingComments[i]; 31 | const commentRange = new vscode.Range(new vscode.Position(commentNode.loc.start.line - 1, 0), new vscode.Position(commentNode.loc.end.line, 0)); 32 | const commentText = document.getText(commentRange); 33 | const typeMatch = /@var\s(\S*)/g.exec(commentText); 34 | if (typeMatch) { 35 | const newCommentText = commentText.replace(typeMatch[1], newPropertyType); 36 | const regexp = new RegExp(`${utils_1.escapeForRegExp(commentText)}((?:\s|[\r\n])*)${utils_1.escapeForRegExp(newPropertyStatementText)}`); 37 | newDocumentText = newDocumentText.replace(regexp, `${newCommentText}$1${newPropertyStatementText}`); 38 | } 39 | } 40 | break; 41 | } 42 | } 43 | } 44 | const constructor = phpClass.getConstructor(); 45 | if (constructor) { 46 | for (let i = 0; i < constructor.ast.arguments.length; i++) { 47 | const node = constructor.ast.arguments[i]; 48 | if (((_c = node.name) === null || _c === void 0 ? void 0 : _c.name) == property.getName()) { 49 | const constructorText = constructor.ast.loc.source; 50 | const newConstructorText = constructorText.replace(node.loc.source, `${newPropertyType} \$${property.getName()}`); 51 | newDocumentText = newDocumentText.replace(constructorText, newConstructorText); 52 | break; 53 | } 54 | } 55 | for (let i = 0; i < ((_d = constructor.ast.leadingComments) === null || _d === void 0 ? void 0 : _d.length); i++) { 56 | const commentNode = constructor.ast.leadingComments[i]; 57 | const commentRange = new vscode.Range(new vscode.Position(commentNode.loc.start.line - 1, 0), new vscode.Position(commentNode.loc.end.line, 0)); 58 | const commentText = document.getText(commentRange); 59 | const regexp = new RegExp(`\\S*(\\s+\\$${property.getName()})`); 60 | const newCommentText = commentText.replace(regexp, `${newPropertyType}$1`); 61 | newDocumentText = newDocumentText.replace(commentText, newCommentText); 62 | } 63 | } 64 | if (newDocumentText === document.getText(phpClassRange)) { 65 | return; 66 | } 67 | (_e = vscode.window.activeTextEditor) === null || _e === void 0 ? void 0 : _e.edit(editBuilder => { 68 | editBuilder.replace(phpClassRange, newDocumentText); 69 | }, { 70 | undoStopBefore: true, 71 | undoStopAfter: false 72 | }); 73 | } 74 | exports.changePropertyType = changePropertyType; 75 | //# sourceMappingURL=changePropertyType.js.map -------------------------------------------------------------------------------- /out/changePropertyType.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"changePropertyType.js","sourceRoot":"","sources":["../src/changePropertyType.ts"],"names":[],"mappings":";;AAAA,iCAAiC;AAGjC,mCAAkD;AAElD,SAAgB,kBAAkB,CAAC,MAAyB,EAAE,QAAkB,EAAE,eAAuB,EAAE,QAAe;;IACzH,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;IACjC,MAAM,aAAa,GAAG,IAAI,MAAM,CAAC,KAAK,CACrC,IAAI,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,EAAE,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,EACnF,IAAI,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,EAAE,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,CAC/E,CAAC;IAEF,IAAI,eAAe,GAAG,QAAQ,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;IAEnD,MAAM,YAAY,GAAG,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC;IAC1C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,YAAY,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QAC7C,MAAM,IAAI,GAAG,YAAY,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xD,OAAO;KACP;IAED,MAAA,MAAM,CAAC,MAAM,CAAC,gBAAgB,0CAAE,IAAI,CACnC,WAAW,CAAC,EAAE;QACb,WAAW,CAAC,OAAO,CAAC,aAAa,EAAE,eAAe,CAAC,CAAC;IACrD,CAAC,EACD;QACC,cAAc,EAAE,IAAI;QACpB,aAAa,EAAE,KAAK;KACpB,EACA;AACH,CAAC;AA3HD,gDA2HC"} -------------------------------------------------------------------------------- /out/class.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | const constructor_1 = require("./constructor"); 4 | class Class { 5 | constructor(ast) { 6 | this.ast = ast; 7 | this.findConstructor(); 8 | } 9 | getConstructor() { 10 | return this.construct; 11 | } 12 | findConstructor() { 13 | var _a; 14 | for (let i = 0; i < this.ast.body.length; i++) { 15 | const node = this.ast.body[i]; 16 | if (node.kind === 'method' && ((_a = node.name) === null || _a === void 0 ? void 0 : _a.name) === '__construct') { 17 | this.construct = new constructor_1.default(node); 18 | } 19 | } 20 | } 21 | } 22 | exports.default = Class; 23 | //# sourceMappingURL=class.js.map -------------------------------------------------------------------------------- /out/class.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"class.js","sourceRoot":"","sources":["../src/class.ts"],"names":[],"mappings":";;AAAA,+CAAwC;AAExC,MAAqB,KAAK;IAKtB,YAAY,GAAQ;QAChB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QAEf,IAAI,CAAC,eAAe,EAAE,CAAC;IAC3B,CAAC;IAEM,cAAc;QACjB,OAAO,IAAI,CAAC,SAAS,CAAC;IAC1B,CAAC;IAEO,eAAe;;QACnB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YAC3C,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YAE9B,IAAI,IAAI,CAAC,IAAI,KAAK,QAAQ,IAAI,OAAA,IAAI,CAAC,IAAI,0CAAE,IAAI,MAAK,aAAa,EAAE;gBAC7D,IAAI,CAAC,SAAS,GAAG,IAAI,qBAAW,CAAC,IAAI,CAAC,CAAC;aAC1C;SACJ;IACL,CAAC;CACJ;AAxBD,wBAwBC"} -------------------------------------------------------------------------------- /out/constants.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.extensionId = 'php-add-property'; 4 | exports.extensionQualifiedId = `kotfire.${exports.extensionId}`; 5 | exports.debugEnvName = 'PHP_ADD_PROPERTY_DEBUG_MODE'; 6 | var GlobalState; 7 | (function (GlobalState) { 8 | GlobalState["version"] = "phpAddPropertyVersion"; 9 | })(GlobalState = exports.GlobalState || (exports.GlobalState = {})); 10 | //# sourceMappingURL=constants.js.map -------------------------------------------------------------------------------- /out/constants.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";;AAAa,QAAA,WAAW,GAAG,kBAAkB,CAAC;AACjC,QAAA,oBAAoB,GAAG,WAAW,mBAAW,EAAE,CAAC;AAChD,QAAA,YAAY,GAAG,6BAA6B,CAAC;AAE1D,IAAY,WAEX;AAFD,WAAY,WAAW;IACtB,gDAAiC,CAAA;AAClC,CAAC,EAFW,WAAW,GAAX,mBAAW,KAAX,mBAAW,QAEtB"} -------------------------------------------------------------------------------- /out/constructor.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | class Constructor { 4 | constructor(ast) { 5 | this.ast = ast; 6 | } 7 | } 8 | exports.default = Constructor; 9 | //# sourceMappingURL=constructor.js.map -------------------------------------------------------------------------------- /out/constructor.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"constructor.js","sourceRoot":"","sources":["../src/constructor.ts"],"names":[],"mappings":";;AAAA,MAAqB,WAAW;IAG5B,YAAY,GAAQ;QAChB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACnB,CAAC;CACJ;AAND,8BAMC"} -------------------------------------------------------------------------------- /out/factory.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | const php_parser_1 = require("php-parser"); 4 | function createProperty(name, value) { 5 | let statement = `\$${name}`; 6 | if (value) { 7 | statement += ` = ${value}`; 8 | } 9 | const ast = php_parser_1.default.parseEval(` 10 | class a { 11 | ${statement}; 12 | } 13 | `); 14 | return ast.children[0].body[0]; 15 | } 16 | exports.createProperty = createProperty; 17 | //# sourceMappingURL=factory.js.map -------------------------------------------------------------------------------- /out/factory.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"factory.js","sourceRoot":"","sources":["../src/factory.ts"],"names":[],"mappings":";;AAAA,2CAAgC;AAEhC,SAAgB,cAAc,CAAC,IAAY,EAAE,KAAc;IACvD,IAAI,SAAS,GAAG,KAAK,IAAI,EAAE,CAAC;IAE5B,IAAI,KAAK,EAAE;QACP,SAAS,IAAI,MAAM,KAAK,EAAE,CAAC;KAC9B;IAED,MAAM,GAAG,GAAG,oBAAM,CAAC,SAAS,CAAC;;cAEnB,SAAS;;KAElB,CAAC,CAAC;IAEH,OAAQ,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAC5C,CAAC;AAdD,wCAcC"} -------------------------------------------------------------------------------- /out/locator.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | const class_1 = require("./class"); 4 | const constructor_1 = require("./constructor"); 5 | class Locator { 6 | constructor(ast) { 7 | this.ast = ast; 8 | } 9 | findClass(cursorAtLine) { 10 | let firstClass; 11 | const cursorClass = filter(this.ast, 'class', function (node) { 12 | if (!firstClass) { 13 | firstClass = new class_1.default(node); 14 | } 15 | if (!cursorAtLine || (cursorAtLine >= node.loc.start.line && cursorAtLine <= node.loc.end.line)) { 16 | return new class_1.default(node); 17 | } 18 | }); 19 | return cursorClass || firstClass; 20 | } 21 | findConstructor() { 22 | return filter(this.ast, 'method', function (node) { 23 | var _a; 24 | if (((_a = node.name) === null || _a === void 0 ? void 0 : _a.name) === '__construct') { 25 | return new constructor_1.default(node); 26 | } 27 | }); 28 | } 29 | } 30 | exports.default = Locator; 31 | function filter(ast, kind, matcher) { 32 | let result; 33 | if (Array.isArray(ast)) { 34 | for (var i = 0; i < ast.length; i++) { 35 | result = filter(ast[i], kind, matcher); 36 | if (result) { 37 | return result; 38 | } 39 | } 40 | } 41 | else { 42 | if ((ast === null || ast === void 0 ? void 0 : ast.kind) === kind) { 43 | result = matcher(ast); 44 | if (result) { 45 | return result; 46 | } 47 | } 48 | for (const node in ast) { 49 | if (ast.hasOwnProperty(node) && ast[node] !== ast) { 50 | result = filter(ast[node], kind, matcher); 51 | if (result) { 52 | return result; 53 | } 54 | } 55 | } 56 | } 57 | } 58 | //# sourceMappingURL=locator.js.map -------------------------------------------------------------------------------- /out/locator.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"locator.js","sourceRoot":"","sources":["../src/locator.ts"],"names":[],"mappings":";;AAAA,mCAA4B;AAC5B,+CAAwC;AAExC,MAAqB,OAAO;IAGxB,YAAY,GAAQ;QAChB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACnB,CAAC;IAED,SAAS,CAAC,YAAqB;QAC3B,IAAI,UAA6B,CAAC;QAClC,MAAM,WAAW,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,OAAO,EAAE,UAAU,IAAS;YAC7D,IAAI,CAAC,UAAU,EAAE;gBACb,UAAU,GAAG,IAAI,eAAK,CAAC,IAAI,CAAC,CAAC;aAChC;YACD,IAAI,CAAC,YAAY,IAAI,CAAC,YAAY,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,IAAI,YAAY,IAAI,IAAI,CAAC,GAAG,CA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AC;gBAC1C,IAAI,MAAM,EAAE;oBACR,OAAO,MAAM,CAAC;iBACjB;aACJ;SACJ;KACJ;AACL,CAAC"} -------------------------------------------------------------------------------- /out/property.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | const utils_1 = require("./utils"); 4 | class Property { 5 | constructor(name, nullable = false, type) { 6 | this.name = name; 7 | this.nullable = nullable; 8 | this.type = type; 9 | } 10 | getName() { 11 | return this.name; 12 | } 13 | isNullable() { 14 | return this.nullable === true; 15 | } 16 | getType() { 17 | return this.type; 18 | } 19 | getStatementText(tabStops) { 20 | let docblockTypeStop = tabStops.propertyDocblockType; 21 | let dockblockImportStop = tabStops.propertyDocblockImport; 22 | if (utils_1.config('phpAddProperty.property.docblock.withParameter') === true) { 23 | docblockTypeStop = tabStops.constructorParameterType; 24 | dockblockImportStop = tabStops.constructorParameterStop; 25 | tabStops.constructorParameterStop++; 26 | } 27 | let propertyStatementText = ''; 28 | if (utils_1.config('phpAddProperty.property.docblock.add') === true) { 29 | let stopText = ''; 30 | if (utils_1.config('phpAddProperty.property.docblock.stopToImport') === true) { 31 | stopText += `$${dockblockImportStop}`; 32 | } 33 | stopText += `$${docblockTypeStop}`; 34 | if (utils_1.config('phpAddProperty.property.docblock.multiline') === true) { 35 | propertyStatementText += `/**\n${utils_1.indentText(' * @var ')}${stopText}\n${utils_1.indentText(' */')}\n${utils_1.indentText('')}`; 36 | } 37 | else { 38 | if (utils_1.config('phpAddProperty.property.docblock.withParameter') === false) { 39 | stopText += ' '; 40 | } 41 | propertyStatementText += `/** @var ${stopText}*/\n${utils_1.indentText('')}`; 42 | } 43 | } 44 | const visibility = utils_1.config('phpAddProperty.property.visibility.default'); 45 | propertyStatementText += utils_1.config('phpAddProperty.property.visibility.choose') === true 46 | ? `\${${tabStops.propertyVisibility}${utils_1.getVisibilityChoice(visibility)}} ` 47 | : `${visibility} `; 48 | if (utils_1.config('phpAddProperty.property.types') === true) { 49 | propertyStatementText += `$${tabStops.constructorParameterType}`; 50 | } 51 | propertyStatementText += `\\$${this.getName()};`; 52 | return propertyStatementText; 53 | } 54 | getParameterText(tabStops) { 55 | let tabStopsText = `$${tabStops.constructorParameterType}`; 56 | if (this.getType()) { 57 | let typeText = this.getType(); 58 | if (this.isNullable()) { 59 | typeText = `?${typeText}`; 60 | } 61 | tabStopsText = `\${${tabStops.constructorParameterType}:${typeText}}`; 62 | } 63 | if (utils_1.config('phpAddProperty.property.stopToImport') === true) { 64 | tabStopsText += `$${tabStops.constructorParameterStop}`; 65 | } 66 | let parameterText = `${tabStopsText}`; 67 | if (this.getType()) { 68 | parameterText += ' '; 69 | } 70 | parameterText += `\\$${this.getName()}`; 71 | return parameterText; 72 | } 73 | getConstructorParamDocblockText(tabStops) { 74 | let docblockTypeStop = tabStops.constructorDocblockType; 75 | let dockblockImportStop = tabStops.constructorDocblockImport; 76 | if (utils_1.config('phpAddProperty.constructor.docblock.withParameter') === true) { 77 | docblockTypeStop = tabStops.constructorParameterType; 78 | dockblockImportStop = tabStops.constructorParameterStop; 79 | tabStops.constructorParameterStop++; 80 | } 81 | let constructorParamDocblockText = `\${${docblockTypeStop}}`; 82 | if (this.getType()) { 83 | let typeText = this.getType(); 84 | if (this.isNullable()) { 85 | typeText = `${typeText}|null`; 86 | } 87 | constructorParamDocblockText = `\${${docblockTypeStop}:${typeText}} `; 88 | } 89 | if (utils_1.config('phpAddProperty.constructor.docblock.stopToImport') === true) { 90 | constructorParamDocblockText += `\$${dockblockImportStop}`; 91 | } 92 | constructorParamDocblockText += `\\$${this.getName()}`; 93 | if (utils_1.config('phpAddProperty.constructor.docblock.stopForDescription') === true) { 94 | constructorParamDocblockText += `\$${tabStops.constructorDocblockDescription}`; 95 | } 96 | return ` * @param ${constructorParamDocblockText}`; 97 | } 98 | } 99 | exports.default = Property; 100 | //# sourceMappingURL=property.js.map -------------------------------------------------------------------------------- /out/property.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"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: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"removeProperty.js","sourceRoot":"","sources":["../src/removeProperty.ts"],"names":[],"mappings":";;AAAA,iCAAiC;AAGjC,mCAA0C;AAE1C,SAAgB,cAAc,CAAC,MAAyB,EAAE,QAAkB,EAAE,QAAe;;IAC5F,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;IACjC,MAAM,aAAa,GAAG,IAAI,MAAM,CAAC,KAAK,CACrC,IAAI,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,EAAE,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,EACnF,IAAI,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,EAAE,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,CAC/E,CAAC;IAEF,IAAI,eAAe,GAAG,QAAQ,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;IAEtD,MAAM,YAAY,GAAG,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC;IACvC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,YAAY,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QAC7C,MAAM,IAAI,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC;QAE7B,IAAI,IAAI,CAAC,IAAI,KAAK,mBAAmB,EAAE;YACtC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;gBAChD,MAAM,YAAY,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;gBAExC,IAAI,OAAA,YAAY,CAAC,IAAI,0CAAE,IAAI,MAAK,QAAQ,CAAC,OAAO,EAAE,EA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AAG,WAAW,CAAC,GAAG,CAAC,eAAe,0CAAE,MAAM,CAAA,EAAE,CAAC,EAAE,EAAE;gBACjE,MAAM,WAAW,GAAG,WAAW,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;gBAEvD,MAAM,YAAY,GAAG,IAAI,MAAM,CAAC,KAAK,CACpC,IAAI,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,EAAE,CAAC,CAAC,EACtD,IAAI,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,CAChD,CAAC;gBAEF,MAAM,WAAW,GAAG,QAAQ,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;gBAEnD,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,aAAa,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;gBACxE,MAAM,cAAc,GAAG,WAAW,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;gBAEvD,eAAe,GAAG,eAAe,CAAC,OAAO,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC;aACvE;SACD;KACD;IAED,IAAI,eAAe,KAAK,QAAQ,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE;QACxD,OAAO;KACP;IAED,MAAA,MAAM,CAAC,MAAM,CAAC,gBAAgB,0CAAE,IAAI,CACnC,WAAW,CAAC,EAAE;QACb,WAAW,CAAC,OAAO,CAAC,aAAa,EAAE,eAAe,CAAC,CAAC;IACrD,CAAC,EACD;QACC,cAAc,EAAE,IAAI;QACpB,aAAa,EAAE,KAAK;KACpB,EACA;AACH,CAAC;AA5JD,wCA4JC"} -------------------------------------------------------------------------------- /out/test/fixtures/breakConstructorIntoMultiline/inputs/Constructor.php: -------------------------------------------------------------------------------- 1 | rank = $rank; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /out/test/fixtures/breakConstructorIntoMultiline/outputs/Constructor.php: -------------------------------------------------------------------------------- 1 | rank = $rank; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /out/test/fixtures/changePropertyType/inputs/ConstructorDocblock.php: -------------------------------------------------------------------------------- 1 | class = $class; 22 | $this->name = $name; 23 | $this->rank = $rank; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /out/test/fixtures/changePropertyType/inputs/ConstructorWithMultipleProperties.php: -------------------------------------------------------------------------------- 1 | class = $class; 17 | $this->name = $name; 18 | $this->rank = $rank; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /out/test/fixtures/changePropertyType/inputs/ConstructorWithMultiplePropertiesCursorInConstructorDocblock.php: -------------------------------------------------------------------------------- 1 | class = $class; 22 | $this->name = $name; 23 | $this->rank = $rank; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /out/test/fixtures/changePropertyType/inputs/OtherPropertiesStatementDocblock.php: -------------------------------------------------------------------------------- 1 | class = $class; 17 | $this->name = $name; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /out/test/fixtures/changePropertyType/inputs/PropertyStatementDocblock.php: -------------------------------------------------------------------------------- 1 | name = $name; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /out/test/fixtures/changePropertyType/inputs/PropertyWithoutType.php: -------------------------------------------------------------------------------- 1 | name = $name; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /out/test/fixtures/changePropertyType/inputs/TypedPropertyStatement.php: -------------------------------------------------------------------------------- 1 | name = $name; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /out/test/fixtures/changePropertyType/outputs/ConstructorDocblock.php: -------------------------------------------------------------------------------- 1 | class = $class; 22 | $this->name = $name; 23 | $this->rank = $rank; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /out/test/fixtures/changePropertyType/outputs/ConstructorWithMultipleProperties.php: -------------------------------------------------------------------------------- 1 | class = $class; 17 | $this->name = $name; 18 | $this->rank = $rank; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /out/test/fixtures/changePropertyType/outputs/ConstructorWithMultiplePropertiesCursorInConstructorDocblock.php: -------------------------------------------------------------------------------- 1 | class = $class; 22 | $this->name = $name; 23 | $this->rank = $rank; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /out/test/fixtures/changePropertyType/outputs/OtherPropertiesStatementDocblock.php: -------------------------------------------------------------------------------- 1 | class = $class; 17 | $this->name = $name; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /out/test/fixtures/changePropertyType/outputs/PropertyStatementDocblock.php: -------------------------------------------------------------------------------- 1 | name = $name; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /out/test/fixtures/changePropertyType/outputs/PropertyWithoutType.php: -------------------------------------------------------------------------------- 1 | name = $name; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /out/test/fixtures/changePropertyType/outputs/TypedPropertyStatement.php: -------------------------------------------------------------------------------- 1 | name = $name; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /out/test/fixtures/customizations/inputs/ConstructorBreakIntoMultiline.php: -------------------------------------------------------------------------------- 1 | rank = $rank; 23 | $this->lightSaberColor = $lightSaberColor; 24 | $this->class = $class; 25 | $this->isCouncilMember = $isCouncilMember; 26 | $this->isHighCouncilMember = $isHighCouncilMember; 27 | $this->occupation = $occupation; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /out/test/fixtures/customizations/inputs/ConstructorBreakIntoMultilineLength.php: -------------------------------------------------------------------------------- 1 | rank = $rank; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /out/test/fixtures/customizations/inputs/ConstructorDefaultVisibility.php: -------------------------------------------------------------------------------- 1 | rank = $rank; 32 | $this->lightSaberColor = $lightSaberColor; 33 | $this->class = $class; 34 | $this->isCouncilMember = $isCouncilMember; 35 | $this->isHighCouncilMember = $isHighCouncilMember; 36 | $this->occupation = $occupation; 37 | $this->name = $name; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /out/test/fixtures/customizations/outputs/ConstructorBreakIntoMultilineLength.php: -------------------------------------------------------------------------------- 1 | rank = $rank; 17 | $this->name = $name; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /out/test/fixtures/customizations/outputs/ConstructorDefaultVisibility.php: -------------------------------------------------------------------------------- 1 | name = $name; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /out/test/fixtures/customizations/outputs/PropertyAddDocblock.php: -------------------------------------------------------------------------------- 1 | name = $name; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /out/test/fixtures/customizations/outputs/PropertyDefaultVisibility.php: -------------------------------------------------------------------------------- 1 | name = $name; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /out/test/fixtures/customizations/outputs/PropertyMultilineDocblock.php: -------------------------------------------------------------------------------- 1 | name = $name; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /out/test/fixtures/existing/inputs/ConstructorDocblockUsingDocblock.php: -------------------------------------------------------------------------------- 1 | rank = $rank; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /out/test/fixtures/existing/inputs/NullableType.php: -------------------------------------------------------------------------------- 1 | name = $name; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /out/test/fixtures/existing/outputs/DocblockTypeWithParameter.php: -------------------------------------------------------------------------------- 1 | name = $name; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /out/test/fixtures/existing/outputs/EmptyClass.php: -------------------------------------------------------------------------------- 1 | name = $name; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /out/test/fixtures/existing/outputs/EmptyConstructor.php: -------------------------------------------------------------------------------- 1 | name = $name; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /out/test/fixtures/existing/outputs/ExistingConstructor.php: -------------------------------------------------------------------------------- 1 | rank = $rank; 15 | $this->name = $name; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /out/test/fixtures/existing/outputs/NullableType.php: -------------------------------------------------------------------------------- 1 | name = $name; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /out/test/fixtures/existing/outputs/UseDocblock.php: -------------------------------------------------------------------------------- 1 | name = $name; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /out/test/fixtures/existing/outputs/UseNullableDocblock.php: -------------------------------------------------------------------------------- 1 | name = $name; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /out/test/fixtures/existing/outputs/UseType.php: -------------------------------------------------------------------------------- 1 | name = $name; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /out/test/fixtures/new/inputs/AddConstructorDocblock.php: -------------------------------------------------------------------------------- 1 | rank = $rank; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /out/test/fixtures/new/inputs/ExistingProperty.php: -------------------------------------------------------------------------------- 1 | rank = $rank; 13 | $this->name = 'Yoda'; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /out/test/fixtures/new/inputs/ExistingPropertyInConstructor.php: -------------------------------------------------------------------------------- 1 | rank = $rank; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /out/test/fixtures/new/inputs/MultipleClasses.php: -------------------------------------------------------------------------------- 1 | rank = $rank; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /out/test/fixtures/new/inputs/UpdateConstructorDocblock.php: -------------------------------------------------------------------------------- 1 | rank = $rank; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /out/test/fixtures/new/outputs/AddConstructorDocblock.php: -------------------------------------------------------------------------------- 1 | name = $name; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /out/test/fixtures/new/outputs/ClassKeyword.php: -------------------------------------------------------------------------------- 1 | name = $name; 17 | } 18 | 19 | public function foo() 20 | { 21 | return new class { 22 | public function __construct() 23 | { 24 | } 25 | }; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /out/test/fixtures/new/outputs/EmptyClass.php: -------------------------------------------------------------------------------- 1 | name = $name; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /out/test/fixtures/new/outputs/EmptyConstructor.php: -------------------------------------------------------------------------------- 1 | name = $name; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /out/test/fixtures/new/outputs/ExistingConstructor.php: -------------------------------------------------------------------------------- 1 | rank = $rank; 15 | $this->name = $name; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /out/test/fixtures/new/outputs/ExistingProperty.php: -------------------------------------------------------------------------------- 1 | name = $name; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /out/test/fixtures/new/outputs/ExistingPropertyAssignation.php: -------------------------------------------------------------------------------- 1 | rank = $rank; 15 | $this->name = 'Yoda'; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /out/test/fixtures/new/outputs/ExistingPropertyInConstructor.php: -------------------------------------------------------------------------------- 1 | name = $name; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /out/test/fixtures/new/outputs/MultilineConstructor.php: -------------------------------------------------------------------------------- 1 | rank = $rank; 17 | $this->name = $name; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /out/test/fixtures/new/outputs/MultipleClasses.php: -------------------------------------------------------------------------------- 1 | name = $name; 13 | } 14 | } 15 | 16 | class Sith 17 | { 18 | 19 | } 20 | -------------------------------------------------------------------------------- /out/test/fixtures/new/outputs/MultipleClassesCursorInFirst.php: -------------------------------------------------------------------------------- 1 | name = $name; 13 | } 14 | } 15 | 16 | class Sith 17 | { 18 | 19 | } 20 | -------------------------------------------------------------------------------- /out/test/fixtures/new/outputs/MultipleClassesCursorInLast.php: -------------------------------------------------------------------------------- 1 | name = $name; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /out/test/fixtures/new/outputs/TabIndentation.php: -------------------------------------------------------------------------------- 1 | rank = $rank; 15 | $this->name = $name; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /out/test/fixtures/new/outputs/UpdateConstructorDocblock.php: -------------------------------------------------------------------------------- 1 | rank = $rank; 19 | $this->name = $name; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /out/test/fixtures/remove/inputs/ConstructorDocblock.php: -------------------------------------------------------------------------------- 1 | class = $class; 22 | $this->name = $name; 23 | $this->rank = $rank; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /out/test/fixtures/remove/inputs/ConstructorWithMultipleProperties.php: -------------------------------------------------------------------------------- 1 | class = $class; 17 | $this->name = $name; 18 | $this->rank = $rank; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /out/test/fixtures/remove/inputs/ConstructorWithMultiplePropertiesCursorInArgument.php: -------------------------------------------------------------------------------- 1 | class = $class; 17 | $this->name = $name; 18 | $this->rank = $rank; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /out/test/fixtures/remove/inputs/ConstructorWithMultiplePropertiesCursorInAssignment.php: -------------------------------------------------------------------------------- 1 | class = $class; 17 | $this->name = $name; 18 | $this->rank = $rank; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /out/test/fixtures/remove/inputs/ConstructorWithMultiplePropertiesCursorInConstructorDocblock.php: -------------------------------------------------------------------------------- 1 | class = $class; 22 | $this->name = $name; 23 | $this->rank = $rank; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /out/test/fixtures/remove/inputs/ConstructorWithMultiplePropertiesCursorInPropertyStatement.php: -------------------------------------------------------------------------------- 1 | class = $class; 17 | $this->name = $name; 18 | $this->rank = $rank; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /out/test/fixtures/remove/inputs/ConstructorWithOneProperty.php: -------------------------------------------------------------------------------- 1 | name = $name; 15 | $this->initialized = true; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /out/test/fixtures/remove/inputs/ConstructorWithOtherArgument.php: -------------------------------------------------------------------------------- 1 | class = $class; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /out/test/fixtures/remove/inputs/ConstructorWithSingleProperty.php: -------------------------------------------------------------------------------- 1 | name = $name; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /out/test/fixtures/remove/inputs/ConstructorWithSinglePropertyAndDocblock.php: -------------------------------------------------------------------------------- 1 | name = $name; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /out/test/fixtures/remove/inputs/EmptyConstructor.php: -------------------------------------------------------------------------------- 1 | name = $name; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /out/test/fixtures/remove/inputs/TypedProperty.php: -------------------------------------------------------------------------------- 1 | name = $name; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /out/test/fixtures/remove/outputs/ConstructorDocblock.php: -------------------------------------------------------------------------------- 1 | class = $class; 19 | $this->rank = $rank; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /out/test/fixtures/remove/outputs/ConstructorWithMultipleProperties.php: -------------------------------------------------------------------------------- 1 | class = $class; 15 | $this->rank = $rank; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /out/test/fixtures/remove/outputs/ConstructorWithMultiplePropertiesCursorInArgument.php: -------------------------------------------------------------------------------- 1 | name = $name; 15 | $this->rank = $rank; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /out/test/fixtures/remove/outputs/ConstructorWithMultiplePropertiesCursorInAssignment.php: -------------------------------------------------------------------------------- 1 | name = $name; 15 | $this->rank = $rank; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /out/test/fixtures/remove/outputs/ConstructorWithMultiplePropertiesCursorInConstructorDocblock.php: -------------------------------------------------------------------------------- 1 | class = $class; 19 | $this->name = $name; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /out/test/fixtures/remove/outputs/ConstructorWithMultiplePropertiesCursorInPropertyStatement.php: -------------------------------------------------------------------------------- 1 | class = $class; 15 | $this->name = $name; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /out/test/fixtures/remove/outputs/ConstructorWithOneProperty.php: -------------------------------------------------------------------------------- 1 | initialized = true; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /out/test/fixtures/remove/outputs/ConstructorWithOtherArgument.php: -------------------------------------------------------------------------------- 1 | class = $class; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /out/test/fixtures/remove/outputs/ConstructorWithSingleProperty.php: -------------------------------------------------------------------------------- 1 | name = $name; 21 | $this->rank = $rank; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /out/test/fixtures/rename/inputs/ConstructorWithMultipleProperties.php: -------------------------------------------------------------------------------- 1 | class = $class; 17 | $this->name = $name; 18 | $this->rank = $rank; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /out/test/fixtures/rename/inputs/ConstructorWithMultiplePropertiesCursorInArgument.php: -------------------------------------------------------------------------------- 1 | class = $class; 17 | $this->name = $name; 18 | $this->rank = $rank; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /out/test/fixtures/rename/inputs/ConstructorWithMultiplePropertiesCursorInAssignment.php: -------------------------------------------------------------------------------- 1 | class = $class; 17 | $this->name = $name; 18 | $this->rank = $rank; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /out/test/fixtures/rename/inputs/ConstructorWithMultiplePropertiesCursorInConstructorDocblock.php: -------------------------------------------------------------------------------- 1 | name = $name; 21 | $this->rank = $rank; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /out/test/fixtures/rename/inputs/ConstructorWithMultiplePropertiesCursorInPropertyStatement.php: -------------------------------------------------------------------------------- 1 | class = $class; 17 | $this->name = $name; 18 | $this->rank = $rank; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /out/test/fixtures/rename/inputs/ConstructorWithSingleProperty.php: -------------------------------------------------------------------------------- 1 | name = $name; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /out/test/fixtures/rename/inputs/MultiplePropertyStatements.php: -------------------------------------------------------------------------------- 1 | name = $name; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /out/test/fixtures/rename/inputs/PropertyReferences.php: -------------------------------------------------------------------------------- 1 | name = "Yoda"; 13 | } 14 | 15 | public function getName(): string 16 | { 17 | return $this->name; 18 | } 19 | 20 | public function getFormattedName(): string 21 | { 22 | $title = self::getTitle($this->name); 23 | 24 | return "{$title} {$this->name}"; 25 | } 26 | 27 | public function setName(string $name) 28 | { 29 | $this->name = $name; 30 | } 31 | 32 | public static function getTitle(string $name): string 33 | { 34 | return $name === "Yoda" ? "Master" : ""; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /out/test/fixtures/rename/outputs/ConstructorDocblock.php: -------------------------------------------------------------------------------- 1 | newName = $newName; 21 | $this->rank = $rank; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /out/test/fixtures/rename/outputs/ConstructorWithMultipleProperties.php: -------------------------------------------------------------------------------- 1 | class = $class; 17 | $this->newName = $newName; 18 | $this->rank = $rank; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /out/test/fixtures/rename/outputs/ConstructorWithMultiplePropertiesCursorInArgument.php: -------------------------------------------------------------------------------- 1 | class = $class; 17 | $this->newName = $newName; 18 | $this->rank = $rank; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /out/test/fixtures/rename/outputs/ConstructorWithMultiplePropertiesCursorInAssignment.php: -------------------------------------------------------------------------------- 1 | class = $class; 17 | $this->newName = $newName; 18 | $this->rank = $rank; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /out/test/fixtures/rename/outputs/ConstructorWithMultiplePropertiesCursorInConstructorDocblock.php: -------------------------------------------------------------------------------- 1 | newName = $newName; 21 | $this->rank = $rank; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /out/test/fixtures/rename/outputs/ConstructorWithMultiplePropertiesCursorInPropertyStatement.php: -------------------------------------------------------------------------------- 1 | class = $class; 17 | $this->newName = $newName; 18 | $this->rank = $rank; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /out/test/fixtures/rename/outputs/ConstructorWithSingleProperty.php: -------------------------------------------------------------------------------- 1 | newName = $newName; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /out/test/fixtures/rename/outputs/MultiplePropertyStatements.php: -------------------------------------------------------------------------------- 1 | newName = $newName; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /out/test/fixtures/rename/outputs/PropertyReferences.php: -------------------------------------------------------------------------------- 1 | newName = "Yoda"; 13 | } 14 | 15 | public function getName(): string 16 | { 17 | return $this->newName; 18 | } 19 | 20 | public function getFormattedName(): string 21 | { 22 | $title = self::getTitle($this->newName); 23 | 24 | return "{$title} {$this->newName}"; 25 | } 26 | 27 | public function setName(string $name) 28 | { 29 | $this->newName = $name; 30 | } 31 | 32 | public static function getTitle(string $name): string 33 | { 34 | return $name === "Yoda" ? "Master" : ""; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /out/test/runTest.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { 3 | function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } 4 | return new (P || (P = Promise))(function (resolve, reject) { 5 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } 6 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } 7 | function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } 8 | step((generator = generator.apply(thisArg, _arguments || [])).next()); 9 | }); 10 | }; 11 | Object.defineProperty(exports, "__esModule", { value: true }); 12 | const path = require("path"); 13 | const vscode_test_1 = require("vscode-test"); 14 | function main() { 15 | return __awaiter(this, void 0, void 0, function* () { 16 | try { 17 | // The folder containing the Extension Manifest package.json 18 | // Passed to `--extensionDevelopmentPath` 19 | const extensionDevelopmentPath = path.resolve(__dirname, '../../'); 20 | // The path to test runner 21 | // Passed to --extensionTestsPath 22 | const extensionTestsPath = path.resolve(__dirname, './suite/index'); 23 | const testUserDir = path.resolve(__dirname, './user'); 24 | const vscodeCompatibilityString = require('../../package.json').engines.vscode; 25 | const vscodeMinimumVersion = vscodeCompatibilityString.replace(/[^\d\.]/g, ''); 26 | yield vscode_test_1.runTests({ 27 | version: vscodeMinimumVersion, 28 | extensionDevelopmentPath, 29 | extensionTestsPath, 30 | launchArgs: [ 31 | `--user-data-dir=${testUserDir}`, 32 | '--disable-extensions' 33 | ], 34 | extensionTestsEnv: { 35 | 'VSCODE_VERSION': vscodeMinimumVersion, 36 | } 37 | }); 38 | yield vscode_test_1.runTests({ 39 | extensionDevelopmentPath, 40 | extensionTestsPath, 41 | launchArgs: [ 42 | `--user-data-dir=${testUserDir}`, 43 | '--disable-extensions' 44 | ] 45 | }); 46 | } 47 | catch (err) { 48 | console.error('Failed to run tests'); 49 | process.exit(1); 50 | } 51 | }); 52 | } 53 | main(); 54 | //# sourceMappingURL=runTest.js.map -------------------------------------------------------------------------------- /out/test/runTest.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"runTest.js","sourceRoot":"","sources":["../../src/test/runTest.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,6BAA6B;AAE7B,6CAAuC;AAEvC,SAAe,IAAI;;QAClB,IAAI;YACH,4DAA4D;YAC5D,yCAAyC;YACzC,MAAM,wBAAwB,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;YAEnE,0BAA0B;YAC1B,iCAAiC;YACjC,MAAM,kBAAkB,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,eAAe,CAAC,CAAC;YAEpE,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;YAEtD,MAAM,yBAAyB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC;YAC/E,MAAM,oBAAoB,GAAG,yBAAyB,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;YAE/E,MAAM,sBAAQ,CACb;gBACC,OAAO,EAAE,oBAAoB;gBAC7B,wBAAwB;gBACxB,kBAAkB;gBAClB,UAAU,EAAE;oBACX,mBAAmB,WAAW,EAAE;oBAChC,sBAAsB;iBACtB;gBACD,iBAAiB,EAAE;oBAClB,gBAAgB,EAAE,oBAAoB;iBACtC;aACD,CACD,CAAC;YAEF,MAAM,sBAAQ,CACb;gBACC,wBAAwB;gBACxB,kBAAkB;gBAClB,UAAU,EAAE;oBACX,mBAAmB,WAAW,EAAE;oBAChC,sBAAsB;iBACtB;aACD,CACD,CAAC;SACF;QAAC,OAAO,GAAG,EAAE;YACb,OAAO,CAAC,KAAK,CAAC,qBAAqB,CAAC,CAAC;YACrC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;SAChB;IACF,CAAC;CAAA;AAED,IAAI,EAAE,CAAC"} -------------------------------------------------------------------------------- /out/test/suite/RemoveProperty.test.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"RemoveProperty.test.js","sourceRoot":"","sources":["../../../src/test/suite/RemoveProperty.test.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,iCAAiC;AACjC,6BAA6B;AAC7B,iCAAiC;AACjC,yBAAyB;AACzB,mCAA6E;AAE7E,MAAM,0BAA0B,GAAG,sBAAsB,CAAC;AAE1D,KAAK,CAAC,iBAAiB,EAAE;IACrB,KAAK,CAAC,GAAS,EAAE;QACb,MAAM,4BAAoB,EAAE,CAAC;IACjC,CAAC,CAAA,CAAC,CAAC;IAEH,QAAQ,CAAC,GAAS,EAAE;QAChB,MAAM,4BAAoB,EAAE,CAAC;IACjC,CAAC,CAAA,CAAC,CAAC;IAEH,IAAI,CAAC,4CAA4C,EAAE,GAAS,EAAE;QAC1D,MAAM,UAAU,CAAC,uCAAuC,CAAC,CAAC;IAC9D,CAAC,CAAA,CAAC,CAAC;IAEH,IAAI,CAAC,8FAA8F,EAAE,GAAS,EAAE;QAC5G,MAAM,UAAU,CAAC,mCAAmC,CAAC,CAAC;IAC1D,CAAC,CAAA,CAAC,CAAC;IAEH,IAAI,CAAC,sGAAsG,EAAE,GAAS,EAAE;QACpH,MAAM,UAAU,CAAC,gCAAgC,CAAC,CAAC;IACvD,CAAC,CAAA,CAAC,CAAC;IAEH,IAAI,CAAC,gCAAgC,EAAE,GAAS,EAAE;QAC9C,MAAM,UAAU,CAAC,mBAAmB,CAAC,CAAC;IAC1C,CAAC,CAAA,CAAC,CAAC;IAEH,IAAI,CAAC,qCAAqC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YACH,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,UAAU,GAAG,CAAC,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,EAAE,cAAc,CAAC,CAAC,CAAC;SACtG;QAED,MAAM,MAAM,CAAC,QAAQ,CAAC,cAAc,CAAC,uBAAuB,CAAC,CAAC;QAE9D,MAAM,YAAY,GAAG,EAAE,CAAC,YAAY,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;QAE7E,MAAM,aAAK,CAAC,6BAAqB,EAAE,GAAG,EAAE;;YACpC,MAAM,CAAC,WAAW,OAAC,MAAM,CAAC,MAAM,CAAC,gBAAgB,0CAAE,QAAQ,CAAC,OAAO,IAAI,YAAY,CAAC,CAAC;QACzF,CAAC,CAAC,CAAC;IACP,CAAC;CAAA;AAED,SAAS,gBAAgB,CAAC,IAAY;IAClC,OAAO,IAAI,CAAC,IAAI,CAAC,SAAS,GAAG,0BAA0B,GAAG,UAAU,IAAI,EAAE,CAAC,CAAC;AAChF,CAAC;AAED,SAAS,iBAAiB,CAAC,IAAY;IACnC,OAAO,IAAI,CAAC,IAAI,CAAC,SAAS,GAAG,0BAA0B,GAAG,WAAW,IAAI,EAAE,CAAC,CAAC;AACjF,CAAC"} -------------------------------------------------------------------------------- /out/test/suite/addExistingProperty.test.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { 3 | function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } 4 | return new (P || (P = Promise))(function (resolve, reject) { 5 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } 6 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } 7 | function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } 8 | step((generator = generator.apply(thisArg, _arguments || [])).next()); 9 | }); 10 | }; 11 | Object.defineProperty(exports, "__esModule", { value: true }); 12 | const vscode = require("vscode"); 13 | const path = require("path"); 14 | const assert = require("assert"); 15 | const fs = require("fs"); 16 | const utils_1 = require("./utils"); 17 | const testFolderRelativeLocation = '/../fixtures/existing/'; 18 | suite('Add Existing Property', function () { 19 | setup(() => __awaiter(this, void 0, void 0, function* () { 20 | yield utils_1.resetDefaultSettings(); 21 | })); 22 | teardown(() => __awaiter(this, void 0, void 0, function* () { 23 | yield utils_1.resetDefaultSettings(); 24 | })); 25 | test('Should add an existing property and constructor in an empty class', () => __awaiter(this, void 0, void 0, function* () { 26 | yield runFixture('EmptyClass.php', new vscode.Position(7, 0)); 27 | })); 28 | test('Should add an existing property to an empty constructor', () => __awaiter(this, void 0, void 0, function* () { 29 | yield runFixture('EmptyConstructor.php', new vscode.Position(7, 0)); 30 | })); 31 | test('Should add an existing property to an existing constructor', () => __awaiter(this, void 0, void 0, function* () { 32 | yield runFixture('ExistingConstructor.php', new vscode.Position(9, 0)); 33 | })); 34 | test('Should add an existing property using type from docblock', () => __awaiter(this, void 0, void 0, function* () { 35 | yield runFixture('UseDocblock.php', new vscode.Position(8, 0)); 36 | })); 37 | test('Should add an existing property using its PHP7.4+ type', () => __awaiter(this, void 0, void 0, function* () { 38 | yield runFixture('UseType.php', new vscode.Position(8, 0)); 39 | })); 40 | test('Should add a docblock with @param using type from property docblock', () => __awaiter(this, void 0, void 0, function* () { 41 | yield vscode.workspace.getConfiguration('phpAddProperty').update('constructor.docblock.enable', true, true); 42 | yield runFixture('ConstructorDocblockUsingDocblock.php', new vscode.Position(8, 0)); 43 | })); 44 | test('Should NOT add an extra space when adding property type and docblock type at the same type', () => __awaiter(this, void 0, void 0, function* () { 45 | yield vscode.workspace.getConfiguration('phpAddProperty').update('constructor.docblock.enable', true, true); 46 | yield vscode.workspace.getConfiguration('phpAddProperty').update('constructor.docblock.withParameter', true, true); 47 | yield runFixture('DocblockTypeWithParameter.php', new vscode.Position(10, 22)); 48 | })); 49 | test('Should add an existing property with a nullable type', () => __awaiter(this, void 0, void 0, function* () { 50 | yield vscode.workspace.getConfiguration('phpAddProperty').update('constructor.docblock.enable', true, true); 51 | yield runFixture('NullableType.php', new vscode.Position(10, 0)); 52 | })); 53 | test('Should add a nullable property using type from property docblock', () => __awaiter(this, void 0, void 0, function* () { 54 | yield runFixture('UseNullableDocblock.php', new vscode.Position(8, 0)); 55 | })); 56 | }); 57 | function runFixture(fileName, cursorPosition) { 58 | return __awaiter(this, void 0, void 0, function* () { 59 | const uri = vscode.Uri.file(getInputFilePath(fileName)); 60 | const document = yield vscode.workspace.openTextDocument(uri); 61 | yield vscode.window.showTextDocument(document); 62 | if (!vscode.window.activeTextEditor) { 63 | return; 64 | } 65 | vscode.window.activeTextEditor.selections = [new vscode.Selection(cursorPosition, cursorPosition)]; 66 | yield vscode.commands.executeCommand('phpAddProperty.append'); 67 | const expectedText = fs.readFileSync(getOutputFilePath(fileName)).toString(); 68 | yield utils_1.delay(utils_1.waitToAssertInSeconds, () => { 69 | var _a; 70 | assert.strictEqual((_a = vscode.window.activeTextEditor) === null || _a === void 0 ? void 0 : _a.document.getText(), expectedText); 71 | }); 72 | }); 73 | } 74 | function getInputFilePath(name) { 75 | return path.join(__dirname + testFolderRelativeLocation + `inputs/${name}`); 76 | } 77 | function getOutputFilePath(name) { 78 | return path.join(__dirname + testFolderRelativeLocation + `outputs/${name}`); 79 | } 80 | //# sourceMappingURL=addExistingProperty.test.js.map -------------------------------------------------------------------------------- /out/test/suite/addExistingProperty.test.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"addExistingProperty.test.js","sourceRoot":"","sources":["../../../src/test/suite/addExistingProperty.test.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,iCAAiC;AACjC,6BAA6B;AAC7B,iCAAiC;AACjC,yBAAyB;AACzB,mCAA6E;AAE7E,MAAM,0BAA0B,GAAG,wBAAwB,CAAC;AAE5D,KAAK,CAAC,uBAAuB,EAAE;IAC3B,KAAK,CAAC,GAAS,EAAE;QACb,MAAM,4BAAoB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AAQ,GAAG,MAAM,MAAM,CAAC,SAAS,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC;QAC9D,MAAM,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC;QAE/C,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,gBAAgB,EAAE;YACjC,OAAO;SACV;QAED,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,UAAU,GAAG,CAAC,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,EAAE,cAAc,CAAC,CAAC,CAAC;QAEnG,MAAM,MAAM,CAAC,QAAQ,CAAC,cAAc,CAAC,uBAAuB,CAAC,CAAC;QAE9D,MAAM,YAAY,GAAG,EAAE,CAAC,YAAY,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;QAE7E,MAAM,aAAK,CAAC,6BAAqB,EAAE,GAAG,EAAE;;YACpC,MAAM,CAAC,WAAW,OAAC,MAAM,CAAC,MAAM,CAAC,gBAAgB,0CAAE,QAAQ,CAAC,OAAO,IAAI,YAAY,CAAC,CAAC;QACzF,CAAC,CAAC,CAAC;IACP,CAAC;CAAA;AAED,SAAS,gBAAgB,CAAC,IAAY;IAClC,OAAO,IAAI,CAAC,IAAI,CAAC,SAAS,GAAG,0BAA0B,GAAG,UAAU,IAAI,EAAE,CAAC,CAAC;AAChF,CAAC;AAED,SAAS,iBAAiB,CAAC,IAAY;IACnC,OAAO,IAAI,CAAC,IAAI,CAAC,SAAS,GAAG,0BAA0B,GAAG,WAAW,IAAI,EAAE,CAAC,CAAC;AACjF,CAAC"} -------------------------------------------------------------------------------- /out/test/suite/addProperty.test.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"addProperty.test.js","sourceRoot":"","sources":["../../../src/test/suite/addProperty.test.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,iCAAiC;AACjC,6BAA6B;AAC7B,iCAAiC;AACjC,yBAAyB;AACzB,mCAA6E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CAAC"} -------------------------------------------------------------------------------- /out/test/suite/breakConstructorIntoMultiline.test.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { 3 | function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } 4 | return new (P || (P = Promise))(function (resolve, reject) { 5 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } 6 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } 7 | function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } 8 | step((generator = generator.apply(thisArg, _arguments || [])).next()); 9 | }); 10 | }; 11 | Object.defineProperty(exports, "__esModule", { value: true }); 12 | const vscode = require("vscode"); 13 | const path = require("path"); 14 | const assert = require("assert"); 15 | const fs = require("fs"); 16 | const utils_1 = require("./utils"); 17 | const testFolderRelativeLocation = '/../fixtures/breakConstructorIntoMultiline/'; 18 | suite('Break Constructor Into Multilines', function () { 19 | setup(() => __awaiter(this, void 0, void 0, function* () { 20 | yield utils_1.resetDefaultSettings(); 21 | })); 22 | teardown(() => __awaiter(this, void 0, void 0, function* () { 23 | yield utils_1.resetDefaultSettings(); 24 | })); 25 | test('Should break the constructor into multiline regardless of the settings', () => __awaiter(this, void 0, void 0, function* () { 26 | yield vscode.workspace.getConfiguration('phpAddProperty').update('constructor.breakIntoMultilineIfLengthExceeded.enabled', false, true); 27 | yield vscode.workspace.getConfiguration('phpAddProperty').update('constructor.breakIntoMultilineIfLengthExceeded.maxLineLength', 999, true); 28 | yield runFixture('Constructor.php'); 29 | })); 30 | }); 31 | function runFixture(fileName) { 32 | return __awaiter(this, void 0, void 0, function* () { 33 | const uri = vscode.Uri.file(getInputFilePath(fileName)); 34 | const document = yield vscode.workspace.openTextDocument(uri); 35 | yield vscode.window.showTextDocument(document); 36 | yield vscode.commands.executeCommand('phpAddProperty.breakConstructorIntoMultiline'); 37 | const expectedText = fs.readFileSync(getOutputFilePath(fileName)).toString(); 38 | yield utils_1.delay(utils_1.waitToAssertInSeconds, () => { 39 | var _a; 40 | assert.strictEqual((_a = vscode.window.activeTextEditor) === null || _a === void 0 ? void 0 : _a.document.getText(), expectedText); 41 | }); 42 | }); 43 | } 44 | function getInputFilePath(name) { 45 | return path.join(__dirname + testFolderRelativeLocation + `inputs/${name}`); 46 | } 47 | function getOutputFilePath(name) { 48 | return path.join(__dirname + testFolderRelativeLocation + `outputs/${name}`); 49 | } 50 | //# sourceMappingURL=breakConstructorIntoMultiline.test.js.map -------------------------------------------------------------------------------- /out/test/suite/breakConstructorIntoMultiline.test.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"breakConstructorIntoMultiline.test.js","sourceRoot":"","sources":["../../../src/test/suite/breakConstructorIntoMultiline.test.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,iCAAiC;AACjC,6BAA6B;AAC7B,iCAAiC;AACjC,yBAAyB;AACzB,mCAA6E;AAE7E,MAAM,0BAA0B,GAAG,6CAA6C,CAAC;AAEjF,KAAK,CAAC,mCAAmC,EAAE;IACvC,KAAK,CAAC,GAAS,EAAE;QACb,MAAM,4BAAoB,EAAE,CAAC;IACjC,CAAC,CAAA,CAAC,CAAC;IAEH,QAAQ,CAAC,GAAS,EAAE;QAChB,MAAM,4BAAoB,EAAE,CAAC;IACjC,CAAC,CAAA,CAAC,CAAC;IAEH,IAAI,CAAC,wEAAwE,EAAE,GAAS,EAAE;QACtF,MAAM,MAAM,CAAC,SAAS,CAAC,gBAAgB,CAAC,gBAAgB,CAAC,CAAC,MAAM,CAAC,wDAAwD,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;QACxI,MAAM,MAAM,CAAC,SAAS,CAAC,gBAAgB,CAAC,gBAAgB,CAAC,CAAC,MAAM,CAAC,8DAA8D,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;QAC5I,MAAM,UAAU,CAAC,iBAAiB,CAAC,CAAC;IACxC,CAAC,CAAA,CAAC,CAAC;AACP,CAAC,CAAC,CAAC;AAEH,SAAe,UAAU,CAAC,QAAgB;;QACtC,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,IAAI,CACvB,gBAAgB,CAAC,QAAQ,CAAC,CAC7B,CAAC;QACF,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,SAAS,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC;QAC9D,MAAM,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC;QAE/C,MAAM,MAAM,CAAC,QAAQ,CAAC,cAAc,CAAC,8CAA8C,CAAC,CAAC;QAErF,MAAM,YAAY,GAAG,EAAE,CAAC,YAAY,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;QAE7E,MAAM,aAAK,CAAC,6BAAqB,EAAE,GAAG,EAAE;;YACpC,MAAM,CAAC,WAAW,OAAC,MAAM,CAAC,MAAM,CAAC,gBAAgB,0CAAE,QAAQ,CAAC,OAAO,IAAI,YAAY,CAAC,CAAC;QACzF,CAAC,CAAC,CAAC;IACP,CAAC;CAAA;AAED,SAAS,gBAAgB,CAAC,IAAY;IAClC,OAAO,IAAI,CAAC,IAAI,CAAC,SAAS,GAAG,0BAA0B,GAAG,UAAU,IAAI,EAAE,CAAC,CAAC;AAChF,CAAC;AAED,SAAS,iBAAiB,CAAC,IAAY;IACnC,OAAO,IAAI,CAAC,IAAI,CAAC,SAAS,GAAG,0BAA0B,GAAG,WAAW,IAAI,EAAE,CAAC,CAAC;AACjF,CAAC"} -------------------------------------------------------------------------------- /out/test/suite/changePropertyType.test.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { 3 | function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } 4 | return new (P || (P = Promise))(function (resolve, reject) { 5 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } 6 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } 7 | function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } 8 | step((generator = generator.apply(thisArg, _arguments || [])).next()); 9 | }); 10 | }; 11 | Object.defineProperty(exports, "__esModule", { value: true }); 12 | const vscode = require("vscode"); 13 | const path = require("path"); 14 | const assert = require("assert"); 15 | const fs = require("fs"); 16 | const utils_1 = require("./utils"); 17 | const testFolderRelativeLocation = '/../fixtures/changePropertyType/'; 18 | suite('Change Property Type', function () { 19 | setup(() => __awaiter(this, void 0, void 0, function* () { 20 | yield utils_1.resetDefaultSettings(); 21 | })); 22 | teardown(() => __awaiter(this, void 0, void 0, function* () { 23 | yield utils_1.resetDefaultSettings(); 24 | })); 25 | test('Should change a property type by name', () => __awaiter(this, void 0, void 0, function* () { 26 | yield runFixture('ConstructorWithMultipleProperties.php'); 27 | })); 28 | test('Should change the property statement type if already exists', () => __awaiter(this, void 0, void 0, function* () { 29 | yield runFixture('TypedPropertyStatement.php'); 30 | })); 31 | test('Should change the property statement type if typed properties is enabled', () => __awaiter(this, void 0, void 0, function* () { 32 | yield vscode.workspace.getConfiguration('phpAddProperty').update('property.types', true, true); 33 | yield runFixture('PropertyWithoutType.php'); 34 | })); 35 | test('Should change property statement docblock type', () => __awaiter(this, void 0, void 0, function* () { 36 | yield runFixture('PropertyStatementDocblock.php'); 37 | })); 38 | test('Should NOT change other properties statement docblock type', () => __awaiter(this, void 0, void 0, function* () { 39 | yield runFixture('OtherPropertiesStatementDocblock.php'); 40 | })); 41 | test('Should change property type in constructor docblock', () => __awaiter(this, void 0, void 0, function* () { 42 | yield runFixture('ConstructorDocblock.php'); 43 | })); 44 | test('Should rename a property when the cursor is placed in its constructor docblock param', () => __awaiter(this, void 0, void 0, function* () { 45 | yield runFixture('ConstructorWithMultiplePropertiesCursorInConstructorDocblock.php', new vscode.Position(15, 17)); 46 | })); 47 | }); 48 | function runFixture(fileName, cursorPosition) { 49 | return __awaiter(this, void 0, void 0, function* () { 50 | const uri = vscode.Uri.file(getInputFilePath(fileName)); 51 | const document = yield vscode.workspace.openTextDocument(uri); 52 | yield vscode.window.showTextDocument(document); 53 | if (!vscode.window.activeTextEditor) { 54 | return; 55 | } 56 | if (cursorPosition === undefined) { 57 | let first = true; 58 | vscode.window.showInputBox = function (options, token) { 59 | if (first === true) { 60 | first = false; 61 | return Promise.resolve('name'); 62 | } 63 | return Promise.resolve('Name'); 64 | }; 65 | } 66 | else { 67 | vscode.window.activeTextEditor.selections = [new vscode.Selection(cursorPosition, cursorPosition)]; 68 | vscode.window.showInputBox = function (options, token) { 69 | return Promise.resolve('Name'); 70 | }; 71 | } 72 | yield vscode.commands.executeCommand('phpAddProperty.changeType'); 73 | const expectedText = fs.readFileSync(getOutputFilePath(fileName)).toString(); 74 | yield utils_1.delay(utils_1.waitToAssertInSeconds, () => { 75 | var _a; 76 | assert.strictEqual((_a = vscode.window.activeTextEditor) === null || _a === void 0 ? void 0 : _a.document.getText(), expectedText); 77 | }); 78 | }); 79 | } 80 | function getInputFilePath(name) { 81 | return path.join(__dirname + testFolderRelativeLocation + `inputs/${name}`); 82 | } 83 | function getOutputFilePath(name) { 84 | return path.join(__dirname + testFolderRelativeLocation + `outputs/${name}`); 85 | } 86 | //# sourceMappingURL=changePropertyType.test.js.map -------------------------------------------------------------------------------- /out/test/suite/changePropertyType.test.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"changePropertyType.test.js","sourceRoot":"","sources":["../../../src/test/suite/changePropertyType.test.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,iCAAiC;AACjC,6BAA6B;AAC7B,iCAAiC;AACjC,yBAAyB;AACzB,mCAA6E;AAE7E,MAAM,0BAA0B,GAAG,kCAAkC,CAAC;AAEtE,KAAK,CAAC,sBAAsB,EAAE;IAC1B,KAAK,CAAC,GAAS,EAAE;QACb,MAAM,4BAAoB,EAAE,CAAC;IACjC,CAAC,CAAA,CAAC,CAAC;IAEH,QAAQ,C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IAAI,YAAY,CAAC,CAAC;QACzF,CAAC,CAAC,CAAC;IACP,CAAC;CAAA;AAED,SAAS,gBAAgB,CAAC,IAAY;IAClC,OAAO,IAAI,CAAC,IAAI,CAAC,SAAS,GAAG,0BAA0B,GAAG,UAAU,IAAI,EAAE,CAAC,CAAC;AAChF,CAAC;AAED,SAAS,iBAAiB,CAAC,IAAY;IACnC,OAAO,IAAI,CAAC,IAAI,CAAC,SAAS,GAAG,0BAA0B,GAAG,WAAW,IAAI,EAAE,CAAC,CAAC;AACjF,CAAC"} -------------------------------------------------------------------------------- /out/test/suite/customizations.test.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { 3 | function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } 4 | return new (P || (P = Promise))(function (resolve, reject) { 5 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } 6 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } 7 | function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } 8 | step((generator = generator.apply(thisArg, _arguments || [])).next()); 9 | }); 10 | }; 11 | Object.defineProperty(exports, "__esModule", { value: true }); 12 | const vscode = require("vscode"); 13 | const path = require("path"); 14 | const assert = require("assert"); 15 | const fs = require("fs"); 16 | const utils_1 = require("./utils"); 17 | const testFolderRelativeLocation = '/../fixtures/customizations/'; 18 | suite('Customizations', function () { 19 | setup(() => __awaiter(this, void 0, void 0, function* () { 20 | yield utils_1.resetDefaultSettings(); 21 | })); 22 | teardown(() => __awaiter(this, void 0, void 0, function* () { 23 | yield utils_1.resetDefaultSettings(); 24 | })); 25 | test('Should use the specified property default visibility', () => __awaiter(this, void 0, void 0, function* () { 26 | yield vscode.workspace.getConfiguration('phpAddProperty').update('property.visibility.default', 'public', true); 27 | yield runFixture('PropertyDefaultVisibility.php'); 28 | })); 29 | test('Should add the docblock', () => __awaiter(this, void 0, void 0, function* () { 30 | yield vscode.workspace.getConfiguration('phpAddProperty').update('property.docblock.add', true, true); 31 | yield runFixture('PropertyAddDocblock.php'); 32 | })); 33 | test('Should add a multiline docblock', () => __awaiter(this, void 0, void 0, function* () { 34 | yield vscode.workspace.getConfiguration('phpAddProperty').update('property.docblock.add', true, true); 35 | yield vscode.workspace.getConfiguration('phpAddProperty').update('property.docblock.multiline', true, true); 36 | yield runFixture('PropertyMultilineDocblock.php'); 37 | })); 38 | test('Should use the specified constructor default visibility', () => __awaiter(this, void 0, void 0, function* () { 39 | yield vscode.workspace.getConfiguration('phpAddProperty').update('constructor.visibility.default', 'private', true); 40 | yield runFixture('ConstructorDefaultVisibility.php'); 41 | })); 42 | test('Should break constructor into multiple lines', () => __awaiter(this, void 0, void 0, function* () { 43 | yield vscode.workspace.getConfiguration('phpAddProperty').update('constructor.breakIntoMultilineIfLengthExceeded.enabled', true, true); 44 | yield runFixture('ConstructorBreakIntoMultiline.php'); 45 | })); 46 | test('Should break constructor into multiple lines at a specified length', () => __awaiter(this, void 0, void 0, function* () { 47 | yield vscode.workspace.getConfiguration('phpAddProperty').update('constructor.breakIntoMultilineIfLengthExceeded.enabled', true, true); 48 | yield vscode.workspace.getConfiguration('phpAddProperty').update('constructor.breakIntoMultilineIfLengthExceeded.maxLineLength', 40, true); 49 | yield runFixture('ConstructorBreakIntoMultilineLength.php'); 50 | })); 51 | }); 52 | function runFixture(fileName) { 53 | return __awaiter(this, void 0, void 0, function* () { 54 | vscode.window.showInputBox = function (options, token) { 55 | return Promise.resolve('name'); 56 | }; 57 | const uri = vscode.Uri.file(getInputFilePath(fileName)); 58 | const document = yield vscode.workspace.openTextDocument(uri); 59 | yield vscode.window.showTextDocument(document); 60 | yield vscode.commands.executeCommand('phpAddProperty.add'); 61 | const expectedText = fs.readFileSync(getOutputFilePath(fileName)).toString(); 62 | yield utils_1.delay(utils_1.waitToAssertInSeconds, () => { 63 | var _a; 64 | assert.strictEqual((_a = vscode.window.activeTextEditor) === null || _a === void 0 ? void 0 : _a.document.getText(), expectedText); 65 | }); 66 | }); 67 | } 68 | function getInputFilePath(name) { 69 | return path.join(__dirname + testFolderRelativeLocation + `inputs/${name}`); 70 | } 71 | function getOutputFilePath(name) { 72 | return path.join(__dirname + testFolderRelativeLocation + `outputs/${name}`); 73 | } 74 | //# sourceMappingURL=customizations.test.js.map -------------------------------------------------------------------------------- /out/test/suite/customizations.test.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"customizations.test.js","sourceRoot":"","sources":["../../../src/test/suite/customizations.test.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,iCAAiC;AACjC,6BAA6B;AAC7B,iCAAiC;AACjC,yBAAyB;AACzB,mCAA6E;AAE7E,MAAM,0BAA0B,GAAG,8BAA8B,CAAC;AAElE,KAAK,CAAC,gBAAgB,EAAE;IACpB,KAAK,CAAC,GAAS,EAAE;QACb,MAAM,4BAAoB,EAAE,CAAC;IACjC,CAAC,CAAA,CAAC,CAAC;IAEH,QAAQ,CAAC,GAAS,EAAE;QAChB,MAAM,4BAAoB,EAAE,CAAC;IACjC,CAAC,CAAA,CAAC,CAAC;IAEH,IAAI,CAAC,sDAAsD,EAAE,GAAS,EAAE;QACpE,MAAM,MAAM,CAAC,SAAS,CAAC,gBAAgB,CAAC,gBAAgB,CAAC,CAAC,MAAM,CAAC,6BAA6B,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC;QAChH,MAAM,UAAU,CAAC,+BAA+B,CAAC,CAAC;IACtD,CAAC,CAAA,CAAC,CAAC;IAEH,IAAI,CAAC,yBAAyB,EAAE,GAAS,EAAE;QACvC,MAAM,MAAM,CAAC,SAAS,CAAC,gBAAgB,CAAC,gBAAgB,CAAC,CAAC,MAAM,CAAC,uBAAuB,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;QACtG,MAAM,UAAU,CAAC,yBAAyB,CAAC,CAAC;IAChD,CAAC,CAAA,CAAC,CAAC;IAEH,IAAI,CAAC,iCAAiC,EA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AC,CAAC;AAEH,SAAe,UAAU,CAAC,QAAgB;;QACtC,MAAM,CAAC,MAAM,CAAC,YAAY,GAAG,UACzB,OAA4C,EAC5C,KAA4C;YAE5C,OAAO,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QACnC,CAAC,CAAC;QAEF,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,IAAI,CACvB,gBAAgB,CAAC,QAAQ,CAAC,CAC7B,CAAC;QACF,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,SAAS,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC;QAC9D,MAAM,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC;QAE/C,MAAM,MAAM,CAAC,QAAQ,CAAC,cAAc,CAAC,oBAAoB,CAAC,CAAC;QAE3D,MAAM,YAAY,GAAG,EAAE,CAAC,YAAY,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;QAE7E,MAAM,aAAK,CAAC,6BAAqB,EAAE,GAAG,EAAE;;YACpC,MAAM,CAAC,WAAW,OAAC,MAAM,CAAC,MAAM,CAAC,gBAAgB,0CAAE,QAAQ,CAAC,OAAO,IAAI,YAAY,CAAC,CAAC;QACzF,CAAC,CAAC,CAAC;IACP,CAAC;CAAA;AAED,SAAS,gBAAgB,CAAC,IAAY;IAClC,OAAO,IAAI,CAAC,IAAI,CAAC,SAAS,GAAG,0BAA0B,GAAG,UAAU,IAAI,EAAE,CAAC,CAAC;AAChF,CAAC;AAED,SAAS,iBAAiB,CAAC,IAAY;IACnC,OAAO,IAAI,CAAC,IAAI,CAAC,SAAS,GAAG,0BAA0B,GAAG,WAAW,IAAI,EAAE,CAAC,CAAC;AACjF,CAAC"} -------------------------------------------------------------------------------- /out/test/suite/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | const path = require("path"); 4 | const Mocha = require("mocha"); 5 | const glob = require("glob"); 6 | function run() { 7 | // Create the mocha test 8 | const mocha = new Mocha({ 9 | ui: 'tdd', 10 | color: true 11 | }); 12 | const testsRoot = path.resolve(__dirname, '..'); 13 | return new Promise((c, e) => { 14 | glob('**/**.test.js', { cwd: testsRoot }, (err, files) => { 15 | if (err) { 16 | return e(err); 17 | } 18 | // Add files to the test suite 19 | files.forEach(f => mocha.addFile(path.resolve(testsRoot, f))); 20 | try { 21 | // Run the mocha test 22 | mocha.run(failures => { 23 | if (process.env.VSCODE_VERSION === '1.31.0') { 24 | process.exit(failures > 0 ? 1 : 0); 25 | } 26 | if (failures > 0) { 27 | e(new Error(`${failures} tests failed.`)); 28 | } 29 | else { 30 | c(); 31 | } 32 | }); 33 | } 34 | catch (err) { 35 | console.error(err); 36 | e(err); 37 | } 38 | }); 39 | }); 40 | } 41 | exports.run = run; 42 | //# sourceMappingURL=index.js.map -------------------------------------------------------------------------------- /out/test/suite/index.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/test/suite/index.ts"],"names":[],"mappings":";;AAAA,6BAA6B;AAC7B,+BAA+B;AAC/B,6BAA6B;AAE7B,SAAgB,GAAG;IAClB,wBAAwB;IACxB,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC;QACvB,EAAE,EAAE,KAAK;QACT,KAAK,EAAE,IAAI;KACX,CAAC,CAAC;IAEH,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;IAEhD,OAAO,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;QAC3B,IAAI,CAAC,eAAe,EAAE,EAAE,GAAG,EAAE,SAAS,EAAE,EAAE,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE;YACxD,IAAI,GAAG,EAAE;gBACR,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC;aACd;YAED,8BAA8B;YAC9B,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;YAE9D,IAAI;gBACH,qBAAqB;gBACrB,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE;oBACpB,IAAI,OAAO,CAAC,GAAG,CAAC,cAAc,KAAK,QAAQ,EAAE;wBAC5C,OAAO,CAAC,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;qBACnC;oBAED,IAAI,QAAQ,GAAG,CAAC,EAAE;wBACjB,CAAC,CAAC,IAAI,KAAK,CAAC,GAAG,QAAQ,gBAAgB,CAAC,CAAC,CAAC;qBAC1C;yBAAM;wBACN,CAAC,EAAE,CAAC;qBACJ;gBACF,CAAC,CAAC,CAAC;aACH;YAAC,OAAO,GAAG,EAAE;gBACb,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;gBACnB,CAAC,CAAC,GAAG,CAAC,CAAC;aACP;QACF,CAAC,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;AACJ,CAAC;AArCD,kBAqCC"} -------------------------------------------------------------------------------- /out/test/suite/removeProperty.test.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { 3 | function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } 4 | return new (P || (P = Promise))(function (resolve, reject) { 5 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } 6 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } 7 | function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } 8 | step((generator = generator.apply(thisArg, _arguments || [])).next()); 9 | }); 10 | }; 11 | Object.defineProperty(exports, "__esModule", { value: true }); 12 | const vscode = require("vscode"); 13 | const path = require("path"); 14 | const assert = require("assert"); 15 | const fs = require("fs"); 16 | const utils_1 = require("./utils"); 17 | const testFolderRelativeLocation = '/../fixtures/remove/'; 18 | suite('Remove Property', function () { 19 | setup(() => __awaiter(this, void 0, void 0, function* () { 20 | yield utils_1.resetDefaultSettings(); 21 | })); 22 | teardown(() => __awaiter(this, void 0, void 0, function* () { 23 | yield utils_1.resetDefaultSettings(); 24 | })); 25 | test('Should remove an existing property by name', () => __awaiter(this, void 0, void 0, function* () { 26 | yield runFixture('ConstructorWithMultipleProperties.php'); 27 | })); 28 | test('Should remove the constructor method when the body is empty', () => __awaiter(this, void 0, void 0, function* () { 29 | yield runFixture('EmptyConstructor.php'); 30 | })); 31 | test('Should remove the constructor method when the body is empty after removing the last property', () => __awaiter(this, void 0, void 0, function* () { 32 | yield runFixture('ConstructorWithSingleProperty.php'); 33 | })); 34 | test('Should NOT remove the constructor method when the body is NOT empty after removing the last property', () => __awaiter(this, void 0, void 0, function* () { 35 | yield runFixture('ConstructorWithOneProperty.php'); 36 | })); 37 | test('Should NOT remove the constructor argument when the property name does not match', () => __awaiter(this, void 0, void 0, function* () { 38 | yield runFixture('ConstructorWithOtherArgument.php'); 39 | })); 40 | test('Should remove the constructor docblock along with the constructor', () => __awaiter(this, void 0, void 0, function* () { 41 | yield runFixture('ConstructorWithSinglePropertyAndDocblock.php'); 42 | })); 43 | test('Should remove typed properties', () => __awaiter(this, void 0, void 0, function* () { 44 | yield runFixture('TypedProperty.php'); 45 | })); 46 | test('Should remove the property docblock', () => __awaiter(this, void 0, void 0, function* () { 47 | yield runFixture('PropertyWithDocblock.php'); 48 | })); 49 | test('Should remove the property from the constructor docblock', () => __awaiter(this, void 0, void 0, function* () { 50 | yield runFixture('ConstructorDocblock.php'); 51 | })); 52 | test('Should remove a property when the cursor is placed in its statement', () => __awaiter(this, void 0, void 0, function* () { 53 | yield runFixture('ConstructorWithMultiplePropertiesCursorInPropertyStatement.php', new vscode.Position(11, 13)); 54 | })); 55 | test('Should remove a property when the cursor is placed in its constructor argument', () => __awaiter(this, void 0, void 0, function* () { 56 | yield runFixture('ConstructorWithMultiplePropertiesCursorInArgument.php', new vscode.Position(13, 35)); 57 | })); 58 | test('Should remove a property when the cursor is placed in its assignment', () => __awaiter(this, void 0, void 0, function* () { 59 | yield runFixture('ConstructorWithMultiplePropertiesCursorInAssignment.php', new vscode.Position(15, 18)); 60 | })); 61 | test('Should remove a property when the cursor is placed in its constructor docblock', () => __awaiter(this, void 0, void 0, function* () { 62 | yield runFixture('ConstructorWithMultiplePropertiesCursorInConstructorDocblock.php', new vscode.Position(16, 24)); 63 | })); 64 | }); 65 | function runFixture(fileName, cursorPosition) { 66 | return __awaiter(this, void 0, void 0, function* () { 67 | const uri = vscode.Uri.file(getInputFilePath(fileName)); 68 | const document = yield vscode.workspace.openTextDocument(uri); 69 | yield vscode.window.showTextDocument(document); 70 | if (!vscode.window.activeTextEditor) { 71 | return; 72 | } 73 | if (cursorPosition === undefined) { 74 | vscode.window.showInputBox = function (options, token) { 75 | return Promise.resolve('name'); 76 | }; 77 | } 78 | else { 79 | vscode.window.activeTextEditor.selections = [new vscode.Selection(cursorPosition, cursorPosition)]; 80 | } 81 | yield vscode.commands.executeCommand('phpAddProperty.remove'); 82 | const expectedText = fs.readFileSync(getOutputFilePath(fileName)).toString(); 83 | yield utils_1.delay(utils_1.waitToAssertInSeconds, () => { 84 | var _a; 85 | assert.strictEqual((_a = vscode.window.activeTextEditor) === null || _a === void 0 ? void 0 : _a.document.getText(), expectedText); 86 | }); 87 | }); 88 | } 89 | function getInputFilePath(name) { 90 | return path.join(__dirname + testFolderRelativeLocation + `inputs/${name}`); 91 | } 92 | function getOutputFilePath(name) { 93 | return path.join(__dirname + testFolderRelativeLocation + `outputs/${name}`); 94 | } 95 | //# sourceMappingURL=removeProperty.test.js.map -------------------------------------------------------------------------------- /out/test/suite/removeProperty.test.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"removeProperty.test.js","sourceRoot":"","sources":["../../../src/test/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AC,MAAM,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC;QAE/C,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,gBAAgB,EAAE;YACjC,OAAO;SACV;QAED,IAAI,cAAc,KAAK,SAAS,EAAE;YAC9B,MAAM,CAAC,MAAM,CAAC,YAAY,GAAG,UACzB,OAA4C,EAC5C,KAA4C;gBAE5C,OAAO,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;YACnC,CAAC,CAAC;SACL;aAAM;YACH,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,UAAU,GAAG,CAAC,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,EAAE,cAAc,CAAC,CAAC,CAAC;SACtG;QAED,MAAM,MAAM,CAAC,QAAQ,CAAC,cAAc,CAAC,uBAAuB,CAAC,CAAC;QAE9D,MAAM,YAAY,GAAG,EAAE,CAAC,YAAY,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;QAE7E,MAAM,aAAK,CAAC,6BAAqB,EAAE,GAAG,EAAE;;YACpC,MAAM,CAAC,WAAW,OAAC,MAAM,CAAC,MAAM,CAAC,gBAAgB,0CAAE,QAAQ,CAAC,OAAO,IAAI,YAAY,CAAC,CAAC;QACzF,CAAC,CAAC,CAAC;IACP,CAAC;CAAA;AAED,SAAS,gBAAgB,CAAC,IAAY;IAClC,OAAO,IAAI,CAAC,IAAI,CAAC,SAAS,GAAG,0BAA0B,GAAG,UAAU,IAAI,EAAE,CAAC,CAAC;AAChF,CAAC;AAED,SAAS,iBAAiB,CAAC,IAAY;IACnC,OAAO,IAAI,CAAC,IAAI,CAAC,SAAS,GAAG,0BAA0B,GAAG,WAAW,IAAI,EAAE,CAAC,CAAC;AACjF,CAAC"} -------------------------------------------------------------------------------- /out/test/suite/renameProperty.test.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { 3 | function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } 4 | return new (P || (P = Promise))(function (resolve, reject) { 5 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } 6 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } 7 | function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } 8 | step((generator = generator.apply(thisArg, _arguments || [])).next()); 9 | }); 10 | }; 11 | Object.defineProperty(exports, "__esModule", { value: true }); 12 | const vscode = require("vscode"); 13 | const path = require("path"); 14 | const assert = require("assert"); 15 | const fs = require("fs"); 16 | const utils_1 = require("./utils"); 17 | const testFolderRelativeLocation = '/../fixtures/rename/'; 18 | suite('Rename Property', function () { 19 | setup(() => __awaiter(this, void 0, void 0, function* () { 20 | yield utils_1.resetDefaultSettings(); 21 | })); 22 | teardown(() => __awaiter(this, void 0, void 0, function* () { 23 | yield utils_1.resetDefaultSettings(); 24 | })); 25 | test('Should rename a property by name', () => __awaiter(this, void 0, void 0, function* () { 26 | yield runFixture('ConstructorWithMultipleProperties.php'); 27 | })); 28 | test('Should rename a single property', () => __awaiter(this, void 0, void 0, function* () { 29 | yield runFixture('ConstructorWithSingleProperty.php'); 30 | })); 31 | test('Should rename a property when the cursor is placed in its statement', () => __awaiter(this, void 0, void 0, function* () { 32 | yield runFixture('ConstructorWithMultiplePropertiesCursorInPropertyStatement.php', new vscode.Position(9, 13)); 33 | })); 34 | test('Should rename a property when the cursor is placed in its constructor argument', () => __awaiter(this, void 0, void 0, function* () { 35 | yield runFixture('ConstructorWithMultiplePropertiesCursorInArgument.php', new vscode.Position(13, 50)); 36 | })); 37 | test('Should rename a property when the cursor is placed in its assignment', () => __awaiter(this, void 0, void 0, function* () { 38 | yield runFixture('ConstructorWithMultiplePropertiesCursorInAssignment.php', new vscode.Position(16, 18)); 39 | })); 40 | test('Should rename a property when the cursor is placed in its constructor docblock param', () => __awaiter(this, void 0, void 0, function* () { 41 | yield runFixture('ConstructorWithMultiplePropertiesCursorInConstructorDocblock.php', new vscode.Position(14, 10)); 42 | })); 43 | test('Should rename all property references', () => __awaiter(this, void 0, void 0, function* () { 44 | yield runFixture('PropertyReferences.php'); 45 | })); 46 | test('Should rename only one property when there are more than one properties per statement', () => __awaiter(this, void 0, void 0, function* () { 47 | yield runFixture('MultiplePropertyStatements.php'); 48 | })); 49 | test('Should rename constructor param docblock', () => __awaiter(this, void 0, void 0, function* () { 50 | yield runFixture('ConstructorDocblock.php'); 51 | })); 52 | }); 53 | function runFixture(fileName, cursorPosition) { 54 | return __awaiter(this, void 0, void 0, function* () { 55 | const uri = vscode.Uri.file(getInputFilePath(fileName)); 56 | const document = yield vscode.workspace.openTextDocument(uri); 57 | yield vscode.window.showTextDocument(document); 58 | if (!vscode.window.activeTextEditor) { 59 | return; 60 | } 61 | if (cursorPosition === undefined) { 62 | let first = true; 63 | vscode.window.showInputBox = function (options, token) { 64 | if (first === true) { 65 | first = false; 66 | return Promise.resolve('name'); 67 | } 68 | return Promise.resolve('newName'); 69 | }; 70 | } 71 | else { 72 | vscode.window.activeTextEditor.selections = [new vscode.Selection(cursorPosition, cursorPosition)]; 73 | vscode.window.showInputBox = function (options, token) { 74 | return Promise.resolve('newName'); 75 | }; 76 | } 77 | yield vscode.commands.executeCommand('phpAddProperty.rename'); 78 | const expectedText = fs.readFileSync(getOutputFilePath(fileName)).toString(); 79 | yield utils_1.delay(utils_1.waitToAssertInSeconds, () => { 80 | var _a; 81 | assert.strictEqual((_a = vscode.window.activeTextEditor) === null || _a === void 0 ? void 0 : _a.document.getText(), expectedText); 82 | }); 83 | }); 84 | } 85 | function getInputFilePath(name) { 86 | return path.join(__dirname + testFolderRelativeLocation + `inputs/${name}`); 87 | } 88 | function getOutputFilePath(name) { 89 | return path.join(__dirname + testFolderRelativeLocation + `outputs/${name}`); 90 | } 91 | //# sourceMappingURL=renameProperty.test.js.map -------------------------------------------------------------------------------- /out/test/suite/renameProperty.test.js.map: -------------------------------------------------------------------------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,CAAC,SAAS,CAAC,CAAC;YACtC,CAAC,CAAC;SACL;aAAM;YACH,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,UAAU,GAAG,CAAC,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,EAAE,cAAc,CAAC,CAAC,CAAC;YAEnG,MAAM,CAAC,MAAM,CAAC,YAAY,GAAG,UACzB,OAA4C,EAC5C,KAA4C;gBAE5C,OAAO,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;YACtC,CAAC,CAAC;SACL;QAED,MAAM,MAAM,CAAC,QAAQ,CAAC,cAAc,CAAC,uBAAuB,CAAC,CAAC;QAE9D,MAAM,YAAY,GAAG,EAAE,CAAC,YAAY,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;QAE7E,MAAM,aAAK,CAAC,6BAAqB,EAAE,GAAG,EAAE;;YACpC,MAAM,CAAC,WAAW,OAAC,MAAM,CAAC,MAAM,CAAC,gBAAgB,0CAAE,QAAQ,CAAC,OAAO,IAAI,YAAY,CAAC,CAAC;QACzF,CAAC,CAAC,CAAC;IACP,CAAC;CAAA;AAED,SAAS,gBAAgB,CAAC,IAAY;IAClC,OAAO,IAAI,CAAC,IAAI,CAAC,SAAS,GAAG,0BAA0B,GAAG,UAAU,IAAI,EAAE,CAAC,CAAC;AAChF,CAAC;AAED,SAAS,iBAAiB,CAAC,IAAY;IACnC,OAAO,IAAI,CAAC,IAAI,CAAC,SAAS,GAAG,0BAA0B,GAAG,WAAW,IAAI,EAAE,CAAC,CAAC;AACjF,CAAC"} -------------------------------------------------------------------------------- /out/test/suite/utils.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { 3 | function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } 4 | return new (P || (P = Promise))(function (resolve, reject) { 5 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } 6 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } 7 | function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } 8 | step((generator = generator.apply(thisArg, _arguments || [])).next()); 9 | }); 10 | }; 11 | Object.defineProperty(exports, "__esModule", { value: true }); 12 | const vscode = require("vscode"); 13 | exports.waitToAssertInSeconds = 15; 14 | function delay(seconds, callback) { 15 | return new Promise(resolve => { 16 | setTimeout(() => { 17 | callback(); 18 | resolve(); 19 | }, seconds * exports.waitToAssertInSeconds); 20 | }); 21 | } 22 | exports.delay = delay; 23 | function resetDefaultSettings() { 24 | return __awaiter(this, void 0, void 0, function* () { 25 | const config = vscode.workspace.getConfiguration('phpAddProperty'); 26 | for (const key in config) { 27 | if (config.hasOwnProperty(key)) { 28 | yield setDefaultSetting(config, config[key], key); 29 | } 30 | } 31 | const constructorConfig = vscode.workspace.getConfiguration('phpAddProperty.constructor'); 32 | for (const setting in constructorConfig) { 33 | if (constructorConfig.hasOwnProperty(setting)) { 34 | yield setDefaultSetting(constructorConfig, constructorConfig[setting], setting); 35 | } 36 | } 37 | }); 38 | } 39 | exports.resetDefaultSettings = resetDefaultSettings; 40 | function setDefaultSetting(config, value, parentKey) { 41 | return __awaiter(this, void 0, void 0, function* () { 42 | if (typeof value === 'function') { 43 | return; 44 | } 45 | if (typeof value !== 'object') { 46 | yield config.update(parentKey, undefined, true); 47 | return; 48 | } 49 | for (const key in value) { 50 | if (value.hasOwnProperty(key)) { 51 | setDefaultSetting(config, value[key], [parentKey, key].join('.')); 52 | } 53 | } 54 | }); 55 | } 56 | //# sourceMappingURL=utils.js.map -------------------------------------------------------------------------------- /out/test/suite/utils.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/test/suite/utils.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,iCAAiC;AAEpB,QAAA,qBAAqB,GAAG,EAAE,CAAC;AAExC,SAAgB,KAAK,CAAC,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AAiB,CAAC,MAAM,EAAE,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;aACrE;SACJ;IACL,CAAC;CAAA"} -------------------------------------------------------------------------------- /out/utils.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;AAAA,iCAAiC;AAEjC,2CAA2C;AAE3C,SAAgB,mBAAmB,CAAC,YAAoB;IACpD,IAAI,iBAAiB,GAAG,CAAC,QAAQ,EAAE,WAAW,EAAE,SAAS,CAAC,CAAC;IAC3D,IAAI,iBAAiB,CAAC,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,EAAE;QAChD,iBAAiB,CAAC,MAAM,CAAC,iBAAiB,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC,CAAC;KACxE;IACD,OAAO,IAAI,CAAC,YAAY,EAAE,GAAG,iBAAiB,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;AACjE,CAAC;AAND,kDAMC;AAED,SAAS,uBAAuB,CAAC,IAAY;IACzC,MAAM,KAAK,GAAG,kDAAkD,CAAC;IACjE,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAE/B,OAAO,KAAK,CAAC;AACjB,CAAC;AAED,SAAS,2BAA2B,CAAC,IAAY,EAAE,kBAA0B,EAAE,cAAsB;IACjG,MAAM,UAAU,GAAG,cAAc,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;IAE/F,MAAM,wBAAwB,GAAG,kBAAkB;UAC7C,KAAK;UACL,GAAG,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI;UAC7B,UAAU,CAAC,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B;;IACnE,MAAM,UAAU,GAAG,KAAK,CAAC,GAAG,CAAC,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC;IAErD,MAAA,MAAM,CAAC,MAAM,CAAC,gBAAgB,0CAAE,IAAI,CAChC,WAAW,CAAC,EAAE;QACV,WAAW,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC;IACxD,CAAC,EACD;QACI,cAAc,EAAE,IAAI;QACpB,aAAa,EAAE,KAAK;KACvB,EACH,IAAI,CAAC,GAAG,EAAE;QACR,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC;QAE9C,IAAI,MAAM,EAAE;YACR,MAAM,CAAC,aAAa,CAChB,IAAI,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC,EACjC,KAAK,EACL;gBACI,cAAc,EAAE,KAAK;gBACrB,aAAa,EAAE,KAAK;aACvB,CACJ,CAAC;SACL;IACL,CAAC,EAAE;AACP,CAAC;AAzBD,gDAyBC;AAED,SAAgB,WAAW;IACvB,OAAO,OAAO,CAAC,GAAG,CAAC,wBAAY,CAAC,KAAK,MAAM,CAAC;AAChD,CAAC;AAFD,kCAEC"} -------------------------------------------------------------------------------- /src/addPropertyStatement.ts: -------------------------------------------------------------------------------- 1 | import * as vscode from 'vscode'; 2 | import Class from './class'; 3 | import Property from './property'; 4 | import { escapeForSnippet, indentText, calculateIndentationLevel, getLineFirstNonIndentationCharacterIndex } from './utils'; 5 | 6 | export default function addPropertyStatement(document: vscode.TextDocument, phpClass: Class, property: Property, tabStops: any): string { 7 | const phpClassRange = new vscode.Range( 8 | new vscode.Position(phpClass.ast.loc.start.line - 1, phpClass.ast.loc.start.column), 9 | new vscode.Position(phpClass.ast.loc.end.line - 1, phpClass.ast.loc.end.column) 10 | ); 11 | 12 | let newDocumentText = escapeForSnippet(document.getText(phpClassRange)); 13 | 14 | let lastProperty; 15 | let firstMethod; 16 | let lastNode; 17 | 18 | const astClassBody = phpClass.ast.body; 19 | for (let i = 0; i < astClassBody.length; i++) { 20 | const node = astClassBody[i]; 21 | 22 | lastNode = node; 23 | 24 | if (node.kind === 'propertystatement') { 25 | lastProperty = node; 26 | 27 | // Check that property does not already exist 28 | for (let j = 0; j < node.properties.length; j++) { 29 | const propertyNode = node.properties[j]; 30 | 31 | if (propertyNode.name?.name === property.getName()) { 32 | return newDocumentText; 33 | } 34 | } 35 | } else if (!firstMethod && node.kind === 'method' && node.name !== '__construct') { 36 | firstMethod = node; 37 | } 38 | } 39 | 40 | const propertyStatementText = property.getStatementText(tabStops); 41 | 42 | if (lastProperty) { 43 | const lastPropertyLine = document.lineAt(lastProperty.loc.start.line - 1); 44 | 45 | const newPropertyText = escapeForSnippet(`${lastPropertyLine.text}`) + "\n\n" + indentText( 46 | propertyStatementText, 47 | calculateIndentationLevel( 48 | getLineFirstNonIndentationCharacterIndex(lastPropertyLine.text) 49 | ) 50 | ); 51 | 52 | newDocumentText = newDocumentText.replace(escapeForSnippet(lastPropertyLine.text), newPropertyText); 53 | } else if (firstMethod) { 54 | const firstMethodLine = document.lineAt(firstMethod.loc.start.line - 1); 55 | 56 | const newPropertyText = indentText( 57 | propertyStatementText, 58 | calculateIndentationLevel( 59 | getLineFirstNonIndentationCharacterIndex(firstMethodLine.text) 60 | ) 61 | ) + "\n\n" + escapeForSnippet(firstMethodLine.text); 62 | 63 | newDocumentText = newDocumentText.replace(escapeForSnippet(firstMethodLine.text), newPropertyText); 64 | } else if (lastNode) { 65 | const lastNodeLine = document.lineAt(lastNode.loc.start.line - 1); 66 | 67 | const newPropertyText = escapeForSnippet(lastNodeLine.text) + "\n\n" + indentText( 68 | propertyStatementText, 69 | calculateIndentationLevel( 70 | getLineFirstNonIndentationCharacterIndex(lastNodeLine.text) 71 | ) 72 | ); 73 | 74 | newDocumentText = newDocumentText.replace(escapeForSnippet(lastNodeLine.text), newPropertyText); 75 | } else { 76 | const isOneLineClass = phpClass.ast.loc.start.line === phpClass.ast.loc.end.line; 77 | 78 | if (isOneLineClass) { 79 | const match = phpClass.ast.loc.source.match(/(.*)\}/); 80 | 81 | const newPropertyText = escapeForSnippet(match[1]) + "\n" + indentText( 82 | propertyStatementText, 83 | 1 84 | ) + "\n" + '}'; 85 | 86 | newDocumentText = newDocumentText.replace(escapeForSnippet(phpClass.ast.loc.source), newPropertyText); 87 | } else { 88 | const classBodyLine = document.lineAt(phpClass.ast.loc.start.line - 1); 89 | const classText = escapeForSnippet(phpClass.ast.loc.source); 90 | 91 | const newPropertyText = classText.replace(/{(?:\s|[\r\n]|\s)*}/, "{\n" + indentText( 92 | propertyStatementText, 93 | calculateIndentationLevel( 94 | getLineFirstNonIndentationCharacterIndex(classBodyLine.text) 95 | ) + 1 96 | )) + "\n}"; 97 | 98 | newDocumentText = newDocumentText.replace(classText, newPropertyText); 99 | } 100 | } 101 | 102 | return newDocumentText; 103 | } 104 | -------------------------------------------------------------------------------- /src/changePropertyType.ts: -------------------------------------------------------------------------------- 1 | import * as vscode from 'vscode'; 2 | import Property from './property'; 3 | import Class from './class'; 4 | import { config, escapeForRegExp } from './utils'; 5 | 6 | export function changePropertyType(editor: vscode.TextEditor, property: Property, newPropertyType: string, phpClass: Class) { 7 | const document = editor.document; 8 | const phpClassRange = new vscode.Range( 9 | new vscode.Position(phpClass.ast.loc.start.line - 1, phpClass.ast.loc.start.column), 10 | new vscode.Position(phpClass.ast.loc.end.line - 1, phpClass.ast.loc.end.column) 11 | ); 12 | 13 | let newDocumentText = document.getText(phpClassRange); 14 | 15 | const astClassBody = phpClass.ast.body; 16 | for (let i = 0; i < astClassBody.length; i++) { 17 | const node = astClassBody[i]; 18 | 19 | if (node.kind === 'propertystatement') { 20 | let newPropertyStatementText; 21 | 22 | for (let j = 0; j < node.properties.length; j++) { 23 | const propertyNode = node.properties[j]; 24 | 25 | if (propertyNode.name?.name == property.getName()) { 26 | const propertyStatementRange = new vscode.Range( 27 | new vscode.Position(node.loc.start.line - 1, 0), 28 | new vscode.Position(node.loc.end.line, 0) 29 | ); 30 | 31 | const propertyStatementText = document.getText(propertyStatementRange); 32 | 33 | let newPropertyText = `\$${property.getName()}`; 34 | 35 | if (config('phpAddProperty.property.types') === true || propertyNode.type) { 36 | newPropertyText = `${newPropertyType} ${newPropertyText}`; 37 | } 38 | 39 | newPropertyStatementText = propertyStatementText.replace( 40 | propertyNode.loc.source, 41 | newPropertyText 42 | ); 43 | 44 | newDocumentText = newDocumentText.replace(propertyStatementText, newPropertyStatementText); 45 | } 46 | } 47 | 48 | if (newPropertyStatementText) { 49 | for (let i = 0; i < node.leadingComments?.length; i++) { 50 | const commentNode = node.leadingComments[i]; 51 | 52 | const commentRange = new vscode.Range( 53 | new vscode.Position(commentNode.loc.start.line - 1, 0), 54 | new vscode.Position(commentNode.loc.end.line, 0) 55 | ); 56 | 57 | const commentText = document.getText(commentRange); 58 | 59 | const typeMatch = /@var\s(\S*)/g.exec(commentText); 60 | 61 | if (typeMatch) { 62 | const newCommentText = commentText.replace(typeMatch[1], newPropertyType); 63 | 64 | const regexp = new RegExp( 65 | `${escapeForRegExp(commentText)}((?:\s|[\r\n])*)${escapeForRegExp(newPropertyStatementText)}` 66 | ); 67 | newDocumentText = newDocumentText.replace( 68 | regexp, 69 | `${newCommentText}$1${newPropertyStatementText}` 70 | ); 71 | } 72 | } 73 | 74 | break; 75 | } 76 | } 77 | } 78 | 79 | const constructor = phpClass.getConstructor(); 80 | 81 | if (constructor) { 82 | for (let i = 0; i < constructor.ast.arguments.length; i++) { 83 | const node = constructor.ast.arguments[i]; 84 | 85 | if (node.name?.name == property.getName()) { 86 | const constructorText = constructor.ast.loc.source; 87 | const newConstructorText = constructorText.replace( 88 | node.loc.source, 89 | `${newPropertyType} \$${property.getName()}` 90 | ); 91 | newDocumentText = newDocumentText.replace(constructorText, newConstructorText); 92 | break; 93 | } 94 | } 95 | 96 | for (let i = 0; i < constructor.ast.leadingComments?.length; i++) { 97 | const commentNode = constructor.ast.leadingComments[i]; 98 | 99 | const commentRange = new vscode.Range( 100 | new vscode.Position(commentNode.loc.start.line - 1, 0), 101 | new vscode.Position(commentNode.loc.end.line, 0) 102 | ); 103 | 104 | const commentText = document.getText(commentRange); 105 | 106 | const regexp = new RegExp(`\\S*(\\s+\\$${property.getName()})`); 107 | const newCommentText = commentText.replace( 108 | regexp, 109 | `${newPropertyType}$1` 110 | ); 111 | 112 | newDocumentText = newDocumentText.replace(commentText, newCommentText); 113 | } 114 | } 115 | 116 | if (newDocumentText === document.getText(phpClassRange)) { 117 | return; 118 | } 119 | 120 | vscode.window.activeTextEditor?.edit( 121 | editBuilder => { 122 | editBuilder.replace(phpClassRange, newDocumentText); 123 | }, 124 | { 125 | undoStopBefore: true, 126 | undoStopAfter: false 127 | } 128 | ); 129 | } 130 | -------------------------------------------------------------------------------- /src/class.ts: -------------------------------------------------------------------------------- 1 | import Constructor from './constructor'; 2 | 3 | export default class Class { 4 | public ast: any; 5 | 6 | private construct?: Constructor; 7 | 8 | constructor(ast: any) { 9 | this.ast = ast; 10 | 11 | this.findConstructor(); 12 | } 13 | 14 | public getConstructor() { 15 | return this.construct; 16 | } 17 | 18 | private findConstructor() { 19 | for (let i = 0; i < this.ast.body.length; i++) { 20 | const node = this.ast.body[i]; 21 | 22 | if (node.kind === 'method' && node.name?.name === '__construct') { 23 | this.construct = new Constructor(node); 24 | } 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/constants.ts: -------------------------------------------------------------------------------- 1 | export const extensionId = 'php-add-property'; 2 | export const extensionQualifiedId = `kotfire.${extensionId}`; 3 | export const debugEnvName = 'PHP_ADD_PROPERTY_DEBUG_MODE'; 4 | 5 | export enum GlobalState { 6 | version = 'phpAddPropertyVersion' 7 | } -------------------------------------------------------------------------------- /src/constructor.ts: -------------------------------------------------------------------------------- 1 | export default class Constructor { 2 | public ast: any; 3 | 4 | constructor(ast: any) { 5 | this.ast = ast; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/locator.ts: -------------------------------------------------------------------------------- 1 | import Class from "./class"; 2 | import Constructor from "./constructor"; 3 | 4 | export default class Locator { 5 | private ast: any; 6 | 7 | constructor(ast: any) { 8 | this.ast = ast; 9 | } 10 | 11 | findClass(cursorAtLine?: number): Class | undefined { 12 | let firstClass: Class | undefined; 13 | const cursorClass = filter(this.ast, 'class', function (node: any) { 14 | if (!firstClass) { 15 | firstClass = new Class(node); 16 | } 17 | if (!cursorAtLine || (cursorAtLine >= node.loc.start.line && cursorAtLine <= node.loc.end.line)) { 18 | return new Class(node); 19 | } 20 | }); 21 | 22 | return cursorClass || firstClass; 23 | } 24 | 25 | findConstructor(): Constructor | undefined { 26 | return filter(this.ast, 'method', function (node: any) { 27 | if (node.name?.name === '__construct') { 28 | return new Constructor(node); 29 | } 30 | }); 31 | } 32 | } 33 | 34 | function filter(ast: any, kind: string, matcher: Function): any { 35 | let result; 36 | 37 | if (Array.isArray(ast)) { 38 | for (var i = 0; i < ast.length; i++) { 39 | result = filter(ast[i], kind, matcher); 40 | if (result) { 41 | return result; 42 | } 43 | } 44 | } else { 45 | if (ast?.kind === kind) { 46 | result = matcher(ast); 47 | 48 | if (result) { 49 | return result; 50 | } 51 | } 52 | 53 | for (const node in ast) { 54 | if (ast.hasOwnProperty(node) && ast[node] !== ast) { 55 | result = filter(ast[node], kind, matcher); 56 | if (result) { 57 | return result; 58 | } 59 | } 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/property.ts: -------------------------------------------------------------------------------- 1 | import { config, indentText, getVisibilityChoice } from "./utils"; 2 | 3 | export default class Property { 4 | private name: string; 5 | private nullable: Boolean; 6 | private type?: string; 7 | 8 | constructor(name: string, nullable: Boolean = false, type?: string) { 9 | this.name = name; 10 | this.nullable = nullable; 11 | this.type = type; 12 | } 13 | 14 | public getName() { 15 | return this.name; 16 | } 17 | 18 | public isNullable() { 19 | return this.nullable === true; 20 | } 21 | 22 | public getType() { 23 | return this.type; 24 | } 25 | 26 | public getStatementText(tabStops: any): string { 27 | let docblockTypeStop = tabStops.propertyDocblockType; 28 | let dockblockImportStop = tabStops.propertyDocblockImport; 29 | 30 | if (config('phpAddProperty.property.docblock.withParameter') === true) { 31 | docblockTypeStop = tabStops.constructorParameterType; 32 | dockblockImportStop = tabStops.constructorParameterStop; 33 | tabStops.constructorParameterStop++; 34 | } 35 | 36 | let propertyStatementText = ''; 37 | if (config('phpAddProperty.property.docblock.add') === true) { 38 | let stopText = ''; 39 | 40 | if (config('phpAddProperty.property.docblock.stopToImport') === true) { 41 | stopText += `$${dockblockImportStop}`; 42 | } 43 | 44 | stopText += `$${docblockTypeStop}`; 45 | 46 | if (config('phpAddProperty.property.docblock.multiline') === true) { 47 | propertyStatementText += `/**\n${indentText(' * @var ')}${stopText}\n${indentText(' */')}\n${indentText('')}`; 48 | } else { 49 | if (config('phpAddProperty.property.docblock.withParameter') === false) { 50 | stopText += ' '; 51 | } 52 | 53 | propertyStatementText += `/** @var ${stopText}*/\n${indentText('')}`; 54 | } 55 | } 56 | 57 | const visibility = (config('phpAddProperty.property.visibility.default') as string); 58 | propertyStatementText += config('phpAddProperty.property.visibility.choose') === true 59 | ? `\${${tabStops.propertyVisibility}${getVisibilityChoice(visibility)}} ` 60 | : `${visibility} `; 61 | 62 | if (config('phpAddProperty.property.types') === true) { 63 | propertyStatementText += `$${tabStops.constructorParameterType}`; 64 | } 65 | propertyStatementText += `\\$${this.getName()};`; 66 | 67 | return propertyStatementText; 68 | } 69 | 70 | public getParameterText(tabStops: any): string { 71 | let tabStopsText = `$${tabStops.constructorParameterType}`; 72 | 73 | if (this.getType()) { 74 | let typeText = this.getType(); 75 | 76 | if (this.isNullable()) { 77 | typeText = `?${typeText}`; 78 | } 79 | 80 | tabStopsText = `\${${tabStops.constructorParameterType}:${typeText}}`; 81 | } 82 | 83 | if (config('phpAddProperty.property.stopToImport') === true) { 84 | tabStopsText += `$${tabStops.constructorParameterStop}`; 85 | } 86 | 87 | let parameterText = `${tabStopsText}`; 88 | 89 | if (this.getType()) { 90 | parameterText += ' '; 91 | } 92 | 93 | parameterText += `\\$${this.getName()}`; 94 | 95 | return parameterText; 96 | } 97 | 98 | public getConstructorParamDocblockText(tabStops: any): string { 99 | let docblockTypeStop = tabStops.constructorDocblockType; 100 | let dockblockImportStop = tabStops.constructorDocblockImport; 101 | 102 | if (config('phpAddProperty.constructor.docblock.withParameter') === true) { 103 | docblockTypeStop = tabStops.constructorParameterType; 104 | dockblockImportStop = tabStops.constructorParameterStop; 105 | tabStops.constructorParameterStop++; 106 | } 107 | 108 | let constructorParamDocblockText = `\${${docblockTypeStop}}`; 109 | 110 | if (this.getType()) { 111 | let typeText = this.getType(); 112 | 113 | if (this.isNullable()) { 114 | typeText = `${typeText}|null`; 115 | } 116 | 117 | constructorParamDocblockText = `\${${docblockTypeStop}:${typeText}} `; 118 | } 119 | 120 | if (config('phpAddProperty.constructor.docblock.stopToImport') === true) { 121 | constructorParamDocblockText += `\$${dockblockImportStop}`; 122 | } 123 | 124 | constructorParamDocblockText += `\\$${this.getName()}`; 125 | 126 | if (config('phpAddProperty.constructor.docblock.stopForDescription') === true) { 127 | constructorParamDocblockText += `\$${tabStops.constructorDocblockDescription}`; 128 | } 129 | 130 | return ` * @param ${constructorParamDocblockText}`; 131 | } 132 | } 133 | -------------------------------------------------------------------------------- /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 | const testUserDir = path.resolve(__dirname, './user'); 16 | 17 | const vscodeCompatibilityString = require('../../package.json').engines.vscode; 18 | const vscodeMinimumVersion = vscodeCompatibilityString.replace(/[^\d\.]/g, ''); 19 | 20 | await runTests( 21 | { 22 | version: vscodeMinimumVersion, 23 | extensionDevelopmentPath, 24 | extensionTestsPath, 25 | launchArgs: [ 26 | `--user-data-dir=${testUserDir}`, 27 | '--disable-extensions' 28 | ], 29 | extensionTestsEnv: { 30 | 'VSCODE_VERSION': vscodeMinimumVersion, 31 | } 32 | } 33 | ); 34 | 35 | await runTests( 36 | { 37 | extensionDevelopmentPath, 38 | extensionTestsPath, 39 | launchArgs: [ 40 | `--user-data-dir=${testUserDir}`, 41 | '--disable-extensions' 42 | ] 43 | } 44 | ); 45 | } catch (err) { 46 | console.error('Failed to run tests'); 47 | process.exit(1); 48 | } 49 | } 50 | 51 | main(); 52 | -------------------------------------------------------------------------------- /src/test/suite/addExistingProperty.test.ts: -------------------------------------------------------------------------------- 1 | import * as vscode from 'vscode'; 2 | import * as path from 'path'; 3 | import * as assert from 'assert'; 4 | import * as fs from 'fs'; 5 | import { waitToAssertInSeconds, delay, resetDefaultSettings } from './utils'; 6 | 7 | const testFolderRelativeLocation = '/../fixtures/existing/'; 8 | 9 | suite('Add Existing Property', function () { 10 | setup(async () => { 11 | await resetDefaultSettings(); 12 | }); 13 | 14 | teardown(async () => { 15 | await resetDefaultSettings(); 16 | }); 17 | 18 | test('Should add an existing property and constructor in an empty class', async () => { 19 | await runFixture('EmptyClass.php', new vscode.Position(7, 0)); 20 | }); 21 | 22 | test('Should add an existing property to an empty constructor', async () => { 23 | await runFixture('EmptyConstructor.php', new vscode.Position(7, 0)); 24 | }); 25 | 26 | test('Should add an existing property to an existing constructor', async () => { 27 | await runFixture('ExistingConstructor.php', new vscode.Position(9, 0)); 28 | }); 29 | 30 | test('Should add an existing property using type from docblock', async () => { 31 | await runFixture('UseDocblock.php', new vscode.Position(8, 0)); 32 | }); 33 | 34 | test('Should add an existing property using its PHP7.4+ type', async () => { 35 | await runFixture('UseType.php', new vscode.Position(8, 0)); 36 | }); 37 | 38 | test('Should add a docblock with @param using type from property docblock', async () => { 39 | await vscode.workspace.getConfiguration('phpAddProperty').update('constructor.docblock.enable', true, true); 40 | await runFixture('ConstructorDocblockUsingDocblock.php', new vscode.Position(8, 0)); 41 | }); 42 | 43 | test('Should NOT add an extra space when adding property type and docblock type at the same type', async () => { 44 | await vscode.workspace.getConfiguration('phpAddProperty').update('constructor.docblock.enable', true, true); 45 | await vscode.workspace.getConfiguration('phpAddProperty').update('constructor.docblock.withParameter', true, true); 46 | await runFixture('DocblockTypeWithParameter.php', new vscode.Position(10, 22)); 47 | }); 48 | 49 | test('Should add an existing property with a nullable type', async() => { 50 | await vscode.workspace.getConfiguration('phpAddProperty').update('constructor.docblock.enable', true, true); 51 | await runFixture('NullableType.php', new vscode.Position(10, 0)); 52 | }); 53 | 54 | test('Should add a nullable property using type from property docblock', async() => { 55 | await runFixture('UseNullableDocblock.php', new vscode.Position(8, 0)); 56 | }); 57 | }); 58 | 59 | async function runFixture(fileName: string, cursorPosition: vscode.Position) { 60 | const uri = vscode.Uri.file( 61 | getInputFilePath(fileName) 62 | ); 63 | const document = await vscode.workspace.openTextDocument(uri); 64 | await vscode.window.showTextDocument(document); 65 | 66 | if (!vscode.window.activeTextEditor) { 67 | return; 68 | } 69 | 70 | vscode.window.activeTextEditor.selections = [new vscode.Selection(cursorPosition, cursorPosition)]; 71 | 72 | await vscode.commands.executeCommand('phpAddProperty.append'); 73 | 74 | const expectedText = fs.readFileSync(getOutputFilePath(fileName)).toString(); 75 | 76 | await delay(waitToAssertInSeconds, () => { 77 | assert.strictEqual(vscode.window.activeTextEditor?.document.getText(), expectedText); 78 | }); 79 | } 80 | 81 | function getInputFilePath(name: string) { 82 | return path.join(__dirname + testFolderRelativeLocation + `inputs/${name}`); 83 | } 84 | 85 | function getOutputFilePath(name: string) { 86 | return path.join(__dirname + testFolderRelativeLocation + `outputs/${name}`); 87 | } 88 | -------------------------------------------------------------------------------- /src/test/suite/addProperty.test.ts: -------------------------------------------------------------------------------- 1 | import * as vscode from 'vscode'; 2 | import * as path from 'path'; 3 | import * as assert from 'assert'; 4 | import * as fs from 'fs'; 5 | import { waitToAssertInSeconds, delay, resetDefaultSettings } from './utils'; 6 | 7 | const testFolderRelativeLocation = '/../fixtures/new/'; 8 | 9 | suite('Add Property', function () { 10 | setup(async () => { 11 | await resetDefaultSettings(); 12 | }); 13 | 14 | teardown(async () => { 15 | await resetDefaultSettings(); 16 | }); 17 | 18 | test('Should insert property and constructor in an empty class', async () => { 19 | await runFixture('EmptyClass.php'); 20 | }); 21 | 22 | test('Should insert a new property and add it to an empty constructor', async () => { 23 | await runFixture('EmptyConstructor.php'); 24 | }); 25 | 26 | test('Should insert a new property and add it to an existing constructor', async () => { 27 | await runFixture('ExistingConstructor.php'); 28 | }); 29 | 30 | test('Should insert a new property in a multiline constructor', async () => { 31 | await runFixture('MultilineConstructor.php'); 32 | }); 33 | 34 | test('Should add a property to the constructor even if the property already exists', async () => { 35 | await runFixture('ExistingProperty.php'); 36 | }); 37 | 38 | test('Should NOT add a property to the constructor if it is already there', async () => { 39 | await runFixture('ExistingPropertyInConstructor.php'); 40 | }); 41 | 42 | test('Should NOT add the property assignation if it is already there', async () => { 43 | await runFixture('ExistingPropertyAssignation.php'); 44 | }); 45 | 46 | test('Should work with tab indentation', async () => { 47 | await runFixture('TabIndentation.php'); 48 | }); 49 | 50 | test('Should work when the class contains extra "class" keywords', async () => { 51 | await runFixture('ClassKeyword.php'); 52 | }); 53 | 54 | test('Should insert property in the first class if the file contains multiple', async () => { 55 | await runFixture('MultipleClasses.php'); 56 | }); 57 | 58 | test('Should insert property in the first class if the cursor is placed there', async () => { 59 | await runFixture('MultipleClassesCursorInFirst.php', new vscode.Position(8, 0)); 60 | }); 61 | 62 | test('Should insert property in the last class if the cursor is placed there', async () => { 63 | await runFixture('MultipleClassesCursorInLast.php', new vscode.Position(13, 0)); 64 | }); 65 | 66 | test('Should add a docblock with @param along with the constructor', async () => { 67 | await vscode.workspace.getConfiguration('phpAddProperty').update('constructor.docblock.enable', true, true); 68 | await runFixture('AddConstructorDocblock.php'); 69 | }); 70 | 71 | test('Should update the docblock adding the new @param', async () => { 72 | await vscode.workspace.getConfiguration('phpAddProperty').update('constructor.docblock.enable', true, true); 73 | await runFixture('UpdateConstructorDocblock.php'); 74 | }); 75 | }); 76 | 77 | async function runFixture(fileName: string, cursorPosition?: vscode.Position) { 78 | const uri = vscode.Uri.file( 79 | getInputFilePath(fileName) 80 | ); 81 | const document = await vscode.workspace.openTextDocument(uri); 82 | await vscode.window.showTextDocument(document); 83 | 84 | if (!vscode.window.activeTextEditor) { 85 | return; 86 | } 87 | 88 | if (cursorPosition === undefined) { 89 | vscode.window.showInputBox = function ( 90 | options?: vscode.InputBoxOptions | undefined, 91 | token?: vscode.CancellationToken | undefined 92 | ): Thenable { 93 | return Promise.resolve('name'); 94 | }; 95 | } else { 96 | vscode.window.activeTextEditor.selections = [new vscode.Selection(cursorPosition, cursorPosition)]; 97 | } 98 | 99 | await vscode.commands.executeCommand('phpAddProperty.add'); 100 | 101 | const expectedText = fs.readFileSync(getOutputFilePath(fileName)).toString(); 102 | 103 | await delay(waitToAssertInSeconds, () => { 104 | assert.strictEqual(vscode.window.activeTextEditor?.document.getText(), expectedText); 105 | }); 106 | } 107 | 108 | function getInputFilePath(name: string) { 109 | return path.join(__dirname + testFolderRelativeLocation + `inputs/${name}`); 110 | } 111 | 112 | function getOutputFilePath(name: string) { 113 | return path.join(__dirname + testFolderRelativeLocation + `outputs/${name}`); 114 | } 115 | -------------------------------------------------------------------------------- /src/test/suite/breakConstructorIntoMultiline.test.ts: -------------------------------------------------------------------------------- 1 | import * as vscode from 'vscode'; 2 | import * as path from 'path'; 3 | import * as assert from 'assert'; 4 | import * as fs from 'fs'; 5 | import { waitToAssertInSeconds, delay, resetDefaultSettings } from './utils'; 6 | 7 | const testFolderRelativeLocation = '/../fixtures/breakConstructorIntoMultiline/'; 8 | 9 | suite('Break Constructor Into Multilines', function () { 10 | setup(async () => { 11 | await resetDefaultSettings(); 12 | }); 13 | 14 | teardown(async () => { 15 | await resetDefaultSettings(); 16 | }); 17 | 18 | test('Should break the constructor into multiline regardless of the settings', async () => { 19 | await vscode.workspace.getConfiguration('phpAddProperty').update('constructor.breakIntoMultilineIfLengthExceeded.enabled', false, true); 20 | await vscode.workspace.getConfiguration('phpAddProperty').update('constructor.breakIntoMultilineIfLengthExceeded.maxLineLength', 999, true); 21 | await runFixture('Constructor.php'); 22 | }); 23 | }); 24 | 25 | async function runFixture(fileName: string) { 26 | const uri = vscode.Uri.file( 27 | getInputFilePath(fileName) 28 | ); 29 | const document = await vscode.workspace.openTextDocument(uri); 30 | await vscode.window.showTextDocument(document); 31 | 32 | await vscode.commands.executeCommand('phpAddProperty.breakConstructorIntoMultiline'); 33 | 34 | const expectedText = fs.readFileSync(getOutputFilePath(fileName)).toString(); 35 | 36 | await delay(waitToAssertInSeconds, () => { 37 | assert.strictEqual(vscode.window.activeTextEditor?.document.getText(), expectedText); 38 | }); 39 | } 40 | 41 | function getInputFilePath(name: string) { 42 | return path.join(__dirname + testFolderRelativeLocation + `inputs/${name}`); 43 | } 44 | 45 | function getOutputFilePath(name: string) { 46 | return path.join(__dirname + testFolderRelativeLocation + `outputs/${name}`); 47 | } 48 | 49 | -------------------------------------------------------------------------------- /src/test/suite/changePropertyType.test.ts: -------------------------------------------------------------------------------- 1 | import * as vscode from 'vscode'; 2 | import * as path from 'path'; 3 | import * as assert from 'assert'; 4 | import * as fs from 'fs'; 5 | import { waitToAssertInSeconds, delay, resetDefaultSettings } from './utils'; 6 | 7 | const testFolderRelativeLocation = '/../fixtures/changePropertyType/'; 8 | 9 | suite('Change Property Type', function () { 10 | setup(async () => { 11 | await resetDefaultSettings(); 12 | }); 13 | 14 | teardown(async () => { 15 | await resetDefaultSettings(); 16 | }); 17 | 18 | test('Should change a property type by name', async () => { 19 | await runFixture('ConstructorWithMultipleProperties.php'); 20 | }); 21 | 22 | test('Should change the property statement type if already exists', async () => { 23 | await runFixture('TypedPropertyStatement.php'); 24 | }); 25 | 26 | test('Should change the property statement type if typed properties is enabled', async () => { 27 | await vscode.workspace.getConfiguration('phpAddProperty').update('property.types', true, true); 28 | await runFixture('PropertyWithoutType.php'); 29 | }); 30 | 31 | test('Should change property statement docblock type', async () => { 32 | await runFixture('PropertyStatementDocblock.php'); 33 | }); 34 | 35 | test('Should NOT change other properties statement docblock type', async () => { 36 | await runFixture('OtherPropertiesStatementDocblock.php'); 37 | }); 38 | 39 | test('Should change property type in constructor docblock', async () => { 40 | await runFixture('ConstructorDocblock.php'); 41 | }); 42 | 43 | test('Should rename a property when the cursor is placed in its constructor docblock param', async () => { 44 | await runFixture('ConstructorWithMultiplePropertiesCursorInConstructorDocblock.php', new vscode.Position(15, 17)); 45 | }); 46 | }); 47 | 48 | async function runFixture(fileName: string, cursorPosition?: vscode.Position) { 49 | const uri = vscode.Uri.file( 50 | getInputFilePath(fileName) 51 | ); 52 | const document = await vscode.workspace.openTextDocument(uri); 53 | await vscode.window.showTextDocument(document); 54 | 55 | if (!vscode.window.activeTextEditor) { 56 | return; 57 | } 58 | 59 | if (cursorPosition === undefined) { 60 | let first = true; 61 | vscode.window.showInputBox = function ( 62 | options?: vscode.InputBoxOptions | undefined, 63 | token?: vscode.CancellationToken | undefined 64 | ): Thenable { 65 | if (first === true) { 66 | first = false; 67 | 68 | return Promise.resolve('name'); 69 | } 70 | 71 | return Promise.resolve('Name'); 72 | }; 73 | } else { 74 | vscode.window.activeTextEditor.selections = [new vscode.Selection(cursorPosition, cursorPosition)]; 75 | 76 | vscode.window.showInputBox = function ( 77 | options?: vscode.InputBoxOptions | undefined, 78 | token?: vscode.CancellationToken | undefined 79 | ): Thenable { 80 | return Promise.resolve('Name'); 81 | }; 82 | } 83 | 84 | await vscode.commands.executeCommand('phpAddProperty.changeType'); 85 | 86 | const expectedText = fs.readFileSync(getOutputFilePath(fileName)).toString(); 87 | 88 | await delay(waitToAssertInSeconds, () => { 89 | assert.strictEqual(vscode.window.activeTextEditor?.document.getText(), expectedText); 90 | }); 91 | } 92 | 93 | function getInputFilePath(name: string) { 94 | return path.join(__dirname + testFolderRelativeLocation + `inputs/${name}`); 95 | } 96 | 97 | function getOutputFilePath(name: string) { 98 | return path.join(__dirname + testFolderRelativeLocation + `outputs/${name}`); 99 | } 100 | -------------------------------------------------------------------------------- /src/test/suite/customizations.test.ts: -------------------------------------------------------------------------------- 1 | import * as vscode from 'vscode'; 2 | import * as path from 'path'; 3 | import * as assert from 'assert'; 4 | import * as fs from 'fs'; 5 | import { waitToAssertInSeconds, delay, resetDefaultSettings } from './utils'; 6 | 7 | const testFolderRelativeLocation = '/../fixtures/customizations/'; 8 | 9 | suite('Customizations', function () { 10 | setup(async () => { 11 | await resetDefaultSettings(); 12 | }); 13 | 14 | teardown(async () => { 15 | await resetDefaultSettings(); 16 | }); 17 | 18 | test('Should use the specified property default visibility', async () => { 19 | await vscode.workspace.getConfiguration('phpAddProperty').update('property.visibility.default', 'public', true); 20 | await runFixture('PropertyDefaultVisibility.php'); 21 | }); 22 | 23 | test('Should add the docblock', async () => { 24 | await vscode.workspace.getConfiguration('phpAddProperty').update('property.docblock.add', true, true); 25 | await runFixture('PropertyAddDocblock.php'); 26 | }); 27 | 28 | test('Should add a multiline docblock', async () => { 29 | await vscode.workspace.getConfiguration('phpAddProperty').update('property.docblock.add', true, true); 30 | await vscode.workspace.getConfiguration('phpAddProperty').update('property.docblock.multiline', true, true); 31 | await runFixture('PropertyMultilineDocblock.php'); 32 | }); 33 | 34 | test('Should use the specified constructor default visibility', async () => { 35 | await vscode.workspace.getConfiguration('phpAddProperty').update('constructor.visibility.default', 'private', true); 36 | await runFixture('ConstructorDefaultVisibility.php'); 37 | }); 38 | 39 | test('Should break constructor into multiple lines', async () => { 40 | await vscode.workspace.getConfiguration('phpAddProperty').update('constructor.breakIntoMultilineIfLengthExceeded.enabled', true, true); 41 | await runFixture('ConstructorBreakIntoMultiline.php'); 42 | }); 43 | 44 | test('Should break constructor into multiple lines at a specified length', async () => { 45 | await vscode.workspace.getConfiguration('phpAddProperty').update('constructor.breakIntoMultilineIfLengthExceeded.enabled', true, true); 46 | await vscode.workspace.getConfiguration('phpAddProperty').update('constructor.breakIntoMultilineIfLengthExceeded.maxLineLength', 40, true); 47 | await runFixture('ConstructorBreakIntoMultilineLength.php'); 48 | }); 49 | }); 50 | 51 | async function runFixture(fileName: string) { 52 | vscode.window.showInputBox = function ( 53 | options?: vscode.InputBoxOptions | undefined, 54 | token?: vscode.CancellationToken | undefined 55 | ): Thenable { 56 | return Promise.resolve('name'); 57 | }; 58 | 59 | const uri = vscode.Uri.file( 60 | getInputFilePath(fileName) 61 | ); 62 | const document = await vscode.workspace.openTextDocument(uri); 63 | await vscode.window.showTextDocument(document); 64 | 65 | await vscode.commands.executeCommand('phpAddProperty.add'); 66 | 67 | const expectedText = fs.readFileSync(getOutputFilePath(fileName)).toString(); 68 | 69 | await delay(waitToAssertInSeconds, () => { 70 | assert.strictEqual(vscode.window.activeTextEditor?.document.getText(), expectedText); 71 | }); 72 | } 73 | 74 | function getInputFilePath(name: string) { 75 | return path.join(__dirname + testFolderRelativeLocation + `inputs/${name}`); 76 | } 77 | 78 | function getOutputFilePath(name: string) { 79 | return path.join(__dirname + testFolderRelativeLocation + `outputs/${name}`); 80 | } 81 | 82 | -------------------------------------------------------------------------------- /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 (process.env.VSCODE_VERSION === '1.31.0') { 27 | process.exit(failures > 0 ? 1 : 0); 28 | } 29 | 30 | if (failures > 0) { 31 | e(new Error(`${failures} tests failed.`)); 32 | } else { 33 | c(); 34 | } 35 | }); 36 | } catch (err) { 37 | console.error(err); 38 | e(err); 39 | } 40 | }); 41 | }); 42 | } 43 | -------------------------------------------------------------------------------- /src/test/suite/removeProperty.test.ts: -------------------------------------------------------------------------------- 1 | import * as vscode from 'vscode'; 2 | import * as path from 'path'; 3 | import * as assert from 'assert'; 4 | import * as fs from 'fs'; 5 | import { waitToAssertInSeconds, delay, resetDefaultSettings } from './utils'; 6 | 7 | const testFolderRelativeLocation = '/../fixtures/remove/'; 8 | 9 | suite('Remove Property', function () { 10 | setup(async () => { 11 | await resetDefaultSettings(); 12 | }); 13 | 14 | teardown(async () => { 15 | await resetDefaultSettings(); 16 | }); 17 | 18 | test('Should remove an existing property by name', async () => { 19 | await runFixture('ConstructorWithMultipleProperties.php'); 20 | }); 21 | 22 | test('Should remove the constructor method when the body is empty', async () => { 23 | await runFixture('EmptyConstructor.php'); 24 | }); 25 | 26 | test('Should remove the constructor method when the body is empty after removing the last property', async () => { 27 | await runFixture('ConstructorWithSingleProperty.php'); 28 | }); 29 | 30 | test('Should NOT remove the constructor method when the body is NOT empty after removing the last property', async () => { 31 | await runFixture('ConstructorWithOneProperty.php'); 32 | }); 33 | 34 | test('Should NOT remove the constructor argument when the property name does not match', async () => { 35 | await runFixture('ConstructorWithOtherArgument.php'); 36 | }); 37 | 38 | test('Should remove the constructor docblock along with the constructor', async () => { 39 | await runFixture('ConstructorWithSinglePropertyAndDocblock.php'); 40 | }); 41 | 42 | test('Should remove typed properties', async () => { 43 | await runFixture('TypedProperty.php'); 44 | }); 45 | 46 | test('Should remove the property docblock', async () => { 47 | await runFixture('PropertyWithDocblock.php'); 48 | }); 49 | 50 | test('Should remove the property from the constructor docblock', async () => { 51 | await runFixture('ConstructorDocblock.php'); 52 | }); 53 | 54 | test('Should remove a property when the cursor is placed in its statement', async () => { 55 | await runFixture('ConstructorWithMultiplePropertiesCursorInPropertyStatement.php', new vscode.Position(11, 13)); 56 | }); 57 | 58 | test('Should remove a property when the cursor is placed in its constructor argument', async () => { 59 | await runFixture('ConstructorWithMultiplePropertiesCursorInArgument.php', new vscode.Position(13, 35)); 60 | }); 61 | 62 | test('Should remove a property when the cursor is placed in its assignment', async () => { 63 | await runFixture('ConstructorWithMultiplePropertiesCursorInAssignment.php', new vscode.Position(15, 18)); 64 | }); 65 | 66 | test('Should remove a property when the cursor is placed in its constructor docblock', async () => { 67 | await runFixture('ConstructorWithMultiplePropertiesCursorInConstructorDocblock.php', new vscode.Position(16, 24)); 68 | }); 69 | }); 70 | 71 | async function runFixture(fileName: string, cursorPosition?: vscode.Position) { 72 | const uri = vscode.Uri.file( 73 | getInputFilePath(fileName) 74 | ); 75 | const document = await vscode.workspace.openTextDocument(uri); 76 | await vscode.window.showTextDocument(document); 77 | 78 | if (!vscode.window.activeTextEditor) { 79 | return; 80 | } 81 | 82 | if (cursorPosition === undefined) { 83 | vscode.window.showInputBox = function ( 84 | options?: vscode.InputBoxOptions | undefined, 85 | token?: vscode.CancellationToken | undefined 86 | ): Thenable { 87 | return Promise.resolve('name'); 88 | }; 89 | } else { 90 | vscode.window.activeTextEditor.selections = [new vscode.Selection(cursorPosition, cursorPosition)]; 91 | } 92 | 93 | await vscode.commands.executeCommand('phpAddProperty.remove'); 94 | 95 | const expectedText = fs.readFileSync(getOutputFilePath(fileName)).toString(); 96 | 97 | await delay(waitToAssertInSeconds, () => { 98 | assert.strictEqual(vscode.window.activeTextEditor?.document.getText(), expectedText); 99 | }); 100 | } 101 | 102 | function getInputFilePath(name: string) { 103 | return path.join(__dirname + testFolderRelativeLocation + `inputs/${name}`); 104 | } 105 | 106 | function getOutputFilePath(name: string) { 107 | return path.join(__dirname + testFolderRelativeLocation + `outputs/${name}`); 108 | } 109 | -------------------------------------------------------------------------------- /src/test/suite/renameProperty.test.ts: -------------------------------------------------------------------------------- 1 | import * as vscode from 'vscode'; 2 | import * as path from 'path'; 3 | import * as assert from 'assert'; 4 | import * as fs from 'fs'; 5 | import { waitToAssertInSeconds, delay, resetDefaultSettings } from './utils'; 6 | 7 | const testFolderRelativeLocation = '/../fixtures/rename/'; 8 | 9 | suite('Rename Property', function () { 10 | setup(async () => { 11 | await resetDefaultSettings(); 12 | }); 13 | 14 | teardown(async () => { 15 | await resetDefaultSettings(); 16 | }); 17 | 18 | test('Should rename a property by name', async () => { 19 | await runFixture('ConstructorWithMultipleProperties.php'); 20 | }); 21 | 22 | test('Should rename a single property', async () => { 23 | await runFixture('ConstructorWithSingleProperty.php'); 24 | }); 25 | 26 | test('Should rename a property when the cursor is placed in its statement', async () => { 27 | await runFixture('ConstructorWithMultiplePropertiesCursorInPropertyStatement.php', new vscode.Position(9, 13)); 28 | }); 29 | 30 | test('Should rename a property when the cursor is placed in its constructor argument', async () => { 31 | await runFixture('ConstructorWithMultiplePropertiesCursorInArgument.php', new vscode.Position(13, 50)); 32 | }); 33 | 34 | test('Should rename a property when the cursor is placed in its assignment', async () => { 35 | await runFixture('ConstructorWithMultiplePropertiesCursorInAssignment.php', new vscode.Position(16, 18)); 36 | }); 37 | 38 | test('Should rename a property when the cursor is placed in its constructor docblock param', async () => { 39 | await runFixture('ConstructorWithMultiplePropertiesCursorInConstructorDocblock.php', new vscode.Position(14, 10)); 40 | }); 41 | 42 | test('Should rename all property references', async () => { 43 | await runFixture('PropertyReferences.php'); 44 | }); 45 | 46 | test('Should rename only one property when there are more than one properties per statement', async () => { 47 | await runFixture('MultiplePropertyStatements.php'); 48 | }); 49 | 50 | test('Should rename constructor param docblock', async () => { 51 | await runFixture('ConstructorDocblock.php'); 52 | }); 53 | }); 54 | 55 | async function runFixture(fileName: string, cursorPosition?: vscode.Position) { 56 | const uri = vscode.Uri.file( 57 | getInputFilePath(fileName) 58 | ); 59 | const document = await vscode.workspace.openTextDocument(uri); 60 | await vscode.window.showTextDocument(document); 61 | 62 | if (!vscode.window.activeTextEditor) { 63 | return; 64 | } 65 | 66 | if (cursorPosition === undefined) { 67 | let first = true; 68 | vscode.window.showInputBox = function ( 69 | options?: vscode.InputBoxOptions | undefined, 70 | token?: vscode.CancellationToken | undefined 71 | ): Thenable { 72 | if (first === true) { 73 | first = false; 74 | 75 | return Promise.resolve('name'); 76 | } 77 | 78 | return Promise.resolve('newName'); 79 | }; 80 | } else { 81 | vscode.window.activeTextEditor.selections = [new vscode.Selection(cursorPosition, cursorPosition)]; 82 | 83 | vscode.window.showInputBox = function ( 84 | options?: vscode.InputBoxOptions | undefined, 85 | token?: vscode.CancellationToken | undefined 86 | ): Thenable { 87 | return Promise.resolve('newName'); 88 | }; 89 | } 90 | 91 | await vscode.commands.executeCommand('phpAddProperty.rename'); 92 | 93 | const expectedText = fs.readFileSync(getOutputFilePath(fileName)).toString(); 94 | 95 | await delay(waitToAssertInSeconds, () => { 96 | assert.strictEqual(vscode.window.activeTextEditor?.document.getText(), expectedText); 97 | }); 98 | } 99 | 100 | function getInputFilePath(name: string) { 101 | return path.join(__dirname + testFolderRelativeLocation + `inputs/${name}`); 102 | } 103 | 104 | function getOutputFilePath(name: string) { 105 | return path.join(__dirname + testFolderRelativeLocation + `outputs/${name}`); 106 | } 107 | -------------------------------------------------------------------------------- /src/test/suite/utils.ts: -------------------------------------------------------------------------------- 1 | import * as vscode from 'vscode'; 2 | 3 | export const waitToAssertInSeconds = 15; 4 | 5 | export function delay(seconds: number, callback: Function) { 6 | return new Promise(resolve => { 7 | setTimeout(() => { 8 | callback(); 9 | resolve(); 10 | }, seconds * waitToAssertInSeconds); 11 | }); 12 | } 13 | 14 | export async function resetDefaultSettings() { 15 | const config = vscode.workspace.getConfiguration('phpAddProperty'); 16 | 17 | for (const key in config) { 18 | if (config.hasOwnProperty(key)) { 19 | await setDefaultSetting(config, config[key], key); 20 | } 21 | } 22 | 23 | const constructorConfig = vscode.workspace.getConfiguration('phpAddProperty.constructor'); 24 | for (const setting in constructorConfig) { 25 | if (constructorConfig.hasOwnProperty(setting)) { 26 | await setDefaultSetting(constructorConfig, constructorConfig[setting], setting); 27 | } 28 | } 29 | } 30 | 31 | async function setDefaultSetting(config: vscode.WorkspaceConfiguration, value: any, parentKey: string) { 32 | if (typeof value === 'function') { 33 | return; 34 | } 35 | 36 | if (typeof value !== 'object') { 37 | await config.update(parentKey, undefined, true); 38 | return; 39 | } 40 | 41 | for (const key in value) { 42 | if (value.hasOwnProperty(key)) { 43 | setDefaultSetting(config, value[key], [parentKey, key].join('.')); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /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 /* enable all strict type-checking options */ 12 | /* Additional Checks */ 13 | // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ 14 | // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ 15 | // "noUnusedParameters": true, /* Report errors on unused parameters. */ 16 | }, 17 | "exclude": [ 18 | "node_modules", 19 | ".vscode-test" 20 | ] 21 | } 22 | -------------------------------------------------------------------------------- /webviews/1.0.1/i/code.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kotfire/vscode-php-add-property/7eef6578ea265db9188ff3494efaa3f4d39d62ca/webviews/1.0.1/i/code.jpg -------------------------------------------------------------------------------- /webviews/1.0.1/i/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kotfire/vscode-php-add-property/7eef6578ea265db9188ff3494efaa3f4d39d62ca/webviews/1.0.1/i/icon.png --------------------------------------------------------------------------------