Class Helper supports:
What does Class Helper do?
- Add a class if the cursor is out of the scope of another class.
- Add a constructor if the cursor is in scope of a class and there is no constructor.
- Add properties if the cursor is in scope of a class and if the class has a constructor. Multiline constructor is also supported.
- Add methods. Public methods are always placed before the first private method.
- Add getters and setters.
- Getters and setters are placed after a constructor if the constructor exist, if not, they are placed after the last propery.
- If the class has a missing getter or setter for a property, then the missing getter or setter will be added.
- If the class has a getter and a setter for a property, nothing will be added.
How do you do all of that?
Keybindings:
{
"key": "alt+c",
"command": "class-helper.addConstructor"
},
{
"key": "ctrl+alt+c",
"command": "class-helper.addPrivateProperties"
},
{
"key": "alt+m",
"command": "class-helper.addMehtod"
},
{
"key": "ctrl+alt+m",
"command": "class-helper.addPrivateMehtod"
}
Now you can bind the shortcuts to execute commands according to your preferences.
Settings
PHP specific settings:
{
// Php: default property visibility
"class-helper.php.property.visibility": "public",
}
TypeScript specific settings:
{
// TypeScript: prefix method and properties with public or private keywords
"class-helper.ts.prefixVisibility": true,
// TypeScript: default property visibility
"class-helper.ts.property.visibility": "public",
// TypeScript: prefix method with the type declaration
"class-helper.ts.method.prefixType": true,
}
Idea
This extension is inspired by sublime php companion package.
Hope you like it :)