Community
Participate
Working Groups
It would be very useful to have code folding for if statements and for loops.
I would like to add switch and case statements to the list.
I'd like also to fold all the '{' '}' statement like for enum & struct..
I'd love to see folding for "if" "else" "else if" "for" "while" "case" "switch" and simular constructs.
I'd just like to add a "me too" to this enhancement request.
*** Bug 213938 has been marked as a duplicate of this bug. ***
Created attachment 87339 [details] A non finished patch that solves the problem for reference only Where should I send patches? Is there a mailing list?
Created attachment 87346 [details] Final version of the patch - please review and comment The following patch should enable C statements folding. Please review it and apply it to the next version of CDT. I'll be glad for comments about my patch quality. If you need me to fix anything - do tell. Thanks
Created attachment 87362 [details] A better version of the patch which enables case folding This is a better version of the previous patch, it allows folding of case statements within switch. It'll only fold case statements in the body of a switch statement, that is: switch (a) { case 1: break; }//possible switch (a) { if (0) { case 1: break; } }// not possible
Thanks for the patch. It looks quite good! I would like you to make the following changes: - Please keep Java 1.4 source level - Remove debug print statements (or prefix with "if (DEBUG)") - default clause in switch is not handled correctly - The new checkbox on the preference page is wrongly connected to the option for initial folding of inactive preprocessor branches - JUnit tests would be great! See class FoldingTest in org.eclipse.cdt.ui.tests - Add a contributor note to the Copyright comment of each file
Created attachment 87468 [details] Fixed patch, without JUnit tests yet This fixes all the issues you asked me to fix. Thanks alot. I didn't add the unit tests yet, since I didn't think of a good way to get the projection information from a file, but I want to do that until weekend. Please, apply the patch even before the JUnit tests.
(In reply to comment #10) > Created an attachment (id=87468) [details] > Fixed patch, without JUnit tests yet > This fixes all the issues you asked me to fix. Thanks, I noticed a lot of formatting changes. Is it OK if I revert those changes before applying? > I didn't add the unit tests yet, since I didn't think of a good way to get the > projection information from a file, but I want to do that until weekend. The class FoldingTest already has support to verify projection positions.
Created attachment 87696 [details] Final patch with JUnit tests, and Enum folding This patch has Enum folding support and JUnit tests updated to test the patch as well. Please have a look at it, you may change whatever you see which would be better.
If you've installed one of the other previous patches, you may need to redownload org.eclipse.cdt.ui and org.eclipse.cdt.ui.tests from CVS or it may not build correctly...at least that's the experience I had.
(In reply to comment #12) > Created an attachment (id=87696) [details] > Final patch with JUnit tests, and Enum folding > This patch has Enum folding support and JUnit tests updated to test the patch > as well. Thanks. I noticed that this new patch creates duplicate positions due to the additional handling of declarations in the ast visitor. I reverted this to the version of the previous patch and re-added the handling for enums. Applied to HEAD.
I'm not sure if I'm running into a different problem or a problem introduced by this latest patch. But here's the scenario, 1. Start off with everything expanded 2. Collapse All 3. Expand something (anything) 4. Add or Modify some code and summon the Template Proposal to suggest something 5. After selecting something from the Template Proposal list, EVERYTHING wants to expand on its own. However it's doing a bad job of it because some things are only partially expanded...yes partially expanded and there are the dot-dot elipses all over the screen where the "unexpaded" parts are. I know I've seen the partial expansion of things before this patch was developed. I even saw that on v3.3 where only the functions would collapse. So I don't think the bug is directly related to this patch. Without knowing the code, I can't say this for sure, but perhaps the bug is in whatever supporting code this patch is making use of. I've been using almost every one of the patches listed above, and I don't recall this happening with any of them except this latest one (2008-01-23). Thoughts?
1) Oops, indeed I tried to add folding to long arrays (int a[] = {1,2,3})) but forgot to revert that before creating the patch. 2) Did you check that you didn't break the JUnit tests? I'll try to check it and propose another patch with the JUnit tests enabled.
(In reply to comment #15) Please update to CVS HEAD. (In reply to comment #16) > 1) Oops, indeed I tried to add folding to long arrays (int a[] = {1,2,3})) but > forgot to revert that before creating the patch. I actually took the previous patch, as I mentioned in comment 14. > 2) Did you check that you didn't break the JUnit tests? I'll try to check it > and propose another patch with the JUnit tests enabled. Don't bother, I already fixed the tests.
I updated org.eclipse.cdt.ui and org.eclipse.cdt.ui.tests from HEAD, and it did the same thing with the unfolding. I've deleted all cdt projects so I can redownload them all from HEAD. I'll see if that makes any difference. Doing this has helped in the past with other issues I had.
(In reply to comment #18) Please open a new bug if the problem persists.