2
votes

I have been researching about how to create my own Eclipse's editor template or customize code template to fit my need but to no avail.

Here is my requirement:

I need to have to this kind of script.

${class} ${classname:newName(class)} = new ${class}();
${classname}.toString();

So when I try to use use this. I can automatically generate the code below just by typing "MyClass" to the ${class} part of the code

MyClass myClass = new MyClass();
myClass.toString();

But just by using that script. "myClass" cannot be automatically generated when I input the class name "MyClass"

So for example, I will have

MyClass classname = new MyClass();
classname.toString();

I have found these resources, but it didn't help me. Can anyone point me to the right direction as I can't seem to find a solution for this problem.

http://help.eclipse.org/luna/index.jsp?topic=%2Forg.eclipse.jdt.doc.user%2Freference%2Fpreferences%2Fjava%2Fcodestyle%2Fref-preferences-code-templates.htm

Can you define your own template variables in Eclipse

Is there a Eclipse template variable for short version of enclosing type name

OR, is there a way to create my own Eclipse's "Generate Getters and Setters..",

which can be achieved my right clicking on any eclipse source file -> Source -> "Generate Getters and Setters"

1

1 Answers

0
votes

This is the best I've found so far: https://marketplace.eclipse.org/content/fast-code-eclipse-plugin

It does exactly what I want, but it lacks polish and documentation. I've also had it crash on me to the point where I needed to reinstall it.

But it's still the best I've found so far.