Inline Variable Refactoring for JavaScript / ActionScript

Next version of IntelliJ IDEA, code named Maia, brings you several new JavaScript and ActionScript refactorings. In this post we showcase one of them — Inline Variable, which works with local variables and ActionScript class fields.

Before Inline Variable

Pressing Control+Alt+N (default Windows keymap) replaces variable occurrences with an initializing expression.

After Inline Variable

During the inline process, IntelliJ IDEA checks if a variable can be safely replaced and warns if, for example, there are its usages inside a functional expression.

Problem detected when inlining variable

By the way, the Inline Variable refactoring also works in the left part of local variable assignment.

Enjoy developing with pleasure!

image description