Any way to group methods in Java/Eclipse?

前端 未结 6 2132
感动是毒
感动是毒 2021-02-12 15:11

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 e

6条回答
  •  北荒
    北荒 (楼主)
    2021-02-12 15:21

    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; the version appears to work against Eclipse 3.6 and 3.7 as well. It is also available in the Yoxos marketplace.

    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.

提交回复
热议问题