简体   繁体   English

JavaScript类定义本地作用域启用使用tern的全局代码完成

[英]JavaScript class definition local scope enable global code completion with tern

We use this way to define classes in our js code: 我们使用这种方式在我们的js代码中定义类:

  ( function( $, wb ) {
        "use strict";

        /**
        * @class wb.QueryServiceEditor
        * @constructor
        */
        var SELF = wb.QueryServiceEditor = function QueryServiceEditor(
        ) {
        };

        SELF.prototype.fromTextArea = function( selector ){
        };

    }( jQuery, wb ) );

The problem I have with this approach is that the code completion I use (eclipse + tern) is not working well with this when using this class QueryServiceEditor from a different scope. 我使用这种方法的问题是,当从不同的范围使用此类QueryServiceEditor时,我使用的代码完成功能(eclipse + tern)不能与此一起很好地工作。

How could we improve our code to make code completion possible everywhere? 我们如何改善代码以使代码完成在任何地方都可行?

The important thing when you work with ternjs is that you must declare your variable . 使用ternjs时,重要的是必须声明变量 Perhaps you have not declared your wb variable? 也许您尚未声明wb变量?

I have tried with tern.java 1.1.0-SNAPSHOT and it seems it works, here a screenshot with completion for fromTextArea method: 我已经尝试过tern.java 1.1.0-SNAPSHOT,它似乎可以正常工作,这是一张来自fromTextArea方法的完整屏幕截图:

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM