1

我的项目通过以下代码模式实现继承:

ScanTemplate1.prototype = Object.create(ScanTemplateBase.prototype);
ScanTemplate1.prototype.contructor = ScanTemplate1;

在这里,ScanTemplate1 继承自 ScanTemplateBase 类。

现在在任何 .js 文件中,内容辅助仅建议在 ScanTemplate1.js 文件中定义的成员函数。它不建议从 ScanTemplateBase 继承的成员函数。

我正在使用带有最新 JSDT 版本的 eclipse Luna。有没有办法启用内容辅助来建议继承的成员函数?

示例: ScanTemplateBase 类有一个函数

ScanTemplateBase.prototype.getInstruction = function(){
    return this.instruction;
};

ScanTemplate1 有一个功能

ScanTemplate1.prototype.getTextbox = function() {
return this.textbox;
};

现在,在文件main.js中,我有声明

var packageScanBox = new ScanTemplate1( ..... constructor args ....);

在输入packageScanBox。并按Ctrl + space,它建议getTextbox()但不是getInstruction()

提前致谢!

4

1 回答 1

1

免责声明,我是tern.java的作者

我建议你安装 tern.java,它支持Object.create. 我已经快速测试了:

在此处输入图像描述

由于 tern.java 是基于ternjs的,您可以使用ternjs 在线演示来测试您的案例。

于 2015-07-08T13:10:59.363 回答