What is a JavaScript refactoring plugin for Eclipse (or Intellij IDEA) quality?

Today, when I tried to make it simple to rename refactoring in JavaScript using intellij IDEA 10, I was shocked at what it did. He renamed this attribute of the class everywhere, regardless of the attribute belonging to this class or not! For example, Baz.attr1 , renamed Baz.attribute1 , it also renamed Box.attr1 to Box.attribute1 . Previewing Refactor here does not help, because there are hundreds of places where the same attribute name is used in different situations like this.attr1 .

Eclipse does not have JavaScript rename refactoring.

In addition to renaming, I am looking to reorganize a group of functions and move them to Object Literal notes such as

 function foo() { } function bar() { } 

refactor to:

 var MyCompany.Baz = { foo: function() { }, bar: function() { } } 

It should reorganize all references to these function calls in all files, including HTML and JSP files such as foo(); changing to MyCompany.Baz.foo();

There is no such thing in the IDE.

Is there a high-quality JavaScript plugin for Eclipse (preferably) or Intellij IDEA that will perform the type refactoring I'm talking about?

+4
source share
1 answer

I believe that refactoring the renaming you want is not possible in a dynamic language.

Say you have the Baz and Box classes with the attr1 attribute.

If we write something like:

 var b; if (someCondition) { b = createBox(); } else { b = createBaz(); } b.attr1 = "value"; 

What should a refactoring program do?

Given that the type of a variable is known only when the corresponding code is executed, and that this type may differ each time this code is called, the computer cannot determine which definition causes the attr1 attribute to be called, should be associated with.

+8
source

All Articles