p42ai / js-assistant

120+ refactorings and code-assists for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=p42ai.refactor
MIT License
119 stars 7 forks source link

Inline occurence issue #17

Closed chandan192 closed 2 years ago

chandan192 commented 2 years ago

Previous Code const temp3 = []; temp3[0] = temp1; temp3[1] = temp2;

![Uploading image.png…]()

After refactoring [][0] = temp1; [][1] = temp2;

lgrammel commented 2 years ago

Thanks for the bug report! I'll update when I have a fix.

lgrammel commented 2 years ago

Hey @chandan192 - I agree that inlining here does not make sense, and you would typically not invoke it.

However, I'm not sure I understand what the issue with the refactoring is? The resulting code compiles and executes for me, and it indeed the expected result of an inline operation on temp3.

What would you expect to happen instead?

chandan192 commented 2 years ago

Hi @lgrammel, I was just experimenting with the refactoring using p42 and tslint. I got the p42 refactoring suggestion on the context menu. Inline 2 occurrences [p42]

I also checked the p42 suggestion on the activity bar but there was no suggestion. It was only on the manual context menu refactoring.

lgrammel commented 2 years ago

I see - in this case it was not a 'suggestion' (an in, P42 recommended), but it showed up in the quickfix menu. I'll add a warning similar to what is shown for new Objects.

lgrammel commented 2 years ago

I've made a couple of improvements in v1.103.1 to address this issue:

Thanks for the bug report!