Catch up on stories from the past week (and beyond) at the Slashdot story archive

 



Forgot your password?
typodupeerror
×
Programming IT Technology

Eclipse Finally Gets Code Folding 90

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."
This discussion has been archived. No new comments can be posted.

Eclipse Finally Gets Code Folding

Comments Filter:
  • Code folding is: (Score:5, Informative)

    by Elwood P Dowd ( 16933 ) <judgmentalist@gmail.com> on Tuesday May 04, 2004 @04:52PM (#9056281) Journal
    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?
    • Re:Code folding is: (Score:5, Interesting)

      by Yokaze ( 70883 ) on Tuesday May 04, 2004 @05:16PM (#9056617)
      > 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 [linux.no].
      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 [wisc.edu].
      • If you have to scroll some pages to find the corresponding closing tag, something has gone wrong.

        Perhaps, but it's just as annoying tracing your way through a bunch of method/function calls.
        • Perhaps, but it's just as annoying tracing your way through a bunch of method/function calls.

          Same rule applies. If you have to trace through a bunch of methods, it's time to refactor, because something has gone wrong.

    • 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
      • Re:Code folding is: (Score:3, Interesting)

        by abrotman ( 323016 )
        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).
      • by Elwood P Dowd ( 16933 ) <judgmentalist@gmail.com> on Tuesday May 04, 2004 @05:58PM (#9057116) Journal
        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?
        • I tend to use vim when editing either HTML, XML, or other markup languages. (And, in fact, SQL stored procedures, because we use MS SQL Server at my work and it's native editor is t3h suck.) I use brace matching, incremental search, and vim's code folding functionality. Especially when working with large HTML or XML files, folding up large sections of code makes it much less... stressful to see what's going on. Personal preferences differ, I'm sure. I like it.
      • Vim offers code folding. There are even Windows and KDE-enabled versions.

        I'd be really surprised if EMACS didn't offer something similar.
        • I'd be really surprised if EMACS didn't offer something similar.

          I'd be really surprised if the idea didn't come from Emacs in the first place. outline-mode has existed in Emacs since the '80s, and before it was made to play nicely with other programming modes by default (it used to take a lot of configuration for anything other than bullet-point text like the Emacs NEWS file), someone wrote a folding-mode [csd.uu.se] (apparently in 1992) specifically for curly-brace languages (C/C++ etc).

      • jEdit, Netbeans...
      • I've been using it in netbeans since one of the early 3.6 betas I downloaded. It's in the 3.6 version that was recently released.
    • Real programmers use the tools they like. I like code folding because it forces me to see everything that's going on in the class, when I'm say, modifying two functions.
    • Real programmers don't believe they have to do arbitrary things because "Elwood P Dowd" said so.
      • Hey, whether I'm a real programmer or not is easily confirmed by my coworkers. They say I learned VB 6 in record time .

        P.S. I *asked* whether that was something "real" programmers would do. I guarantee you, I'm not a "real" programmer.

        I think I've only ever met one or two. And they didn't write SQL queries. For cash. On the street. Eating government cheese.
  • code folding? (Score:5, Interesting)

    by jpu8086 ( 682572 ) on Tuesday May 04, 2004 @04:53PM (#9056308) Homepage
    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?
    • Code folding is always the same... in practise it's no better than just looking over at the bottom left window, which shows all the methods and fields in your class. If anything it's a little more inconvenient because you need to keep opening things when you have to edit the insides.

      Really at this point the only thing that Eclipse could do to wow me would be fixing bugs like "application performance sucks", or "there is no Qt frontend." The latter of these I've been investigating lately by prodding the r

      • Re:code folding? (Score:3, Informative)

        by rmull ( 26174 )
        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
      • Really at this point the only thing that Eclipse could do to wow me would be fixing bugs like "application performance sucks", or "there is no Qt frontend."

        or printing in Linux...
  • Availability (Score:4, Interesting)

    by jtheory ( 626492 ) on Tuesday May 04, 2004 @05:48PM (#9057013) Homepage Journal
    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 [eclipse.org].

    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?
  • Hint for Emacs Users (Score:5, Informative)

    by AT ( 21754 ) on Tuesday May 04, 2004 @06:22PM (#9057350)
    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).
  • by Anonymous Coward
    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. :)
    • Re:Eclipse and C++ (Score:3, Interesting)

      by notamac ( 750472 ) *
      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 - i
      • Re:Eclipse and C++ (Score:5, Informative)

        by Gill Bates ( 88647 ) on Wednesday May 05, 2004 @08:48AM (#9062342)
        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.
  • by Guspaz ( 556486 ) on Tuesday May 04, 2004 @09:56PM (#9059343)
    Wouldn't support for code-folding and J2SE 1.5 features be feature requests, and not bugs?
    • by Phil John ( 576633 ) <philNO@SPAMwebstarsltd.com> on Tuesday May 04, 2004 @10:43PM (#9059667)
      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.
    • Bugzilla (Score:2, Interesting)

      by bcore ( 705121 )
      Very often OSS projects use Bugzilla [bugzilla.org] 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.
    • Oh boy. In the topic of J2SE, IntelliJ IDEA had (albeit experimental) support for 1.5 over half a year ago (was it longer? It might have been a whole year by now.)

      I wish that the new Eclipse would have support for the Java which is emerging at the time it comes out.

      People often start developing an application while the SDK or APIs they're using are in beta because by the time the app is finished, the API will be in final release. But right now there is no free IDE for editing J2SE 1.5 code (unless you

      • 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 [eclipse.org] (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.
  • by f00zbll ( 526151 ) on Tuesday May 04, 2004 @10:37PM (#9059614)
    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.

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

      Interesting point. Maybe what should be done to support co

    • "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.
    • I can't speak for Java (long time ago now), but code folding makes writing OO PHP a whole lot nicer.

      PHP has no preprocessor "include" statement, so short of splitting your method bodies into other files using the execution time include statement which brings a performance penalty on every call to the method, you often wind up writing huge monoliothic classes full of relevant methods rather than nicely splitting them into smaller files and using a preprocessor directive to include them.

      I have my editing en
      • What?! How can you talk about preprocessing and PHP? It's a scripting language. It's all execution-time processing, especially in regard to includes.

        What you really want is C-style preprocessing. The fundamental difference here is that in C the code gets compiled and therefore preprocessing makes sense. Unless PHP steps up from being interpreted files to being binary executables, what you are talking about makes no sense.

  • 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 lead
  • IDEA (Score:2, Informative)

    by tpv ( 155309 )
    For those who dislike the implementation, it is recommended that you use IntelliJ IDEA, rather than resubjecting yourself to a world of pain.
  • 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 woul
    • Code folding would be extremely nice for comments, imports, and the case where you inheret someone else's really really bad code (read as 100s of lines in a single method).

      Otherwise, truly well written OO code would rarely even lend itself to code folding.

    • 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 sourc

      • Ouch! I personally find that test-driven development is a helpful approach to dealing with such legacy behemoths... there is some up-front catch-up work but it's usually possible to a) keep it focused on the task at hand and b) make at least some of the code simpler (read: better-factored) than it was.

        Or you could just run a java-to-vb cross compiler and replace your entire staff with high school students ^^-)

  • by kmsigel ( 306018 )
    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 lo
    • Argh! It's FORTRAN written in Java! Quick, sprinkle the Holy Water...
      • <blockquote><i>Argh! It's FORTRAN written in Java!</i></blockquote>
        <p>
        Don't worry - Java's garbage collector will take care of that garbage...
        <p>
    • I don't like this.
      I know that everybody has their own style but I work in a commercial organization that writes Enterprise software and I can tell you that this would not have passed our code reviews.
      1- The formatting is too tight. Not enough white space.
      2- Complete absence of comments (big boo boo)
      3- Poor indenting (affects readability)
      4- Multiple statements on one line (usually a bad idea)
      • I don't like this.
        I know that everybody has their own style but I work in a commercial organization that writes Enterprise software and I can tell you that this would not have passed our code reviews.


        I have already stated that this style probably isn't right for most people. It works well for me and since I work alone nobody else has to see it.

        1- The formatting is too tight. Not enough white space.

        I like it precisely because it is tight.

        2- Complete absence of comments (big boo boo)

        Comments often t
    • OMG! You're an "else cuddler". That's just not right! :)
  • 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?
    • This is probably not the answer you're looking for - but NetBeans works very well on a Mac as it uses Swing not SWT. NetBeans vs Eclipse is a real case of swings and roundabouts. For some things I prefer Eclipse (better autocompilation and error detection and better execution targets) but in other ways I prefer NetBeans. Give NetBeans a whirl - it may work for you.

He has not acquired a fortune; the fortune has acquired him. -- Bion

Working...