开发者

In eclipse, can I customize the delegate methods code template?

In Java Code Style -> Code Templates there is a "Delegate Methods" option under comments but not under code. I tried changing the "Setter body" template because I wante开发者_Python百科d to automatically create a bunch of delegated setter methods. However, it didn't work for delegates.

So can I add a Delegate Methods entry to the code part of Code Templates or do I need to do something else?

I am using Eclipse Indigo on Win 7.


To create getter and setter methods, select the field's declaration and invoke Source -> Generate Getter and Setter.

If you use a name prefix or suffix be sure to specify this in the Code Style preference page (Window > Preferences > Java > Code Style).

Another way to create getters and setters is using content assist. Set the cursor in the type body between members and press Ctrl+Space to get the proposals that create a getter or setter method stub.


You can do that but you need to develop a plugin using eclipse's refactoring API provided by the Java Development Tools (JDT) as follows:

Anyone who supports a programming language in an Eclipse-based IDE will be  
asked sooner or later to offer automated refactorings - similar to what is  
provided by the Java Development Tools (JDT). Since the release of Eclipse 3.1, 
at least part of this task (which is by no means simple) is supported by a 
language neutral API:the Language Toolkit (LTK). But how is this API used?

Look at this one for a start.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜