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.
var MODULE = (function () { var my = {}, privateVariable = 1; function privateMethod() { // ... } my.moduleProperty = 1; my.moduleMethod = function () { // ... }; return my; }()); http://www.adequatelygood.com/2010/3/JavaScript-Module-Pattern-In-Depth http://www.yuiblog.com/blog/2007/06/12/module-pattern/ http://snook.ca/archives/javascript/no-love-for-module-pattern Currently, when you use it - neither private, nor public methods appear in code navigator. Would be nice if they did (like in WebStorm IDE).
Yes it would be nice to support this approach. I'm marking as enhancement.
What I think is a better pattern that does work as expected is the following pattern which is similar. This pattern will show in code completion correctly and have the correct documentation presented while allowing for the same pattern and IMHO better encapsulation as all your exports are in one place (the return statement). MODULE = (function() { var privateVariable = 1; function privateMethod() { // ... } var publicMethod = function() { // ... } return { /** * This is a readonly property * @property */ moduleProperty: function() { return privateVariable; }, /** * This is a writable property * @property */ moduleProperty2: function(newVal) { return newVal ? privateVariable = newVal : privateVariable; }, /** * @function */ publicMethod: publicMethod } })();
NB7.3 still cannot parse such code. Shouldn't new JS engine have addressed this?
*** Bug 156553 has been marked as a duplicate of this bug. ***
Increased Priority (i am considering switching to WebStorm, if this feature would not be implemented), and updated milestones and platform field.
This seems to be more of a bug than an enhancement. NB7.3 seems to have taken a huge step backward with regard to the Javascript Navigator. NB7.2 wasn't great but it was usable. Now it seems like hardly anything is showing up in the navigator. Even the simplest sort of closure pattern seems to befuddle the navigator. For example: (function closureFunction(){ var scalarVariable = "Invisible in navigator!"; var arrayVariable = ["Invisible!"]; var objectVariable = {}; // Object variable is visible for some reason function invisible(){ // Invisible in navigator } var functionVariable = invisible; })(); Yields ONLY the following in the navigator: objectVariable At least the previous versions of NetBeans recognized all named functions, regardless of scope, which allowed us to assign dummy names to otherwise anonymous closures (e.g. "closureFunction" above) and use the navigator to jump to them. We've been looking forward to these new Javascript features in NB7.3, but it's virtually impossible to see them when we can't even navigate around our code. In any event, thanks for all the great work on this IDE to date!
Please check issue 226480, which fixes your issue. It is targeted to the next patch.
Hy The Netbeans Navigator doesn't find my object,function and variables. I use a Pattern like this: ********* my/init.js ***************** My = window.My || {}; ********* my/test.js ***************** My.test = { test: true, testFunction: function(){ return "hallo"; } } ************************************* If i work in the text.js, the Navigator show nothing. if i work in the init.js, the Navigator show me my object
I recently ran into this myself and with some help from StackOverflow figured a way around it. The way the code you guys is structured, we are really dealing with objects and not a class or instance thereof. Give that, you can simply move the first lines around in order for you to still maintain the scoping/private variables and yet still have a global object containing your methods. So restructuring the code you posted would look like the code below and most importantly everything shows up in the navigator: (function() { var privateVariable = 1; function privateMethod() { // ... } var publicMethod = function() { // ... } MODULE = { /** * This is a readonly property * @property */ moduleProperty: function() { return privateVariable; }, /** * This is a writable property * @property */ moduleProperty2: function(newVal) { return newVal ? privateVariable = newVal : privateVariable; }, /** * @function */ publicMethod: publicMethod } })();
It's useful to have workarounds, but ideally one should not need to program to the IDE (and sometimes one just wishes to view others' code)...