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 194774 - Missing support for folding function expressions
Summary: Missing support for folding function expressions
Status: NEW
Alias: None
Product: javascript
Classification: Unclassified
Component: Editor (show other bugs)
Version: 6.x
Hardware: PC Linux
: P3 normal with 2 votes (vote)
Assignee: Petr Pisl
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-01-27 14:09 UTC by hasenstein
Modified: 2011-08-01 07:34 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 hasenstein 2011-01-27 14:09:42 UTC
First, I could not test NB7.0-Beta, because it only produced errors in a while(true) kind of loop that I was unable to break out of (whenever I closed an error window it would just pop up fresh).


The issue: There is only very incomplete code folding for Javascript function expressions.

What works:

var o = {
  func1: function () {
    ...
  },
  func2: function () {
    ...
  }
}

Code folding is provided at both func1 and func2.

What doeesn't work:

var func1 = function () {
  ...
};

There is no folding! Also, for ANY other place where there are function expressions (i.e. functions with no name as in "function NAME () {}") no code folding is offered!

However, function expressions are VITAL for programming in JS. It is not acceptable to have to provide a name only because Netbeans otherwise doesn't provide folding.

Thanks!!!


PS: The complete background for Javascript function expressions vs. function declarations:
- http://dmitrysoshnikov.com/ecmascript/chapter-5-functions/
- http://kangax.github.com/nfe/
Comment 1 hasenstein 2011-01-27 14:12:13 UTC
UPDATE: I forgot to mention the most important reason besides "looks" why being forced to name functions in function expressions is the buggy implementation of this case in IE - see the first provided URL for a description. In essence, I have to live without folding or may have to live with serious side effects when the code runs in IE.
Comment 2 damirsecki 2011-08-01 07:34:45 UTC
I am confused why netbeans in version 7 still doesn't support jQuery... specially for code folding...

I have code snippets like this...

$('#something').click(function(e)){
   ....
});
and of course I'd like my code to be folded, so it would be more readable...

I also tried with cosum fold tags like

`//<editor-fold  defaultstate="collapsed" desc="el click">
   .... 
//</editor-fold>`
that strangly doesn't work in javascript (only in java I suppose)...

same thing goes for JS singletons...

Please advise, how can I fold some snippets in JS with netbeans

just to be clear, I already activated all options in NB settings for code folding(In reply to comment #0)
> First, I could not test NB7.0-Beta, because it only produced errors in a
> while(true) kind of loop that I was unable to break out of (whenever I closed
> an error window it would just pop up fresh).
> 
> 
> The issue: There is only very incomplete code folding for Javascript function
> expressions.
> 
> What works:
> 
> var o = {
>   func1: function () {
>     ...
>   },
>   func2: function () {
>     ...
>   }
> }
> 
> Code folding is provided at both func1 and func2.
> 
> What doeesn't work:
> 
> var func1 = function () {
>   ...
> };
> 
> There is no folding! Also, for ANY other place where there are function
> expressions (i.e. functions with no name as in "function NAME () {}") no code
> folding is offered!
> 
> However, function expressions are VITAL for programming in JS. It is not
> acceptable to have to provide a name only because Netbeans otherwise doesn't
> provide folding.
> 
> Thanks!!!
> 
> 
> PS: The complete background for Javascript function expressions vs. function
> declarations:
> - http://dmitrysoshnikov.com/ecmascript/chapter-5-functions/
> - http://kangax.github.com/nfe/

(In reply to comment #0)
> First, I could not test NB7.0-Beta, because it only produced errors in a
> while(true) kind of loop that I was unable to break out of (whenever I closed
> an error window it would just pop up fresh).
> 
> 
> The issue: There is only very incomplete code folding for Javascript function
> expressions.
> 
> What works:
> 
> var o = {
>   func1: function () {
>     ...
>   },
>   func2: function () {
>     ...
>   }
> }
> 
> Code folding is provided at both func1 and func2.
> 
> What doeesn't work:
> 
> var func1 = function () {
>   ...
> };
> 
> There is no folding! Also, for ANY other place where there are function
> expressions (i.e. functions with no name as in "function NAME () {}") no code
> folding is offered!
> 
> However, function expressions are VITAL for programming in JS. It is not
> acceptable to have to provide a name only because Netbeans otherwise doesn't
> provide folding.
> 
> Thanks!!!
> 
> 
> PS: The complete background for Javascript function expressions vs. function
> declarations:
> - http://dmitrysoshnikov.com/ecmascript/chapter-5-functions/
> - http://kangax.github.com/nfe/