This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
Please try this: function Test() { this.perform = function(data, callback) { callback.call(this); }; } var test = new Test(); test.perform({}, function() { var c = {}; c.name = "Test"; alert(c.name); }); The "c" is displayed as global variable in Navigator (but it is not purple and it is correctly not suggested in code completion for global variables). If the "c" is primitive or "instance" of some function, like: var c = 1; // or var c = new Date(); it is ok and Navigator does not show it. Product Version: NetBeans IDE Dev (Build web-main-9627-on-20130103) Java: 1.7.0_10; Java HotSpot(TM) Client VM 23.6-b04 Runtime: Java(TM) SE Runtime Environment 1.7.0_10-b18 System: Linux version 3.2.0-34-generic-pae running on i386; UTF-8; en_US (nb)
The same goes with immediate functions: (function(){ var dir = {}; })();
If we want to show objects that are defined in anonymous function, then there are displayed in global context. I don't know how to express that they are defined in the a anonymous function. I can switch off displaying such objects in navigator, but I'm not sure whether we want this. What do you think?
Aha, that's true, it's probably better to show it then. I don't know better way that wouldn't make Navigator confusing (maybe put them all into single "fake" item?). Then perhaps following test.perform({}, function() { var c = new Date(); }); should make c visible in Navigator as well although its not object literal.
Is this issue related to the fact that the navigator in the latest 7.3 RCs seem to be ignoring closures altogether? As of 7.2.1, it appears that any named function is listed at the top level of the navigator tree. I'm not sure if this was a defect, but it turned out to be quite useful in keeping track of various closures and anonymous functions that tend to proliferate. Is there some other pattern or plan to get the 7.3 navigator to pick up these references?
Created attachment 131366 [details] NetBeans 73RC2 JS Navigator - Closure ignored
The closers are now displayed correctly -> closing this bug as fixed.
Integrated into 'main-silver', will be available in build *201508050002* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main-silver/rev/4d78597f26b0 User: Petr Pisl <ppisl@netbeans.org> Log: #224463 - Object literals declared in anonymous function appears as global in Navigator