Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getter/setter helper #32

Open
jhnyang opened this issue May 14, 2021 · 1 comment
Open

getter/setter helper #32

jhnyang opened this issue May 14, 2021 · 1 comment
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@jhnyang
Copy link

jhnyang commented May 14, 2021

thank you for convenient tool!

it would be great if it supports getter/setter implementation as well.
thank you

@amir9480 amir9480 added the enhancement New feature or request label May 14, 2021
@amir9480 amir9480 added the help wanted Extra attention is needed label Oct 3, 2021
@Ares9323
Copy link

Ares9323 commented Oct 3, 2021

Hi, I'm commenting here because I read the "help wanted" tag.
What do you exactly mean by "getter/setter implementation"?

I actually use C++ only for unreal engine and they have a particular syntax but I think you can solve your problem with a simple snippet like this (removing FORCEINLINE stuff if you don't need it):

"Unreal GetSet": {
    "prefix": "GetSet Variable",
    "body": [
        "//GetSet ${1:Variable_Name}",
        "FORCEINLINE ${2:Variable_Type} Get${1:Variable_Name}() {return ${1:Variable_Name};}",
        "FORCEINLINE void Set${1:Variable_Name}(${2:Variable_Type} In${1:Variable_Name}){${1:Variable_Name} = In${1:Variable_Name};}",
    ],
    "description": "Create getter/setter functions"
},

To write a getter/setter for a variable you just need to type "getset" and autocomplete will suggest you the snippet, then you have to enter the variable name, press tab and enter the variable type, you will have this result:

//GetSet Counter
FORCEINLINE int32 GetCounter() {return Counter;}
FORCEINLINE void SetCounter(int32 InCounter){Counter = InCounter;}

You can also add a string to the snippet after the comment to declare at the same time the variable and the getter/setter:
"${2:Variable_Type} ${1:Variable_Name};",

(If you want to type the Variable type before the variable name just invert the numbers 1 and 2)

It will be really cool to right click the variable and create this syntax but for me this is good enough at the moment!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants