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
Was I the only one who read this and thought it was about the lunar eclipse that's just finished?
Couldn't see much cos of cloud cover - I drove miles to get out to a decent location to take photos, for no good reason.
Ah well. Fold your lunar eclipse code @home or something.
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 downloaded Eclipse and the C++ tools but couldn't get anything like VS.NET's IntelliSense -- is it not supported for Eclipse? I use VS.NET 2003 regularly, but it has this aggravating tendency to freeze up for 5-10 seconds at a time very occasionally. That, and my project broke the IntelliSense, too. :)
I'd like to point out this feature exists in emacs, too.
:help usr_28.txt
And in Vim too.
See
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.
Just wanted to point out that NetBeans also has this feature in the recently released 3.6. You don't have to wait until an "official" Eclipse release; you can use a stable NetBeans now. Obviously, I like NetBeans, and I think they've been making leaps and bounds of progress recently. I'm really looking forward to 4.0 with the Ant based project system. Then, you should be able to work in either NB or Eclipse, or Emacs or whatever floats your boat. Hooray for competition!
Also, for those saying this leads to bad coding style, I'm hoping that the forth-coming refactoring features in NB 4.0 will make this much less of an issue (don't know about Eclipse equivalent feature). Got a junior dev who likes to make really really long code blocks? Refactor into saner functions with a little help from your IDE. Since I'm about to get some junior devs dumped on me, I hope it does work out...
-1 Not Funny
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 thought the reason eclipse didn't support easily collapsing and browsing 100's of line of code had to do with lack of need vs other non-java IDEs. Why would an effective java programmer generate methods with 100's of lines of code that need summarizing? Such methods are known to be error-prone and hard to read and understand. This is why we refactor complex methods into smaller, more focused methods. Once this is done, the package explorer and outline views are much more effective than code folding would be, since they allow navigation at the semantic level (assuming you've chosen good method names). It disturbs me that there is so much demand in the java community for a feature that would be most useful in a language that failed to express the power of OO.
You are in a maze of twisty little passages; all alike.
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;
}
http://www.netbeans.org/community/articles/tiger/3 6Tiger.html
I hope they're working to make Eclipse more Mac compatible. I'm using it on my Powerbook. It's great, but soooo many of the dialog layouts are way off. Things resize poorly and are often totally different and innapproriate sizes. Text starts to the left of the text boxes that hold them, so that I've got to click in the box and scroll left to see the beginning. It's crazy. I guess it's all SWT's fault. Does anyone know if this is being worked on?
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.