How to automatically insert a class notation using eclipse templates?

Posted by João Paulo G. Piccinini on Stack Overflow See other posts from Stack Overflow or by João Paulo G. Piccinini
Published on 2010-04-19T14:05:35Z Indexed on 2010/04/20 1:53 UTC
Read the original article Hit count: 298

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<Object[]> parameters() {
        List<Object[]> list = new ArrayList<Object[]>();
        list.add(new Object[] { "mind!", "find!" });
        list.add(new Object[] { "misunderstood", "understood" });
        return list;
    }
...
}

__

Template:

// TODO: move this '@RunWith(Parameterized.class)' to class anotation
    @Parameters
    public static Collection<Object[]> parameters() {
        ${type:elemType(collection)}<Object[]> parametersList = new ${type:elemType(collection)}<Object[]>();
        ${cursor}// TODO: populate collection
        return parametersList;
    }

__ Thanks for the help!

© Stack Overflow or respective owner

Related posts about eclipse

Related posts about eclipse-templates