Sunian314
Sunian314

Reputation: 329

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: enter image description here enter image description here enter image description here

Upvotes: 3

Views: 3731

Answers (1)

aorcsik
aorcsik

Reputation: 15552

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.

enter image description here

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

(function () {

    /* ... */

})();

Upvotes: 2

Related Questions