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.



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 entry was posted in Cool Feature 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:
    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.

Leave a Reply

Your email address will not be published. Required fields are marked *