Eclipse-Postfix-Code-Completion icon indicating copy to clipboard operation
Eclipse-Postfix-Code-Completion copied to clipboard

.add templates?

Open vogella opened this issue 11 years ago • 1 comments

See example below, not sure if that would be a good fit for add

public static void main(String[] args) { List<Task> list = new ArrayList<Task>(); for (int i = 0; i < 20; i++) { new Task(i, "Test1", "Test2", Task.Status.ASSIGNED, 10).add[HERE I AM] } }

vogella avatar Nov 17 '14 21:11 vogella

Nice idea. Template looks like this:

${collection}.add(${i:inner_expression(java.lang.Object)});

Unfortunately, I don't know why the used collection variable (already implemented by JDT) is not resolving to list in this scenario. I have to do some debugging I guess. Anyway, it would be great if the existing implementation of the collection variable could be extended to allow the definition of the type of the proposed collections:

${:collection(exp)}.add(${exp:inner_expression(java.lang.Object)});

Then we could also guarantee an error-free state after the template is applied.

trylimits avatar Nov 17 '14 22:11 trylimits