You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@netbeans.apache.org by "Christian Lenz (JIRA)" <ji...@apache.org> on 2017/06/27 15:35:00 UTC

[jira] [Created] (NETBEANS-14) Create variable declaration from selected code

Christian Lenz created NETBEANS-14:
--------------------------------------

             Summary: Create variable declaration from selected code
                 Key: NETBEANS-14
                 URL: https://issues.apache.org/jira/browse/NETBEANS-14
             Project: NetBeans
          Issue Type: New Feature
          Components: javascript - Refactoring
    Affects Versions: 9.0
            Reporter: Christian Lenz


When I want to refactor some code and maybe I see this:

{code}
var foo = function () {
   for (var i = 0; i < myObject.thisIsAnArray.length; i++) {
 
   }
 
   anotherFunctions(myObject.thisIsAnArray.length);
   yetAnotherFunctions(myObject.thisIsAnArray.length);
};
{code}

I want to select the phrase: myObject.thisIsAnArray.length and type a hotkey or right click > refactor > create variable.

and this should be look like this:

{code}
var foo = function () {
   var varName = myObject.thisIsAnArray.length;
 
   for (var i = 0; i < varName; i++) {
 
   }
 
   anotherFunctions(varName);
   yetAnotherFunctions(varName);
};
{code}

This feature is already implemented in intelliJ and very helpfull.

Here I mean the part which Java already has: Select a text and press alt + enter (because you see the hint/fix at the line) and you see the hint: introduce Variable..., field..., member... Assign return value to new Variable. Those options are missing for JavaScript and is a must have in my opinion as a WebDeveloper



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)