vscode-gengetset icon indicating copy to clipboard operation
vscode-gengetset copied to clipboard

Constructor is being generated empty

Open joseques opened this issue 7 years ago • 2 comments

When I use the "Generate constructor" command, it ignores my private variables and it generates and empty constructor.

private _id : string;
public get id() : string {
    return this._id;
}
public set id(v : string) {
    this._id = v;
}
//This is what it gets generated when I run the command.
constructor() {
}

Is there any way to debug the extension?

Any help to resolve the bug would be appreciated.

joseques avatar Jul 01 '18 20:07 joseques

Hi joseques,

It may be because you've got a space between the var name and : Try this private _id: string; Then generate again, It's actually working fine for me.

See you

xavierburzig avatar Sep 13 '18 13:09 xavierburzig

https://github.com/cybertim/vscode-gengetset/blob/4f5eac275a458f1535dd3dd36a6cde3b8f87a462/src/getset.ts#L51

should be

if (currentPos.isAfterOrEqual(classes[i].startPos) && currentPos.isBeforeOrEqual(classes[i].endPos)) {

You can fix it locally by editing the file ~/.vscode/extensions/dskwrk.vscode-generate-getter-setter-0.5.0/out/src/getset.js and reloading the window (or closing and starting vscode again).

igoraguiar avatar Feb 15 '19 01:02 igoraguiar