views:

124

answers:

4

I would like to be able to group similar methods and have them appear in my Outline view in Eclipse. This makes navigating large swaths of code a little easier on the eye, and easier to find methods you need. In Objective-C there was a pragma mark command that you could set.

Anything like that for java/eclipse?

+2  A: 

As to your original question, I believe that is not possible with Java/Eclipse.

However, if you have a group of similar methods that you need to distinguish from another group of methods within the same class, why not create a new class with the group of similar methods?

JG
i mean for methods inside of a class. sometimes a class can have a lot of methods.
Sheehan Alam
That sounds like the "Extract class" refactoring. http://www.refactoring.com/catalog/extractClass.html is the best hit I could find quickly but google "extract class" and I'm sure you'll find more.
MatrixFrog
In many cases it does not mean it should be refacotored out. For example, getters/setters are a category, event handling, actions, and more.
zvikico
+1  A: 

If you mean group by name, click the button 'Sort' on 'Outline view'.

Moreover, there are some filters in the view to 'hide static', 'hide non-public'...

卢声远 Shengyuan Lu
+3  A: 

I use the Coffee Bytes plugin for code folding, specifically configuring it for folding code that has start and end tags.

Although the plugin is not downloadable off the page listed on the Google Code page, it has been recompiled against Eclipse 3.5 and made available elsewhere.

I use the following notation to group getters and setters of properties along with declaration of the property, although the same notation could be extended for your use.

// {{ Id
private String id;

public String getId() {
    return id;
}

public void setId(final String id) {
    this.id = id;
}
// }}

Configuration of the same needs to be done by setting appropriate preference in the code folding section available via Windows > Preferences > Java > Editor > Folding. Remember to choose Coffee Bytes Java Folding, and enable support for User Defined Regions.

Although the support for grouping/folding is restricted to the editor, the natural order of the methods within the fold can be retain in the outline view. I'm afraid that I'm unaware of any grouping capabilities beyond this plug-in.

Vineet Reynolds
+2  A: 

I really miss it from the days of Smalltalk.

The best way to denote these categories would be adding annotations to the code itself. You would then need to create a specialized outline view which uses these annotations. Sounds like a good Google Summer of Code project.

zvikico