开发者

Netbeans code completion doesn't see javascript functions or global variables

Example jscript:

    var aGlobalVar = 1;

    function aFunction(){
        aGlobalVar = 2;
    }

    function anotherFunction(){
        var aLocalVar = 3;
        //开发者_开发百科insertion point here
    }

If I'm typing in anotherFunction() as indicated, and I press Ctrl+SPACE, the content assist box contains neither aGlobalVar nor aFunction(), but it does give me aLocalVar. Any ideas why this happens? I've tried many javascript editors, and Netbeans is my favorite, except for this one issue. I'm using Netbeans IDE 7.0

Edit: interestingly enough, everything does show up properly in the Navigator panel. some screenshots:

Netbeans code completion doesn't see javascript functions or global variables

Netbeans code completion doesn't see javascript functions or global variables

Netbeans code completion doesn't see javascript functions or global variables


When you hit Ctr+Space on an empty line, NetBeans offers you a list of most likely variables and functions you may want to use. These are local variables for the context, and after a horizontal line, another most likely list, and a note at the top, that some results are omitted.

If you add further characters, your global may very well show up.

Netbeans code completion doesn't see javascript functions or global variables

Edit: wrapping the code in an immediate function solves it, well sort of :)

(function () {

    /* ... */

})();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜