Eclipse API and Code Folding

| | bookmark | email | 18 comments
One of the my first open source projects I have worked on was Coffee-Bytes code folding plugin. It happened a long time ago and at some point the development has been discontinued. However, tonight, working on some very long sources I have remembered it and I said I should give it a new try. Unfortunately, once I enabled it no editors could been displayed. Checking the .log file I have found the reason: the folding code was broken with a NoSuchMethod exception. I have found in my archives the last version of the plugin and I thought I should check the API. To my surprise the API was still available (or at least reachable), but what made me post this entry is a feature added in Eclise 3.1: Access Restrictions, according to which when you create a plugin you can restrict others plugin access to its code. While I find the idea quite good (as it makes the API more clear), I have found out that almost everything related to java source code editors is restricted, and I am wondering why? I thought some other plugins would benefit from a clear API (for example AJDT), and now finding this makes me wonder about the reasons (I am quite sure there are good reasons). However, getting back to the points of this entry, you can read more about Access restrictions: here. Following the last advise specified at the above link:
But what if you really, really, really, really need to use the class? In that case, you can use it, but you need to be aware of what it means (four really's usually does it for me).
I have done some small changes to readapt the code and now I have again Coffee-Bytes code folding working on Eclipse 3.2. Just look at the picture to see how reach it is compaired with the default code folding offered by Eclipse: Reach Eclipse Code Folding It offers you folding for:
  • top level types
  • normal methods
  • constructors
  • getters and setters
  • main methods
  • inner types
  • static initializers
  • import statements
  • source headers
  • comment blocks
  • javadocs
and even User defined code folding: User defined code folding