Insomnia

Adding a template in Eclipse

After writing

SomeClass mock = Mockito.mock(SomeClass.class) ;
about a million times, I decided to see what Eclipse could do to help me out.

Templates are the key. Add a template like

${word_selection} mock${word_selection} = Mockito.mock(${word_selection}.class);

Then from the editor 1. Type the class name, 2. Select that text 3. Code Completion Assistant will show your template 4. Select it and the relevant code will wrap your selection.

This is still a little cumbersome for me. I haven’t found a way to do this without still having to click the mouse to select text, and scroll through the content assist (templates show at the bottom).

However, it’s a starting point.. hopefully I can clean up the technique some and make it even more efficient.