Get formatted output from eclipse template variable

How can I make an eclipse java template that allows generating java code that eases the repeating part of registering code for a java method. Example:

Assume that the class description is like so:

class A{
    public static void methodName(String s, int i, Object o) {

Now, what I want is to make a template that does something somewhat like this:

"${enclosing_type}.${enclosing_method}(" + ${variable1} + ", " + ${variable2} + ", " + ${variable3} + ")"

Given the available Eclipse variables I know, the idea would probably be:

"${enclosing_type}.${enclosing_method}(" + ${enclosing_method_arguments(" + ", " + ")} + ")"

Where that argument would signal the glue to the join of each element of the enclosing_method_arguments. The result of the format would be:

"A.methodName(" + s + ", " + i + ", " + o + ")"

If there’s an even better alternative, I’m open for suggestions.
This is meant to be used with a piece of code that is executed a LOT,

Unfortunately, String.format() (and related) “solution” is not an option here due to the requirement above and due to other inherited requirements with what I’m working on. It must generate that code in that format no matter what, unfortunately.

I’m open to any plugins that allow that and, if eclipse doesn’t have it, I’m open to make a plugin myself… In case of me having to do a plugin please do show me the resources required to make it.

Source: eclipse

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.