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.

Bug 235364

Summary: Anonymous Function With Object{}, Exposing Local Vars to Window Object For Code Completion
Product: javascript Reporter: gwillie
Component: EditorAssignee: Petr Pisl <ppisl>
Status: NEW ---    
Severity: normal    
Priority: P3    
Version: 7.3.1   
Hardware: PC   
OS: Linux   
Issue Type: ENHANCEMENT Exception Reporter:

Description gwillie 2013-09-01 12:44:01 UTC
I couldnt find much as for other bugs/feature requests, Bug 224463 would be similar but not really.

For javascript: we have an anonymous function with object that we expose back to window eg

(function(window)
{
  function somefunc()
  {
    // this method wont be exposed for code completion
    // as was not passed back to window object
  }

  // this obj should have code completion outside of anonymous function
  var obj = {
    method: function()
    {
      // more...code
      return obj.method.instance.meth1();
    },
    literal:{
      key1: 'val1'
    }
  };
// set some vars
obj.method.instance = new somelib();
// expose obj back to window
window.obj = obj;
})(window);

i utilise this pattern so i can instantiate an otherwise static object.

it would be nice if the editor could pick up on this fact and expose any object or var that was explicitly exposed (eg window.obj = obj;).

Just a thought.

Thanks
Comment 1 Petr Pisl 2014-11-12 12:35:42 UTC
The problem is that in your example window is the name of the parameter. We can not really on the name of parameter. I can implement this pattern, but it will not probably work in all cases.