JavaScript refactoring: Inline Variable

One of the major techniques to keep your code in a good shape is refactoring it. In the latest Web IDE EAP (#470) you can try the just added Inline Variable JavaScript refactoring.

Inline Variable — replaces local variable occurrences with its initializing expression.

Before

After

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

During the inline process, Web IDE verifies if a variable can be safely replaced and gives a warning if not, e.g. there are its usages inside a functional expression.


More JS refactorings are coming in next builds.

Develop with pleasure!

This blog is permanently closed.

For up-to-date information please follow to corresponding WebStorm blog or PhpStorm blog.

 
This entry was posted in Cool Feature, PhpStorm, WebStorm and tagged , , , . Bookmark the permalink.

7 Responses to JavaScript refactoring: Inline Variable

  1. Ilya says:

    What is this color scheme and where take the same? ;)

  2. Eugene Toporov says:

    This one is ‘Thinmint’ from here: http://www.jetbrains.net/devnet/docs/DOC-1154
    We are going to add a dark scheme to Web IDE in one of following builds

  3. Taras Tielkes says:

    What about refactoring support for PHP?

  4. Alexey Gopachenko says:

    Full set of refactorings is planned.

    Currently only “Rename” is implemented (for files, constants, functions, classes, members, parameters and variables).

  5. Taras Tielkes says:

    Alexey, that’s exiting. “Introduce variable” and “Inline variable” are probably the most common ones.
    Do you plan to implement language injection in the first release? Obviously there are hundreds of candidates (literally) for injecting SQL language.

  6. Dean says:

    By the way, that example of refactoring the get cookie function is actually worse than before in the inline variable example – in the “after” shot, the cookie length is evaluated at every iteration in the while loop, instead of just once in the before shot.

  7. Eugene Toporov says:

    @Dean: thanks for the feedback. The example is given just to demonstrate the refactoring but not as a recommendation to refactor this particular code. We realize all developers know their code and make a right decision about the refactorings.

Comments are closed.