Bug 70617 - [projection] Generic code folding
Summary: [projection] Generic code folding
Status: CLOSED DUPLICATE of bug 512956
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 3.0   Edit
Hardware: All All
: P3 enhancement with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: Platform-Text-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 111304 (view as bug list)
Depends on:
Blocks:
 
Reported: 2004-07-22 10:02 EDT by Robert McIntosh CLA
Modified: 2017-03-22 12:33 EDT (History)
9 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Robert McIntosh CLA 2004-07-22 10:02:39 EDT
The addition of code folding for Java code is a nice welcome, but seems too
specific. It would be really nice if the folding was much like JEdit's, where it
is indention based and therefore the folding works with ANY text file that has
indentions. This is especially useful for large XML/HTML/JSP files, and allows
unlimited nesting of folds. 

The Java side keeps requesting folding of code blocks such as if/then, loops,
etc. and by convention, these are indented in the code so therefore it would be
covered by a generic indention based folding solution. To this day I still use
JEdit to work with XML configuration files only because of its folding capabilities.
Comment 1 Brian CLA 2005-05-09 13:37:58 EDT
(In reply to comment #0)

> It would be really nice if the folding was much like JEdit's, where it
> is indention based and therefore the folding works with ANY text file that has
> indentions.

or how about some way to specify a token to maybe "hint" where to fold the line
at.  For example maybe the "{" character could be used, so that lines like:

if( somereallylongname || someotherreallylongname ||
<tab character right here>someotherreallylongname ||somelastname){

would show the whole expression.  This would work well also for coding blocks
also like alot of bsd related source code has in it such as:

static unsigned int
somefunction(int somevariable, float someothervar){
  code....
  code....
}

Comment 2 Morten CLA 2005-09-19 08:01:34 EDT
I've been working with generics for some time now and all the type specification
seems to make for some very long and less readable lines.

Think it would be nice to have the specifications automatically folded, so that:

Map<Integer,Collection<String>> map;

would automatically be:

Map<...> map;

with some possibility of unfolding the specification within the line. 
Comment 3 Dani Megert CLA 2005-10-03 06:02:53 EDT
*** Bug 111304 has been marked as a duplicate of this bug. ***
Comment 4 James Neethling CLA 2005-10-11 05:49:48 EDT
(In reply to comment #3)
> *** Bug 111304 has been marked as a duplicate of this bug. ***

Even more generic than Robert's suggestion and related to the report in 111304,
we should allow for the user to 'fold' any highlighted block of text.

It should be easy to implement something along the lines of 
1. Select text
2. Right-click->fold (OR Right-click->source->fold)



Comment 5 Thomas Timbul CLA 2008-08-23 10:21:22 EDT
I think it may be worth leaving some ability for users to decide for themselves. Having some specific rules for particular types of code *can* help.

I would for example quite like to see more folding options in Java code, e.g. 'fold annotations' so that I can have everything folded to start with, but annotations always showing.

Of course having indentation on (configurable) tokens like '{' would address this problem for my particular case, but what if another user prefers annotations folded away? How would he configure an exception for

@Something
private String field;

@SomethingElse
public void doStuff() {
 ...
}

(i.e. what if you DO want that folded?)

Another target for folding could be multiline comments that use single line commenting, e.g. '//' in Java, or '--' in SQL.

So to me it seems reasonable to have a fairly generic mechanism as already suggested above, but maybe with extension points to be able to include out of the box foldings in plugins.
Comment 6 Angelo ZERR CLA 2016-04-07 08:03:04 EDT
VSCode uses this idea of indentation to indent any code (JSON, TypeScript file, etc) and that's why it is so fast.

I have implemented a generic reconclier which supports folding with indentation. If you are interested tell me and I could create a PR with my class.

Regard's Angelo
Comment 7 Mickael Istria CLA 2017-03-09 03:43:44 EST
(In reply to Angelo ZERR from comment #6)
> I have implemented a generic reconclier which supports folding with
> indentation. If you are interested tell me and I could create a PR with my
> class.

Yes please!
Comment 8 Mickael Istria CLA 2017-03-09 06:20:46 EST
@Angelo: do you think you could contribute it soon enough (within the next month) to have it in Platform/Text as internal code so other Platform/Text bundle (such as generic editor) could use it? Then we could turn it into an API in Photon if need be.
Comment 9 Angelo ZERR CLA 2017-03-09 07:35:22 EST
> @Angelo: do you think you could contribute it soon enough (within the next month) to have it in Platform/Text as internal code so other Platform/Text bundle (such as generic editor) could use it?

@Mickael with pleasure:) I will try do that, just find time.
Comment 10 Dani Megert CLA 2017-03-10 09:17:06 EST
(In reply to Mickael Istria from comment #8)
> @Angelo: do you think you could contribute it soon enough (within the next
> month) to have it in Platform/Text as internal code so other Platform/Text
> bundle (such as generic editor) could use it?

The code would have to go into the generic editor project(s).
Comment 11 Mickael Istria CLA 2017-03-10 11:40:35 EST
(In reply to Dani Megert from comment #10)
> The code would have to go into the generic editor project(s).

Ok that's fine for now. If later we find it is valuable to other editors, we'll consider moving it as API in the org.eclipse.ui.editors project. But it's not something we want to do right now, so the generic editor plugin is a good host for this code.
Comment 12 Dani Megert CLA 2017-03-22 12:33:42 EDT
This should be provided for the generic editor(s).

*** This bug has been marked as a duplicate of bug 512956 ***