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 156553 - Recognizing modular object or class constructions in JavaScript
Summary: Recognizing modular object or class constructions in JavaScript
Status: RESOLVED DUPLICATE of bug 202932
Alias: None
Product: javascript
Classification: Unclassified
Component: Editor (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker (vote)
Assignee: Petr Pisl
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-01-10 04:13 UTC by brettz9
Modified: 2012-12-02 12:55 UTC (History)
0 users

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description brettz9 2009-01-10 04:13:39 UTC
Hi,

This sounds like it might be rather difficult, but given its use in sophisticated JavaScript applications in which
namespacing, privacy, etc. are desired (and given your demonstrated skills in adding support for other JS/E4X features),
I wonder if you might be able to add support for this...

It would be nice to be able to see such constructions (notice the immediate invocations after the main function) be
recognized by the IDE (such as for display in the navigator):

var fooObj = function () {
	var privateStaticVar = 'something';
	function privateStaticMethod () {
		return 'another thing';
	}
	return {
		publicMethod : function () {
			return privateStaticVar + ' and '+ privateStaticMethod();
		}
	};
}();
alert(   fooObj.publicMethod()  ); // something and another thing

The above method is presently invisible to the Navigator.


or, for this more complex construction...

var BarClass = function () {
	var privateStaticVar = 'something';
	function privateStaticMethod () {
	    return 'another thing';
	}
	function aConstructor () {
	    var privateInstanceVar = 'something else';
	    this.privilegedMethod = function () {
		return privateStaticVar + ', ' + privateStaticMethod() + ' and ' +privateInstanceVar;
	    };
	}
	aConstructor.prototype.publicMethod = function () {return 'public';}
	return aConstructor;
}();
var bar = new BarClass();
alert(  bar.privilegedMethod()  ); // something, another thing and something else
alert(  bar.publicMethod()  ); // public

These methods show up, but due presumably also to http://www.netbeans.org/issues/show_bug.cgi?id=154178 , they don't
show up within 'BarClass' (or 'bar'), but as top level functions...

thanks!
Comment 1 Petr Pisl 2009-10-08 14:17:32 UTC
This mean add some heuristic to the creating AST. There is no time to add this to NB 6.8. I hope that we will be able to
do this next release. 
Comment 2 c69 2012-12-02 12:55:36 UTC
I'm marking this one as duplicate, because it has less votes.
But notice how old the issue is - reported in January 2009! and its almost January 2013 now :(

*** This bug has been marked as a duplicate of bug 202932 ***