Refactoring (renaming function)

HI:

i try to rename one  of the function inside a javascript files (es 6 modules), the function was exporting by the following. if i rename one of the function (shift + F6), it will become "sendFile: sendFileToVH". Which it is not what i expecting, because if i require this file in another javascript file, i still have to use sendFile function rather than the sendFileToVH function. Is anyway we can change this renaming behaviour ? 

was:

module.exports = {
sendFile,
getFiles,
renameFiles,
};

refactored:

module.exports = {
sendFile: sendFileToVH,
getFiles,
renameFiles,
};

expecting:

module.exports = {
sendFileToVH,
getFiles,
renameFiles,
};
1

When renaming object shorthand property, you are normally prompted what would you like to rename:

Just choose to rename a property

0

Hi Elena Pogorelova:

I can't see that screen pop up when i did the renaming. The only screen pop up is the following. Do you where i can turn it on ?

1

Hi @Elena Pogorelova:

i have create a sample project and did some testing.

if i rename the method directly it does not prompt me any options(picture 1 and picture 2). if i select the method name inside the module.exports, it will prompt the options property or function, no matter which one i pick ,it will end up the same results. Could you double check and confirm ? is this a bug ?

 

0

Well. But the result in the last screenshot is different, isn't it? The property is renamed, and the require() call is updated as expected

0

hi @Elena Pogorelova, yes it it changed, but not the result what i was hoping for. 

1 i want it to change method name in all the place (including the export, actual method, and place which use this method), so for example in the module.exprots = { methodOneNew} rather than module.exports = { methodOneNew: methOne}. Do you get me point ?
2 why i need to rename the function inside the module.exports to prompt this option ? This option does not show up when i press shift + F6 in the actual function name.

Cheers

0

For shorthand object properties we were specifically requested to expand properties from '{foo}' to '{renamed:foo}' on renaming to avoid breaking the code if function is a part of a public API, or a callback to a library function.

Anyway, please feel free to vote for https://youtrack.jetbrains.com/issue/WEB-27085

0

请先登录再写评论。