什么是 Eclipse(或 Intellij IDEA)的专业品质 JavaScript 重构插件?
今天,当我尝试使用 intellij IDEA 10 在 JavaScript 中进行简单的重命名重构时,我对它所做的感到震惊。无论该属性是否属于该类,它都会在各处重命名该类属性!例如,Baz.attr1
重命名为 Baz.attribute1
,它还将 Box.attr1
重命名为 Box.attribute1
。重构预览在这里没有帮助,因为有数百个地方在不同的情况下使用相同的属性名称,例如 this.attr1
类型的引用。
Eclipse 甚至没有 JavaScript 重命名重构。
除了重命名之外,我还希望重构一组函数并将它们移动到对象文字符号,例如
function foo() {
}
function bar() {
}
重构为:
var MyCompany.Baz = {
foo: function() {
},
bar: function() {
}
}
它应该重构所有文件中对这些函数调用的所有引用,包括 HTML 和 JSP 文件,例如 foo() ;
更改为 MyCompany.Baz.foo();
两个 IDE 中都没有这样的东西。
是否有适用于 Eclipse(首选)或 Intellij IDEA 的 JavaScript 的高质量插件可以进行我正在谈论的各种重构?
Today when I tried to do simple renaming refactor in JavaScript using intellij IDEA 10, I was shocked what it did. It renamed that Class attribute everywhere regardless the attribute belonged to that class or not! For example Baz.attr1
renamed to Baz.attribute1
, it also renamed Box.attr1
to Box.attribute1
. Refactor Preview does not help here because there are hundreds of places in which the same attribute name is used under different situations like this.attr1
type of references.
Eclipse does not even have JavaScript rename refactoring.
In additional to renaming I am looking to refactor a group of functions and move them to Object Literal notations such as
function foo() {
}
function bar() {
}
refactor to :
var MyCompany.Baz = {
foo: function() {
},
bar: function() {
}
}
It should refactor all references to those function calls in all the files including HTML and JSP files like foo();
changing to MyCompany.Baz.foo();
There is no such thing in either IDE.
Is there high quality plugin available for JavaScript for Eclipse (prefer) or Intellij IDEA that would do the kinds refactorings of I am talking about?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我相信您想要的那种重命名重构在动态语言中是不可能的。
假设您的类
Baz
和Box
具有attr1
属性。如果我们写这样的内容:
重构程序应该做什么?
鉴于变量的类型仅在执行相应代码时才知道,并且该类型在每次调用该代码时都可能不同,因此计算机无法确定属性“attr1”的调用应链接到哪个定义到。
I believe that the kind of rename refactoring that you want is not possible in a dynamic language.
Let's say that you have your classes
Baz
andBox
with theattr1
attribute.If we write something like:
What should the refactoring program do?
Given that the type of the variable is only known when the corresponding code is executed, and that this type can differ at each invocation of that code, the computer is unable to determine to which definition an invocation of the attribute 'attr1' should be linked to.