"Surround with..for each"
Just an idea the occured to me a few times, not sure how useful it would
be in practice.
---
FooBar[] = baz.getFooBar(param1, param2);
names
---
Ctrl-Alt-T -> "Surround with...for each".
The idea is that this "surround" template would be available when the current
selection is "iterable".
(Meaning array, or java.lang.Iterable]]>, or whatever foreach() accepts in
addition).
-tt
Please sign in to leave a comment.
Well, I can hardly imagine any situation where this 'Surround with...'
would be more helpful than the 'iter' live template.
Taras Tielkes wrote:
--
Martin Fuhrer
Fuhrer Engineering AG
http://www.fuhrer.com
I want this constantly. Sometimes I hit ctrlaltv, then "iter", then inline the variable. It just feels better than copying and pasting.
Hello Martin,
One situation (for me) is the following.
Let's assume I've got a "foo" object from somewhere.
Using regular completion I navigate to the collection property that I'm interested
in:
foo.getBar.getBazCollection()
At this point it know what I need, and it would be nice to wrap it with foreach.
I use "iter" alot of course, but when expression to be iterated over is more
complex this might be a nice alternative.
Let say I want to iterate the next expression.
FooService.getInstance(myContext).getBars()
Using regular "iter", I would likely need to use ClassName completion and
Smart Completion to write this expression - while the "iter" live template
is active.
Somtimes I "break" the live template by mistake, and I have to start over
again.
So in essence it would be like "iter", but using current selection as a "parameter".
-tt
I think you can create your own surround live template for this.
Add this to your .IntellijIdea70/config/templates/user.xml file:
I think you can do with your own live template.
Add this to /config/templates/user.xml: