Questions tagged [eclipse-templates]
23 questions
7
votes
1 answer
Writing eclipse templates
I am writing django templates in Eclipse->prefrences->templates, to autocomplete DJango templates. I wrote this
{% block ${cursor} %}
{% endblock %}
Now, when I request and do autocompletion, after typing {% the autocompletion is
{% {% block …

agiliq
- 7,518
- 14
- 54
- 74
5
votes
3 answers
Eclipse template for setter that calls firePropertyChange()
For MVC model classes, my setters look like:
enum BoundProperty {FIELD_NAME, ...}
private Type fieldName;
public setFieldName(Type newValue) {
Type oldValue = fieldName;
fieldName = newValue;
…

Richard Neish
- 8,414
- 4
- 39
- 69
5
votes
1 answer
How to automatically insert a class notation using eclipse templates?
Does anybody know how to insert a "@RunWith anotation" above the class signature, using eclipse templates?
Ex.:
@RunWith(Parameterized.class)
public class MyClassTest {
...
@Parameters
public static Collection
5
votes
1 answer
how to better use of eclipse code templates (PHP)?
One particular problem I was having was using ${word_selection} in an Eclipse PDT template.
I was recently trying to use some code templates with Eclipse PDT 2.1 to speed up some common tasks. We use a lot of getters/setters, so I wrote the…

pocketfullofcheese
- 8,427
- 9
- 41
- 57
5
votes
2 answers
Customize Try/Catch code template based on exception
Does anyone know if there is a way to generate different code in the catch block automatically depending on the exception?
The Eclipse function 'Surround with try/catch' generates a try/catch block which just includes dumping a stack trace.
I'm…

TheSporkboy
- 1,759
- 1
- 13
- 13
4
votes
1 answer
Foreach assist using class-variables?
If i use the fore-each-template for the following values using
foreCtrl+SpaceEnterEnter in line 5
foreCtrl+SpaceEnterTabTabDownEnter in line 8
foreCtrl+SpaceEnterTabTabDownDownEnter in line 11
the following code will be produced (by Eclipse…

Grim
- 1,938
- 10
- 56
- 123
4
votes
0 answers
Change Eclipse Code Template Variable Navigation Order
I have an Eclipse code template, say that:
${type} ${name} = ${cursor}
So, generated code will be:
As you see, after code generation variable type is selected, but I want name to be selected first:
It may seem a stupid question in this case, but…

mmdemirbas
- 9,060
- 5
- 45
- 53
4
votes
1 answer
Eclipse anonymous inner type template
When I enter an inner type using fast complete feature of eclipse, it uses some template to generate it.
What I get is seen at left side, what I want is shown at right side of picture.
What I want is to remove empty line and auto-generated method…

guness
- 6,336
- 7
- 59
- 88
4
votes
2 answers
Eclipse template variable for getter and setter
I have a small question. I'm trying to create templates for getters for my variables inside of Eclipse. What I want to do in my getter method is to check if the variable is null or not. If it is null I want to assign a value to it. However the…
user793623
3
votes
0 answers
Eclipse Template Default Value with Dot
I want to have a default value in a String with a dot. I can't save my template when I put in the dot, though. Is it possible to get the dot into the string?
System.out.println("${related.string}");
So I want to have related.string as one string,…

Loki
- 4,065
- 4
- 29
- 51
3
votes
0 answers
eclipse template variable manipulation
Is there any way to manipulate the value of variables in Eclipse templates?
For example, in the following template code:
public class ${file} extends Activity
{
@Override
protected void onCreate(Bundle savedInstanceState)
{
…

Steve Waring
- 2,882
- 2
- 32
- 37
2
votes
1 answer
How to add correct indentation to code from Eclipse templates
I'm trying to generate a template that adds a List to a Javadoc. My current template (name ul) is:
- ${cursor}

Edward
- 4,453
- 8
- 44
- 82
2
votes
0 answers
How can I write an eclipse template that lists all the fields in a class?
Is there a way I can write a template to generate constructor copy method:
public MyClass(SomeOtherClassWithSameInterface i) {
a = i.getA();
b = i.getB();
}
Honestly, it doesn't have to be perfect. For each field I just want to generate:
…

hba
- 7,406
- 10
- 63
- 105
1
vote
0 answers
Eclipse Java Template: Nested variable in :import
I want to develop an Eclipse Java Template that is importing a Class, which name is derived from the current Class. ${enclosing_type} gives me the Class where my cursor is positioned in, lets assume the Qualified Name com.example.CurrentClass.…

notes-jj
- 1,437
- 1
- 20
- 33
1
vote
0 answers
How to get function name and function arguments in JS eclipse template?
I have been trying to generate customised comments for JavaScript code in eclipse. For that I am using templates. I want to get following function name and arguments inside my comments.
Here is my template code:
/** @method…

UserABC
- 49
- 3