I am new to Eclipse which I use primarily for Java. I have previously used IntelliJ Idea in which it is possible to select a variable which extends Iteratable (Collection, List
I typically create code like this by following these steps:
Call the function and use Ctrl-1 to create a local variable holding the return value:
List list = functionWhichReturnsList()
Type fore[Ctrl-space] to insert the for loop (since eclipse usually chooses the closest iterable when constructing the loop):
List list = functionWhichReturnsList()
for (TypeOfItemsInList item : list) {
}
Inline the local variable by putting the cursor on the list variable and typing Alt+Shift+I:
for (TypeOfItemsInList item : functionWhichReturnsList()) {
}
It's not optimal, but it works.