Reputation: 5323
I'm used to using webstorm to generate getter and setter for classes.
Is there any way to do it with VSCode in short steps?
Upvotes: 33
Views: 102978
Reputation: 2830
A VS Code plugin that works to create Java style getters and setters (accessor and mutator methods) is Wilson Godoi's TypeScript's Getters and Setters Object Oriented Programming Style.
https://marketplace.visualstudio.com/items?itemName=Wilson-Godoi.wg-getters-and-setters
Upvotes: 15
Reputation: 1148
To generate getter and setters in typescript :
1)Download and install the TypeScript Toolbox extension in vscode. https://marketplace.visualstudio.com/items?itemName=DSKWRK.vscode-generate-getter-setter?
2)Press Ctrl+Shift+X or Cmd+Shift+X to open the Extensions viewlet. Find the Go extension, click on it to open the Extension Editor.
3) You can view the Visual Studio Code settings for the Go extension along with their default values and description in the product itself.
4) tick the option for Use 'getValue' and 'setValue' instead of 'get value' and 'set value'.
How to use :
1) Press Ctrl+Shift+P or Cmd+Shift+P
2) Enter and search for command Generate All Getter and Setter then hit Enter.
Upvotes: 0
Reputation: 1040
The shortcut is Ctrl+Shift+R after highlighting the property.
Longer method: Right click on the property. Then click on refactor from the popup menu.
Currently, vscode has no feature to mass generate getters and setters for all class properties at once like in other IDEs so it has to be done one property at a time.
Upvotes: 26
Reputation: 2515
This feature is shipped builtin with Visual Studio Code 1.24 (May 2018); see here: https://code.visualstudio.com/updates/v1_24#_generate-gettersetter-refactoring
Basically you select the line with the property, then a Quick Action bulb is shown which you have to click. Then you can generate the getters/setters.
Upvotes: 47
Reputation:
May someone correct me who knows it better, but as far as I know the bare VS Code is not capable of providing this convenience. I'm sure that there exist certain plugins you can use, but I don't know any name.
Edit
Maybe TypeScript Toolbox is what you are searching for.
Upvotes: 0