#18 Code Folding / Collapsing

open
Jochen Ruehl
None
5
2005-01-18
2004-05-19
Anonymous
No

I'm moving over from Komodo as on the whole, eclipse
seems to be a lot fuller featured.
One thing I'd love to see in EPIC though is the ability
to fold blocks of code (with + and - icons) so that an
"if" block can be collapsed, for example.

Discussion

  • H Kitchin
    H Kitchin
    2004-07-23

    Logged In: YES
    user_id=1014896

    +1 vote for this.

    Now that eclipse 3.0 supports folding is there an ETA for
    EPIC handling it?

     
  • LeO
    LeO
    2004-10-11

    Logged In: YES
    user_id=703323

    The new version has code-folding for Subs only.

    Is this really required for 'if'-statements, cause in
    Eclipse it's not included? And what way should it be
    implemented?

     
  • Logged In: YES
    user_id=739213

    I would appreciate it for if-statemets too, 'cause I often
    have constructs like:

    #-- describe following if-statement
    if( defined $me ) {
    # ..
    }

    so this would be like

    #-- describe following if-statement
    if( defined $me ) {

    Just with an arrow in front. A possible solution to differ
    sub's and if's from each other would it be to define
    different colors for both. You could easily distinguish both
    if, say, the color of the if-arrow is slightly brighter than
    subs'.

    hth,
    p

     
  • LeO
    LeO
    2005-01-18

    • assigned_to: nobody --> luelljoc
     
  • LeO
    LeO
    2005-01-18

    Logged In: YES
    user_id=703323

    Hm', I personally see that one with an IF-ELSE little
    tricky. Cause this could cause a lot of work for the
    programmers on the one side, and for Eclispe on the other
    side. eg. we should distinguis beween

    # if ($test) {

    and

    /if{1,3}/

    and

    if (test) {

    etc. (including bracket-matching)

    So, perhaps the most reasonable approach might be to have a
    right-click option with "Fold mark area" or similar.

     
  • Logged In: YES
    user_id=739213

    Makes sense. Personally I love the #TODO style adding to the
    task-list. Maybe one could create #FOLD or #BLOCK parts. The
    most tricky thing that I see /is/ "bracket matching", like:

    if( cond1 ) {
    for( @array ) {
    if( great_enough ) {
    print
    }
    }
    }

    I'm afraid this would get way more complicated than I
    thought in first moment.

    p

     
  • shiraz
    shiraz
    2005-01-20

    Logged In: YES
    user_id=1161953

    I would also love to see EPIC do code folding. It is very
    irretating to see that code folding works in java
    perspective in eclipse 3.0 and not having this cool feature
    in perl perspective.

     
  • LeO
    LeO
    2005-01-21

    Logged In: YES
    user_id=703323

    since there seems to be more interest in this issue, perhaps
    we can specify it little bit more in detail. Generally speaking
    the codefolding works for subs, but what more is requested?

    Bracketmatching is already there, so this peace of code could
    be easily used.

    Parametrized? If so, then ignoring commented stements,
    under quotes, pods etc? Should this be done automatically?
    Problems I would see at the quick glance eg.

    $aifz = ... {
    ...}
    which I guess should not be folded when you have
    specified 'if' but given the code of phaylon it should -
    although after the 'if' there is no space at all!

    How to specify the parameter for e.g. 'if' in contrast to e.g.
    =head10?

    The more I think, the complicated the issue gets. Hm', but
    perhaps there is a missing concept what should be achieved.
    Perhaps we could generate some samples, and then say,
    what should happen. Could be done as well offline.

     
  • Logged In: YES
    user_id=739213

    | The more I think, the complicated the issue gets. Hm',
    | but perhaps there is a missing concept what should
    | be achieved.

    Hm, this is your backyard. I'm sorry to tell that I have no
    clue how things for eclipse are developed. Do these features
    make use of regular expressions?

    I lately thought about this and got a few idea, but I don't
    know if they may help you. One thing I thought of (if it
    uses regex'es) would be to say one can only fold blocks
    larger than n lines.

    To the question /what/ to fold I reply: I would find it
    mostly useful on if and unless blocks. Most times I want to
    fold away things like Error-Handling, Special cases and
    such. Loops, I think, are more "significant"(sry, not an
    english speaker, lack of a better word..) for the actual
    structure.

    | Perhaps we could generate some samples,
    | and then say, what should happen. Could
    | be done as well offline.

    I'll think over it for the weekend. You're reading your
    sf.net mail?

    so long,
    phay

     
  • shiraz
    shiraz
    2005-01-21

    Logged In: YES
    user_id=1161953

    If I had the BNF Grammar of perl, i would be able to more
    formaly say what needs to be folded. But conceptually any
    thing which is of type "BLOCK" , should have the ability to be
    folded.
    Any construct which has the beginning and end should be
    able to fold. Like for exampe, all the loops, if-then-else
    construct, subroutine( this is already there in epic) and such.

    The concept of folding is new to the intellegent IDE world and
    would take some time for us programmer to fully understand
    the benefit of it. But for those who are maintining someone
    else code which is thousands of line long, this feature is a
    blessing.

     
  • Logged In: YES
    user_id=146409

    The best Idea is to fold with rightclick on the item to be
    folded:

    eg. Brakets, or all possible constructs the compiler sees as
    corresponding tokens (if ..else, ...)

    The automated generation of such templates eg. a list of
    possiblities arises and I use the lasso-Function of the
    mouse, and the [Ctrl]+left mouse button to collect what i
    need as statement.

    That would be a nice feater fo input, and would also
    generate the data needed for folding.

    If there are more possiblities to fold or unfold:
    doubleclick unfolds all, right click let you chouse how many
    layers or sections you want to unfold:
    sample:
    if( cond1 ) {
    for( @array ) {
    if( great_enough ) {
    print
    }
    }
    }

    this folded:
    if (cond1) [..]

    unfolding 1 layer:
    if( cond1 ) {
    for( @array ) [..]
    }

    and so on.

    with regards
    Thomas

    (I just started learning java, such a task is too hard for
    me - in the moment ;-)

     
  • Logged In: NO

    Voting for bracket folding. If the programmer has added
    block brackets, then they've indicated manually that a chunk
    of code is a candidate for collapse. This would be a
    godsend for nastily branching logic trees.

    -=Brookepb

     
  • Kevin Benton
    Kevin Benton
    2007-06-20

    Logged In: YES
    user_id=856803
    Originator: NO

    Jochen, I agree, being able to fold more than subroutines would be helpful. Making it possible to fold any multi-line block would greatly increase the usability of collapsible code. :-) I too am considering leaving Komodo behind, though the jury is still out at the moment.

     
  • This would be a wonderful addition to an already great IDE. After using EPIC for months, the only thing that lacks is more bracket folding.

     

  • Anonymous
    2011-01-27

    Man this is an old request! I would also like if block code folding.

     

  • Anonymous
    2011-02-17

    Is anyone actively looking into this issue?

     
  • Jan Ploski
    Jan Ploski
    2011-02-17

    AFAIK, noone is actively looking into this issue, you're welcome to give it a try and submit patches.