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 213107 - Code folding for Inner Classes
Summary: Code folding for Inner Classes
Alias: None
Product: editor
Classification: Unclassified
Component: CSL (API & infrastructure) (show other bugs)
Version: 7.2
Hardware: All All
: P2 normal with 12 votes (vote)
Assignee: Svata Dedic
Depends on:
Blocks: 209284
  Show dependency tree
Reported: 2012-05-28 15:02 UTC by Ondrej Brejla
Modified: 2012-09-26 14:03 UTC (History)
6 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Note You need to log in before you can comment on or make changes to this bug.
Description Ondrej Brejla 2012-05-28 15:02:43 UTC
Please, allow CSL languages to use the "Inner Classes" folding option. It's not allowed right now, so we have to rape "Tags and other code blocks" for folding of common classes (e.g. in PHP). I think that "Inner Classes" option will be much better.

And then, we can use "Tags and other code blocks" option for a proper things...such for a folding of If, Do, While, For, Switch, etc. statements. Now we handle them together with "Methods" block and it's really annoying...

Thanks a lot.
Comment 1 Ondrej Brejla 2012-05-28 15:06:48 UTC
Defect...sice it's really missing in GsfFoldManager. Think that fix could be simple.

Comment 2 mclaassen 2012-07-03 14:42:45 UTC
Looks like the folding in 7.2 RC1 (and the more recent dailies before that) had different folding behavior.  The fold a few weeks ago, if I remember correctly worked like:

l = new ActionListener() {
	public void actionPerformed(ActionEvent e) {
To something like:
l = new ActionListener() {[...] myMethodCall(); [...]}

Now it is just:
l = new ActionListener() {[...]}

I felt that modified fold was very handy.  What happened to it?  (And, for those of us still using Java 6, the automatic "diamond operator" type fold was nice as well: l = new ArrayList<[...]>.)
Comment 3 NicoS 2012-08-01 18:22:04 UTC
Same here. Please fix the code folding which includes methods and these annoying code folds for if/while/for statements.

Just give us an extra option, so we can choose if we want to fold if/for/while/... statements, too.
Comment 4 Martin Fousek 2012-08-06 10:41:00 UTC
Nine votes should be enough to increase to P2. I think that at least for PHP is this really annoying.

Mkristofic could you please set the expected target milestone? Thanks a lot.
Comment 5 lampacz 2012-08-29 10:11:05 UTC
Please add options what to fold for php folding. 

Maybe only statements(if/for/while) with {} should be folded or depends on user settings
Comment 6 Ondrej Brejla 2012-09-12 08:55:36 UTC
Milutin, can you implement it please? 13 votes is quite enough ;) Thanks!
Comment 7 Svata Dedic 2012-09-12 10:55:44 UTC
(In reply to comment #2)
> To something like:
> l = new ActionListener() {[...] myMethodCall(); [...]}
> Now it is just:
> l = new ActionListener() {[...]}

This feature (AFAIK) is not a part of a release, but can is provided by a contrib module 'java.ext.editor'. I originally wanted to make a clean-up and adopt the feature to the main line, but I don't think I can manage that for 7.3.

The later described behaviour is the standard one - the entire inner/anonymous class body is collapsed/folded.
Comment 8 Ondrej Brejla 2012-09-12 11:37:17 UTC
Don't forget that we discuss 2 problems here. 

1) One about implementing of "Inner Classes" folding for CSL, which is missing (Milutin's issue),

2) and another about Java folding (Svata's issue)

The second one should have its own separate issue I think. And hope that the first one will be fixed soon ;)

Thanks in advance.
Comment 9 Martin Fousek 2012-09-12 12:01:00 UTC
(In reply to comment #8)
> Don't forget that we discuss 2 problems here. 
> ...
> The second one should have its own separate issue I think. And hope that the
> first one will be fixed soon ;)


The Java issue should be solved separately. I think that most of votes are related to annoying PHP folding (as reported in comment #0) and is, I would say, stopper for using method foldings in PHP right now.
Comment 10 Svata Dedic 2012-09-12 12:25:35 UTC
People, could you summarize what fold type constants do you now use in PHP and for what purpose ?

I noticed that the top-level class is folded with "tag" ("tags and other code blocks") fold type. Is that correct ? This hack is used in Java folding as well, btw, but Java mod achieves the current behaviour by reusing "tag" type, while providing different setting as autocollapse value. I cannot do that in CSL as the autocollapse setting name is determined by the fold type.

That said, PHP takes an approach different from Java, which does not fold top-levels, Java Fold manager does not report folds for toplevel classes at all -- that's why there's only "fold INNER classes" option in the Options dialog. 

Should be the top-level classes foldable ? And if so, should they fold in a different way than inner classes ? If both answers are "yes", we may need yet another setting (collapse top level classes), exposed in UI, and perhaps honoured by Java fold manager as well.
Comment 11 Ondrej Brejla 2012-09-12 12:40:08 UTC
Now we use: "Tags and Other" for Top level classes in PHP (since PHP has no inner classes...but we can have more top level classes in one file) and "Methods" for methods and for If, Else, Do...statements. 

But that's useless...we need an empty "Tags" just for these If, Else statements and let "Methods" just for methods.

But then we need some another option for our classes. I thought that "Inner" classes solution would be "good enough" for our users. But if you wanna implement just another option, "Top Level Classes", it would be great as well.

So my suggestion is to enable "Inner Classes" folding type for CSL languages (which is not working for now) and then implement whole new option "Top Level Classes". That first implementation part should be simple and fast I think, but I don't know how fast could be the second part :)

So the conclusion, we, in PHP, just need to enable one option, which can handle classes - for NB 7.3 :) Not so important how is that option called ;)

Comment 12 Svata Dedic 2012-09-12 12:49:40 UTC
Sorry for my ignorance about PHP syntax, I've never really worked with it except correcting someone else's scripts. If you think that the wording "Inner classes" wouldn't be confusing for users (and won't produce continuous defect flow ;)), I gladly agree with your proposal.

I still hope that we will be able to somewhat open the fixed set of fold types to language-specific extensions in the future (incl. UI), so unless necessary I would not extend the current core set unless absolutely necessary.
Comment 13 Ondrej Brejla 2012-09-12 12:55:12 UTC
I think that they will be glad that they can somehow fold what they want, regardless the name of the option :) Thanks a lot.
Comment 14 Marian Mirilovic 2012-09-13 10:19:20 UTC
14 votes -> P2
Comment 15 Svata Dedic 2012-09-13 14:30:10 UTC
Changeset: 76bf738b761b
Author:    Svata Dedic <>
Date:      2012-09-13 16:30
Message:   Issue #213107 - Code folding for Inner Classes: fixed
Added 'inner-classes' folding type, bound to "Inner classes" UI option. Cleaned up copypasted code.
Comment 16 Svata Dedic 2012-09-13 14:34:29 UTC
Please use "inner-classes" as fold type. There's also unused "othercodeblocks" constant, which is currently mapped to "Tags and Other Code Blocks" option, consider to use this one for if/elses for better upwards compatibility.
Comment 17 Quality Engineering 2012-09-14 02:10:34 UTC
Integrated into 'main-golden', will be available in build *201209140001* on (upload may still be in progress)
User: Svata Dedic <>
Log: Issue #213107 - Code folding for Inner Classes: fixed
Added 'inner-classes' folding type, bound to "Inner classes" UI option. Cleaned up copypasted code.
Comment 18 oddfish 2012-09-14 14:09:10 UTC
Just downloaded last night's release.  Here's what I've found in a PHP class file if I exclusively select any of these folding options:

- folds everything under class (class is expanded) including:
    - methods
    - if blocks
    - try/catch blocks
    - for/while loops
    - etc.

Inner Classes
- nothing folded

Tags and Other Code Blocks
- folds entire class from top, but everything under class is expanded

What I really need is the (previously existing) option to fold ONLY methods while leaving all sub-elements (try/catch/if/for blocks) expanded.  Would have thought checking off "methods" would do this.  Is there any way to do this?  It used to work this way before.
Comment 19 Svata Dedic 2012-09-14 14:16:29 UTC
You probably need to wait for the dependent defect #209283 to be fixed; this request deals just with the infrastructure PHP folks needed to fix the issue with PHP code folding.
Comment 20 Ondrej Brejla 2012-09-17 07:58:03 UTC
Thanks a lot Svato.
Comment 21 oddfish 2012-09-25 17:21:25 UTC
OK.  I'm confused.  #209284 is flagged as RESOLVED WONTFIX.  Does this mean this will never be addressed?  As a PHP user code folding has become so frustrating I have to stop using netbeans.  I spend a massive amount of time every time I open the IDE either manually folding all functions or manually unfolding all code blocks (if/switch/while/for/etc...)  If there's no hope, I'd rather know now.

Comment 22 Ondrej Brejla 2012-09-26 07:21:14 UTC
oddfish: that issue with strange methods/if, else statements is fixed for PHP in NB 7.3. You can try it in dev build.
Comment 23 oddfish 2012-09-26 14:03:17 UTC
Many thanks!  Build 201209260001 did the trick.