Too much time when I am faced with the need to write sum / delete methods for lists:
public void addSomething(Something something){ somethings.add(something); } public void removeSomething(Something something){ somethings.remove(something); }
If I understood correctly, then Eclipse templates can support automatic completion ... for example, if I have:
Vector<Something> somethings=new Vector<Something>();
I would like the template to add this method to Auto-Complete from Eclipse and automatically complete the whole method:
public void addSomething(Something something){ somethings.add(something); }
when I type add + ( Ctrl + Space ) ...
Any idea how to accomplish something like this ... maybe give me some reading material pertaining to this type of subject.
** UPDATE **
Well, this is what I still have:
public final void add${type:elemType(collection)}(${type} ${varName:newName(type)}) { ${collection}.add(${varName}); }
Here is the problem though, if I type "add" + (Ctrl + Space):
At the class level, and the collection is declared as a field, I get an empty variable as a collection.
public final void addtype(type type) { collection.add(type); }
At the method level, and the collection is declared as a field, I get an empty variable as a collection.
public final void addtype(type type) { collection.add(type); }
At the method level, and the assembly reference is a local variable of the method, I get the correct syntax, but the add method is inside another method.
public void method(...) { public final void addSomething(Something something) { this.somethings.add(something); } }
What does it mean that I donβt get the link at the field level, how can I get it?
** UPDATE 2 **
This also gives the same result:
public final void add${type:elemType(collection)}(${type} ${varName:newName(type)}) { ${collection:field(java.util.Collection)}.add(${varName}); } public final void remove${type:elemType(collection)}(${type} ${varName:newName(type)}) { ${collection:field(java.util.Collection)}.remove(${varName}); }
Thanks,
Adam.