Slashdot Mirror


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."

30 of 90 comments (clear)

  1. Code folding is: by Elwood+P+Dowd · · Score: 4, Informative
    Code folding is where you can collapse a block of code between a set of squirrely braces so it reads"
    { ... }
    or
    // ...
    or
    /* ... */
    Or whatever. Yes, this is like VS.NET and a million other IDEs. I use it all the time, but it never would have occured to me that it was a big deal. I figgered y'all FS/OSS types would use incremental search and brace matching to go anywhere in your code, rather than the scrolly-wheel. Isn't that what "real" programmers would do?
    --

    There are no trails. There are no trees out here.
    1. Re:Code folding is: by Yokaze · · Score: 4, Interesting

      > Isn't that what "real" programmers would do?

      Or what about keeping the code blocks small and concise? See Linux kernel coding style Chapter 4.
      If you have to scroll some pages to find the corresponding closing tag, something has gone wrong.

      But I've to admit, that I use code folding myself, which shows, I'm not a real programmer. But I also prefer Emacs to vi, which only confirms the fact I'm a quiche eater.

      --
      "Between strong and weak, between rich and poor [...], it is freedom which oppresses and the law which sets free"
    2. Re:Code folding is: by jpu8086 · · Score: 2, Troll

      Not withstanding your trivial explanation, what the fuck are you trying to do -- little troll?

      No, a million other IDEs don't have it. I only know of two: VS.NET and IDEA J.

      And no, Eclipse is an OSS project. It is not limited to usage by FS/OSS programmers.

      And no, FS/OSS programmers demand high-standard devlopement tools too which equates to great ease of use. Why do you think we have simple, and easy to use build systems (make) and revision systems (subversion, cvs)? We also like GUI builders (Glade, QT Designer) , when we have to produce GUI code.

      Now, go home and troll to your momma.

      --
      now supporting:
      cmdrTaco for president '04
      michael for oval office intern summer '05
    3. Re:Code folding is: by abrotman · · Score: 3, Interesting

      iirc .. VS.NET, Dreamweaver, Homesite,bluefish,anjuta,eclipse(now), probaby kate, and god knows how many more have this .. its a pretty common feature ive seen in most "major" code editors(dunno about vi(use %) or emacs).

    4. Re:Code folding is: by jpu8086 · · Score: 2, Informative

      Dreamweaver, Homewise, Bluefish: you do Java coding in it? Wow.

      Anjuta doesn't have it. I'm using it right now.
      Kate, I doubt it. It's a text editor.
      Vi doesn't.
      Emacs, I dont know.

      --
      now supporting:
      cmdrTaco for president '04
      michael for oval office intern summer '05
    5. Re:Code folding is: by jpu8086 · · Score: 2, Interesting

      never mind. Anjuta does.
      Ooops. I just upgraded my old ass version.

      Forgive me, senor.

      --
      now supporting:
      cmdrTaco for president '04
      michael for oval office intern summer '05
    6. Re:Code folding is: by Elwood+P+Dowd · · Score: 3, Insightful

      I'm sorry. What on Earth lead you to believe that I have some kind of a problem with FS/OSS development methodologies? I feel that, for good programmers, brace matching and incremental search provide all the "ease of use" that's necessary for living without code folding.

      What sort of a response would I have been trolling for?

      --

      There are no trails. There are no trees out here.
    7. Re:Code folding is: by dedazo · · Score: 3, Insightful

      vim does support folding, though it's a little quirky to get just right. Most editors based on Scintilla (which is very popular with the Python crowd) do as well.

      --
      Web2.0: I love when people Flickr my cuil and digg my boingboing until my google is reddit and I start to yahoo
    8. Re:Code folding is: by BRSloth · · Score: 3, Informative

      Vi (as 6.2.x, at least) have code folding:

      Add in your .vimrc:
      set foldmethod = marker

      And, on your code, do comments like this: /* add function {{{ */
      void stuff(void)
      {
      weird_stuff();
      } /* }}} */

      use 'zc' to close the fold and 'zo' to open it. More info? :help fold

    9. Re:Code folding is: by FAT_VIRGIN · · Score: 3, Informative

      That's VIM, not vi.

  2. code folding? by jpu8086 · · Score: 5, Interesting

    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
    1. Re:code folding? by rmull · · Score: 2, Informative

      Depends what you use it for. If you're folding up method definitions, sure it's the same thing effectively. But there are other places where it helps a WHOLE lot - like when you're using a GUI builder that puts gobs of generated code in different places. Just set it up to fold over the auto-generation delimiters it puts in the file and you can read your code much more easily. I've used it for that in VS.NET, with the gui builder. Eclipse's VE works in very much the same way, so it should be very useful there.

      It also works well with any other application where you have a horde of boilerplate code that you want to ignore but don't want to or can't factor out.

      --
      See you, space cowboy...
  3. Availability by jtheory · · Score: 3, Interesting

    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.
    1. Re:Availability by Dr_Java · · Score: 5, Informative

      The M9 Build is scheduled for Friday May 21, 2004 - its hidden away in the documentation. Full release of 3.0 is scheduled for July 2004.

    2. Re:Availability by plumpy · · Score: 2, Informative

      You have to go to "What's New History" and then scroll down to the Eclipse 3.0 plan.

      They keep updating it, but they never re-list it in the history for some reason, leaving it down in the news from last May.

      Here's a direct link.

  4. Hint for Emacs Users by AT · · Score: 4, Informative

    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).

  5. first thing that I disabled in netbeans by Anonymous Coward · · Score: 2, Insightful

    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.

  6. Re:Eclipse and C++ by notamac · · Score: 2, Interesting

    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 :)

  7. Feature requests, not bugs? by Guspaz · · Score: 3, Insightful

    Wouldn't support for code-folding and J2SE 1.5 features be feature requests, and not bugs?

    1. Re:Feature requests, not bugs? by Phil+John · · Score: 3, Informative

      Yes and no. Typically a lot of oss (and non oss) have one central place to track bugs and feature requests, it just makes it simpler for devs to check one source for what to do next.

      --
      I am NaN
    2. Re:Feature requests, not bugs? by plumpy · · Score: 3, Informative

      They've been planning the 3.0 release for over a year, so they're not going to hold it up to get Java 1.5 support in.

      That said, 1.5 support is coming along and development versions can be installed as a plug-in (that link will also show you the current status).

      Once it's complete, I'm sure it will be included in an Eclipse point release. 3.0.2 or 3.1 or whatever.

  8. questionable features by f00zbll · · Score: 5, Insightful
    although the feature is useful and many programs have them. For example several HTML editors have this feature, since many html pages have tons of tables. Having folding is great for documents that are long like HTML. For code I feel it tends to lead to bad habits.

    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.

    1. Re:questionable features by ClosedSource · · Score: 2, Funny

      "Several people complained Eclipse wasn't usable because it didn't have folding... Needless whining serves no one any good."

      Since the desired feature was implemented, the "whining" was apparently quite effective.

  9. Bugzilla by bcore · · Score: 2, Interesting

    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.

  10. IDEA by tpv · · Score: 2, Informative

    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.
  11. Code Density by kmsigel · · Score: 2, Funny

    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;
    }

    1. Re:Code Density by turgid · · Score: 2, Funny

      Argh! It's FORTRAN written in Java! Quick, sprinkle the Holy Water...

    2. Re:Code Density by AvantLegion · · Score: 2, Funny
      Argh! It's FORTRAN written in Java!

      <p>
      Don't worry - Java's garbage collector will take care of that garbage...
      <p>
  12. Re:Eclipse and C++ by Gill+Bates · · Score: 4, Informative

    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.

  13. Nope. Just dealing with certain realities. by Prior+Restraint · · Score: 3, Insightful

    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.

    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.