Eclipse Finally Gets Code Folding
binarysearch writes "Code folding is finally in the Eclipse project! After more than two years open, Eclipse's Bug 9355 has finally been marked FIXED. Code Folding was the most-voted for bug in Eclipse, with support for J2SE 1.5 features in a close second. Check out the I20040504 Integration build for folding in the Compilation Unit Editor (Class File Editor support is in HEAD). For those who dislike the implementation, it is requested that you create a new bug, rather than reopening 9355."
There are no trails. There are no trees out here.
this is a misnomer. i was lost for a while. i was under the assumption that code folding is akin to code wrapping (which eclipse has had since day 1)
i would rather term it code collapse...and which is what they call it in the main bug report. however, lots of people call it folding in the followup comments.
i guess i better get used to it being called code folding too.
so, i am happy that i can collapse 100s of lines of code into just the relevant 10-15 lines of code easily. however, i think this can create a problem of introducing silly error pass through (because you dont have the whole perspective on things). i think they have a feature to collapse all code that doesnt involve a variable "x". Anyone tested this yet?
now supporting:
cmdrTaco for president '04
michael for oval office intern summer '05
I'm guessing this is only available in the nightly builds for now, since I just hopped over to the site and there's no sign of a new milestone release (would be M9).
So... don't get excited -- the feature is *coded*, but you can't use it yet. That is, I haven't tried an Eclipse nightly before, but in general it's a bad idea if you're depending on the tool.
It looks like the latest integration build (a step up from a nightly) is still failing its tests.
In my experience, even some of the milestone builds have been a tad flaky (I put up with it because I want the features).
Anyone involved in the project know anything about when the next milestone release is planned?
There are only 10 types of people: those who understand decimal, those who don't, and, uh, 8 other types I forget.
I know this article is about eclispse, but I'd like to point out this feature exists in emacs, too.
Turn on hs-minor-mode (M-x hs-minor-mode) and code blocks can be folded and unfolded with shift-middle-click (or C-c @ C-c).
It's funny that people are so happy about this feature. It was the first thing that I turned off in netbeans 3.6. It was a feature that I always wanted in a code editor until I used it and realized that it was only for people who don't read code.
You need to see the code if you're going to write it or understand it.
I'm a bit curious about Eclipse and C++ too. Whilst I'm not *so* concerned about intellisense (although something like Ctrl+P from Vim would be handy), the last time I downloaded the CDT, about 50% of my source code would crash the environment (put CPU usage up to 100% indefinately IIRC).
:)
So, that was about a year ago, and I've been a bit hesitant to try it again, despite the fact I really did like the Eclipse environment.
Can anyone comment on how far the CDT has come in the last 12 months? Oh and also - is there any support for refactoring C++ yet
Wouldn't support for code-folding and J2SE 1.5 features be feature requests, and not bugs?
For example, most of the .NET programmers I work with are x-VB guys and they use this alot. what ends up happening is they put all the classes in one file. Which actually leads to a tendency of coding with lots of inner classes. One of the biggest strengths of Java in my mind is it encourages programmers write smaller chunks of code that is more modular and re-usable. If you write your code in a well organized manner, you won't really need folding. Especially since the right pane in Eclipse shows you the methods and allows you to double click and jump to that point quickly.
I read the bug/feature requests and many of the arguments in my mind are personal bias. they aren't really valid. Several people complained Eclipse wasn't usable because it didn't have folding. I question that way of thinking and suggest the user is inflexible and unwilling to adapt. If it's that important, then write it yourself and submit it to eclipse. Needless whining serves no one any good. The time spent whining could be spent coding.
Very often OSS projects use Bugzilla to track problems and requests for enhancements. To bugzilla, the fundamental unit (whether it's a defect or an RFE) is called a Bug.
Therefore, when they call it "Bug 9399", they are just referring to the entry in bugzilla with that number.
For those who dislike the implementation, it is recommended that you use IntelliJ IDEA, rather than resubjecting yourself to a world of pain.
Read more of this story at Slashdot.Read more of this story at Slashdot.Read more of this story at Slashdot.
I have never used code folding. What I do is (of course) try to keep basic blocks short and focused. In addition, I make my code dense by putting multiple short statements on one line if they are related. (Statements that appear near each other are usually related.) I also place a group of several short statments that are the target of an if/while/etc on the same line as the if/while/etc.
;
What this does is fit a lot more code in the same number of lines (not recommended for LOC whores), meaning you see a lot more code on screen at once.
Here is an example of code I wrote yesterday:
KError error; ichar c;
Loop: if (error = Read(&c)) return error;
if (KIsFlagSet(readMode,fModeAuto)) {
if (KIsFlagSet(readMode,fModeTwo)) {
if (KIsFlagSet(readMode,fModeCR)) {
if (c == CR) { readMode = cModeTextLFCR; goto Loop; }
else readMode = cModeTextLF;
} else {
if (c == LF) { readMode = cModeTextCRLF; goto Loop; }
else readMode = cModeTextCR;
}
} else if (c == CR) {
readMode = cModeTextAuto | fModeTwo | fModeLF; c = LF;
} else if (c == LF) {
readMode = cModeTextAuto | fModeTwo | fModeCR;
}
} else if (c == CR) {
if (KIsFlagSet(readMode,fModeCR)) c = LF;
else if (KIsFlagSet(readMode,fModeToss)) goto Loop;
} else if (c == LF) {
if (KIsFlagClear(readMode,fModeCR))
else if (KIsFlagSet(readMode,fModeToss)) goto Loop;
}
Can anyone comment on how far the CDT has come in the last 12 months? Oh and also - is there any support for refactoring C++ yet :)
Not very far, AFAIKT. I used it a couple of months ago for some JNI/C++ code I was working on, and found that although it looks a lot like the Java editor, it behaves vastly different.
No code completion, no code formatting, no refactoring.
Just a basic code editor with color syntax highlighting.
That's what I keep saying to my coworkers. Nevertheless, we have methods over a thousand lines long, and our largest class is hovering around 25kloc (and I assure you, there's little reason for most of that code to be in the same class).
If nothing else, code folding is an effective tool for when you're forced to maintain source code written by idiots.