你知道它可以自动完成这种代码的任何IDE?
我这里有一个JavaScript类生成:
(function() {
var core = {
bind : function(method, scope) {
if (!( method instanceof Function))
throw new TypeError("Function needed as method.");
if ( typeof (scope) != "object")
throw new TypeError("Object needed as scope.");
return function() {
return method.apply(scope, arguments);
};
},
require : function(source) {
if ( typeof (source) != "object" || !source)
throw new TypeError("Object needed as source.");
for (var property in source)
if (source.hasOwnProperty(property) && !this.prototype.hasOwnProperty(property))
this.prototype[property] = source[property];
},
override : function(source) {
if ( typeof (source) != "object" || !source)
throw new TypeError("Object needed as source.");
for (var property in source)
if (source.hasOwnProperty(property))
this.prototype[property] = source[property];
},
extend : function(source) {
var superClass = this;
var newClass = source.hasOwnProperty("constructor") ? source.constructor : function() {
superClass.apply(this, arguments);
};
newClass.superClass = superClass;
var superClone = function() {
};
superClone.prototype = superClass.prototype;
newClass.prototype = new superClone();
newClass.prototype.constructor = newClass;
if (source)
newClass.override(source);
return newClass;
}
};
core.require.call(Function, core);
Function.create = function (source){
var newClass = source.hasOwnProperty("constructor") ? source.constructor : function() {};
newClass.override(source);
return newClass;
};
})();
我需要为这些示例类代码完成(在评论中写道):
//Function.prototype: bind, require, override, extend
//Function.create
var A = Function.create({ //offer Function.[create]
test: function (){
console.log("a");
}
});
//A is a Function instance
//A.prototype: test
var B = A.extend({ //offer A.[extend]
test: function (){
console.log("b");
},
test2: function (){
console.log("b2");
}
});
//B is a Function instance
//B.prototype inherits from A.prototype
//B.prototype.test overrides A.prototype.test
var F = Function.create({ //offer Function.[create]
getA: function (){
return new A();
},
getB: function (){
return new B();
}
});
//F is a Function instance
//F.prototype getA, getB returns A and B instances
var f = new F(); //offer [F]
//f inherits from F.prototype
var a = f.getA(); //offer f.[getA]
//a inherits from A.prototype
var b = f.getB(); //offer f.[getB]
//b inhertis from B.prototype
a.test(); //offer a.[test]
b.test(); //offer b.[test]
b.test2(); //offer b.[test2]
所以,我必须让IDE莫名其妙地知道,这些职能中存在的Function.prototype的,而这些功能是创建功能情况,他们正在编写到这些实例的原型。 这是可能只与我的代码手工索引,像jsdoc,但是这还不足以形容例如继承。 所以,我需要它至少可以处理JS继承,为此我可以写一个自动创建索引这个插件的IDE。 (也许插件可以办理财产继承的也一样,我不知道该索引是怎么工作的?)
哪个IDE是深谙此道(以及如何)?