eclipseinline-code

Generate inline class for method call parameter in Eclipse


When calling a method that expects an implementation of a specific class, how can I make eclipse write this boring piece of code for me?

In the following example, only the first line needs to be writen by a human:

o.call(
new MyFunction<List<String>>()
                {

                    @Override
                    public void call(List<String> lst) throws Exception {
   }
}

Solution

  • Type o.call(new MyF then Ctrl+Space and Eclipse should offer to complete the anonymous class skeleton for you. You might not even need the new MyF part, depending on how unambiguous the context is.