Community
Participate
Working Groups
It is great to see that general folding functionality for editors finally has been implemented and bug http://bugs.eclipse.org/bugs/show_bug.cgi?id=9355 has been closed. However it is not clear if support for folding Java code blocks (basicallsy any pair of {...} including if, for, do/while, try/catch/finally, unnamed and synchronized blocks) is going to be supported in future.
Do you mean blocks or any selected text (also covering blocks)?
Not selected text, but Java code between btackets {...}
Note that you can provide this yourself with an additional plug-in which contributes a folding structure provider.
Is there are any examples how to do that? From other hand it is quite common functionality for Java editor.I'm not sure if it will be just enough to take any pair of matching {...} or it has to know about Java grammar. See how grammar-based outline was working for Together - http://w8.platonoff.com/together/folding.gif
Doc/example phase comes later.
I understand that at this state the documentation may not be ready, but I had a question: I assume that the folding structure that currently works (folding methods and some comments) are implemented some place. Could you tell me where they are implemented? This way I may be able to understand a bit more without proper documentation. What I mean is which extension currently included in the eclipse sdk uses the IJavaFoldingStructureProvider extension point? I was unable to find this on my own which is why I am asking. Thanks in advance
see DefaultJavaFoldingStructureProvider
*** Bug 67431 has been marked as a duplicate of this bug. ***
FYI - for those of you that want this functionality, please see my folding editor plug-in: http://www.coffee-bytes.com/servlet/PlatformSupport
*** Bug 74879 has been marked as a duplicate of this bug. ***
*** Bug 76469 has been marked as a duplicate of this bug. ***
*** Bug 78020 has been marked as a duplicate of this bug. ***
*** Bug 96191 has been marked as a duplicate of this bug. ***
*** Bug 101758 has been marked as a duplicate of this bug. ***
(In reply to comment #3) > Note that you can provide this yourself with an additional plug-in which > contributes a folding structure provider. > This would be a nice feature for dealing e.g. with large if/else blocks. Don't you find it useful enough or why do you want people to implement it themselves?
>Don't >you find it useful enough or why do you want people to implement it themselves? I said neither of it, didn't I? I only mentioned how it can be achieved. An other option for people giving this a higher priority than we currently do is to participate in the Eclipse open source project and provide us with a good patch that implements this.
(In reply to comment #16) > I said neither of it, didn't I? I only mentioned how it can be achieved. An > other option for people giving this a higher priority than we currently do is to > participate in the Eclipse open source project and provide us with a good patch > that implements this. Sorry I had been staring at that huge if-statement for so long that I started wondering why the best IDE on the planet still can't fold control structures ;) Coffee-bytes seems to work with Eclipse 3.2M3, maybe you could take over some code from there? I'd bet rjlorimer wouldn't mind you doing so if you tell him...
>Coffee-bytes seems to work with Eclipse 3.2M3, maybe you could take over some >code from there? I'd bet rjlorimer wouldn't mind you doing so if you tell him... Since he's listening to this PR as well he can comment on this himself. As stated above we'd be happy to get contributions.
Is he (In reply to comment #18) > >Coffee-bytes seems to work with Eclipse 3.2M3, maybe you could take over some > >code from there? I'd bet rjlorimer wouldn't mind you doing so if you tell him... > Since he's listening to this PR as well he can comment on this himself. As > stated above we'd be happy to get contributions. I can't find him on the CC and I don't believe Bugzilla CCs everybody who has ever commented on a PR. I'll allow myself to put him on the CC. Hello R.J. Lorimer, are you listening?
You're right. I parsed the cc-list too quickly ;-)
Is this issue can be addressed for Eclipse 3.2? Unfortunately folding provider from coffee-bytes does not work with Eclipse 3.2M6, so I wonder if there could be a native support in Eclipse.
Sorry not for 3.2: we're beyond feature work.
*** Bug 148518 has been marked as a duplicate of this bug. ***
Can I vote for this feature. It would be extremely valueable for me.
>Can I vote for this feature. ==> https://bugs.eclipse.org/bugs/votes.cgi?action=show_user&bug_id=60929#vote_60929
*** Bug 195387 has been marked as a duplicate of this bug. ***
See also: bug 148233
Is there any progress on this issue. Especially since 3.5 is almost there. Additional question: Can Bug 63808 also applied to this issue, or is this some kind of separte issue?
>Is there any progress on this issue. Especially since 3.5 is almost there. Definitely not for 3.5 (RC4 just went out and the code base is basically frozen). >Additional question: Can Bug 63808 also applied to this issue, or is this some >kind of separte issue? This bug is only about folding well defined Java code blocks inside braces. Bug 63808 goes further in the sense that it introduces a syntax to mark custom code blocks in the JDT Core layer. However, if the ProjectionViewer is enhanced/fixed so that it can show custom code blocks it will be easy to support this bug here.
3.6sp1 is out and no sign of this feature yet....
After almost a decade, maybe the status could be changed back to NEW. Just so it makes some sense.
(In reply to comment #31) > After almost a decade, maybe the status could be changed back to NEW. Just > so it makes some sense. No, that would make no sense. NEW means, the bug has not yet been triaged by a developer. ASSIGNED means the bug/feature has been accepted.
Hey all, I'm a GSoC student and I am currently working on this bug. It is coming along well so far. If you would like updates then check out my repository at https://github.com/R41D3NN/eclipse.jdt.ui and http://www.google-melange.com/gsoc/project/google/gsoc2013/ahrichards/16001#.
Glad this is worked on - maybe a duplicate https://bugs.eclipse.org/bugs/show_bug.cgi?id=195339 Don't forget anonymous blocks : { }
*** Bug 195339 has been marked as a duplicate of this bug. ***
I've worked on an implementation for this bug that can be found here: https://github.com/R41D3NN/eclipse.jdt.ui/tree/Bug-60929--Java-Code-Block-Folding It includes folding functionality for the following: * Conditional Blocks * Loop Blocks * Switch Blocks * Try/Catch/Finally Blocks * Synchronized Blocks Unnamed (Anonymous) Block folding is currently disabled due to a bug, but I hope to fix this soon.
(In reply to Austin Richards from comment #36) > I've worked on an implementation for this bug that can be found here: > https://github.com/R41D3NN/eclipse.jdt.ui/tree/Bug-60929--Java-Code-Block- > Folding To be clear, I believe that Austin would like to contribute this code to the project. Austin has a signed CLA and the contribution has been signed-off-by. What is Austin's next step?
(In reply to Wayne Beaton from comment #37) > (In reply to Austin Richards from comment #36) > > I've worked on an implementation for this bug that can be found here: > > https://github.com/R41D3NN/eclipse.jdt.ui/tree/Bug-60929--Java-Code-Block- > > Folding > > To be clear, I believe that Austin would like to contribute this code to the > project. Austin has a signed CLA and the contribution has been > signed-off-by. What is Austin's next step? We are very busy working on Java 8 support, but might find a bit of time for an initial review and give an initial feedback, for that we either need a patch or a Gerrit change. This makes it easier to provide the feedback.
A related but not duplicate bug is : https://bugs.eclipse.org/bugs/show_bug.cgi?id=69684 - discussing adding folding support for anonymous and inner types - as well as top level types (classes/interfaces). Could be also addressed here ? Also to bring to your attention the (eternal) : https://bugs.eclipse.org/bugs/show_bug.cgi?id=63808 So adding folding support should be addressed with this in mind (adding support for custom regions, preferably user editable)
Created attachment 235579 [details] Patch For Bug Fix 60929
> Created attachment 235579 [details] > Patch For Bug Fix 60929 It is a bit surprising that the folding does not use the AST of the file and instead it reads char by char - is the info not available ? Or is this used in the case the file has compilation errors ? Anyway - folding is one of the important things IDEs have to offer - so please consider in your design the bugs in https://bugs.eclipse.org/bugs/show_bug.cgi?id=60929#c39 - especially the long lasting https://bugs.eclipse.org/bugs/show_bug.cgi?id=63808 - as well as a family of bugs like https://bugs.eclipse.org/bugs/show_bug.cgi?id=165681 (for PDT but I guess there is the analogous one in JDT) - essentially add the ability to fold any selected lines
(In reply to Palmer Eldritch from comment #41) > > Created attachment 235579 [details] [diff] > > Patch For Bug Fix 60929 > It is a bit surprising that the folding does not use the AST of the file and > instead it reads char by char - is the info not available ? Or is this used > in the case the file has compilation errors ? > > Anyway - folding is one of the important things IDEs have to offer - so > please consider in your design the bugs in > https://bugs.eclipse.org/bugs/show_bug.cgi?id=60929#c39 - especially the > long lasting https://bugs.eclipse.org/bugs/show_bug.cgi?id=63808 - as well > as a family of bugs like > https://bugs.eclipse.org/bugs/show_bug.cgi?id=165681 (for PDT but I guess > there is the analogous one in JDT) - essentially add the ability to fold any > selected lines So far folding does not use (and need) the AST, so that the folding can be presented faster. This is not nailed in stone though. All other comments are better made in the corresponding bugs. This one here is purely for code blocks.
(In reply to Austin Richards from comment #40) > Created attachment 235579 [details] [diff] > Patch For Bug Fix 60929 Noopur, please make a first review when you have some spare time during your Java 8 work. Thanks.
Created attachment 236373 [details] Screenshot with issues Initial review comments: - Update the bundle version of org.eclipse.jdt.ui to 'Bundle-Version: 3.10.0.qualifier' in MANIFEST.MF. - Add "@since 3.10" tag to the new DefaultJavaFoldingStructureProvider.FoldingStructureComputationContext.collapse*() methods and update the @since tags for new constants in PreferenceConstants. - There is no check box for unnamed/anonymous blocks in Preferences. (In reply to Austin Richards from comment #36) > Unnamed (Anonymous) Block folding is currently disabled due to a bug, but I > hope to fix this soon. This doesn't seem to be supported yet in the attached patch. But the related code is partially present in the patch, with some commented code as well. Please update/remove that. - Default values should be set for new preferences in PreferenceConstants.initializeDefaultValues(IPreferenceStore store). - New preferences do not work : Check/uncheck has no difference on initial state of folding. - Uncheck a new preference, click OK, reopen Folding Preferences -> the state of all the checkboxes is lost. - Check all folding preferences (including old ones) and open this file: //------------------------- package code.block.folding.bug60929; public class C3 { /** * test */ private void foo() { } } //------------------------- Expand the comment : The comment is expanded but it is still shown with collapsed marks at each line. I haven't gone through DefaultJavaFoldingStructureProvider#computeCodeBlockFoldingStructure(...) yet, but this issue is not present when there is no call to this method. The same issue also exists with newly added switch, try/catch/finally structures etc (See attached screenshot). Please take care of these general guidelines also: - Refer http://wiki.eclipse.org/JDT_UI/How_to_Contribute to configure your workspace with JDT UI specific Save Actions and follow the Coding Conventions mentioned there. - Make sure the copyright date is updated to 2013. - Add your credentials to the contributors list and follow this one line pattern: Name <e-mail> - summary - https://bugs.eclipse.org/BUG_NUMBER - Attach an EGit patch from next time instead of the msysgit patch. - Post this in the bug report as a comment along with the patch: "This contribution complies with http://www.eclipse.org/legal/CoO.php" - Dani, please have a look at the texts for new preferences and suggest their default values and order.
(In reply to Noopur Gupta from comment #44) > Expand the comment : The comment is expanded but it is still shown with > collapsed marks at each line. > I haven't gone through > DefaultJavaFoldingStructureProvider#computeCodeBlockFoldingStructure(...) > yet, but this issue is not present when there is no call to this method. > The same issue also exists with newly added switch, try/catch/finally > structures etc (See attached screenshot). I had reported the same behavior as a bug : https://bugs.eclipse.org/bugs/show_bug.cgi?id=403358 IIRC I had the coffe-bytes plugin at the time (probably I had already uninstalled it) HTH
VSCode offers code folding for all of the features listed in https://bugs.eclipse.org/bugs/show_bug.cgi?id=60929#c36.