2

How can I fold comment blocks inside method blocks to be folded (outlined), just like methods and regions, etc.?

sample_method_or_Class()
{
 /* I'd like to fold this
  * comment block
  */
}
/* The same way I can fold this one
 * outside the code block.
 */

Does Eclipse support functionality like Visual Studio does like (How do I fold code for comment blocks inside method blocks?) ?

  • In what language? – nitind Mar 02 '19 at 21:27
  • 1
    My particular case is with Eclipse Photon for Java, I had hoped however any solution would be common across Eclipse editions for different languages. – Miami_Programmer Mar 03 '19 at 00:27
  • That's not really how Eclipse is structured. It hosts different editors in the workbench according to a a few simple Java Interfaces, so the implementation details and feature set can and will vary by language. – nitind Mar 03 '19 at 04:47
  • Comments generally are before the member (type, method, or field) on which they are referring. In your example, however, nothing comes after the comments and therefore the comments are treated as commented out code that cannot be folded. Maybe you can describe why you want this? Maybe there is an alternative solution or workaround (e. g. Ctrl+Shift+Up/Down to go to previous/next member). – howlger Mar 03 '19 at 14:20
  • It is precisely commenting out blocks of code, for unit testing, incrementally varying the tests applied on each build, and preserving old implementations in the source until a new implementation is tested, rather than using version control for smaller personal projects. – Miami_Programmer Mar 03 '19 at 17:08
  • 1
    @Miami_Programmer I guess [this plug-in does what you want](https://github.com/stefaneidelloth/EclipseFolding) (see [here for details](https://stackoverflow.com/a/6947590/6505250)). – howlger Mar 04 '19 at 10:09

1 Answers1

1

There is no such support in Eclipse, unfortunately. There is a request for this though, reported in 2008 with only 10 votes, so I would not expect it implemented any time soon.

Mentions of an Eclipse folding plugin called Coffee Bytes can be found, but most links are broken. Looks like latest Eclipse versions are not supported and the project looks discontinued.

Update:

As indicated by howlger in the comment below, EclipseFolding plugin is alive and well. I've tested it now, installed it via Help / Install new software... / Add... using its update site:

After Eclipse restart I got little red squares indicating folding capability for both comment scenarios from the question:

enter image description here

gonadarian
  • 601
  • 7
  • 13
  • 2
    Here is a [fork of Coffee Bytes](https://github.com/stefaneidelloth/EclipseFolding). See my old comment above. – howlger Mar 06 '19 at 12:44