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:
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.
Edit: wrapping the code in an immediate function solves it, well sort of :)
(function () {
/* ... */
})();
精彩评论