Search for implicit usages of Iterable.iterator() in for-each loop declarations

I have seen that the otherwise fantastic Find Usages in IntelliJ  does not find usages of a class that implements Iterable, and is used in a for-each style loop.

e.g

class IterateMe implements Iterable {
  public Iterator iterator() {
    retur new Iterator(){...}
  }
}


and used like this:

...
IterateMe iterMe = ...
for (Object o : iterMe) {
   ...
}


This for loop is not listed as a usage in my search result.

Anyone got any ideas on this one, or does it quialify as a bug?

Regards,
Olve

2 comments
Comment actions Permalink

Hello Olve,

For performance reasons, our Find Usages functionality doesn't look for implicit
calls, such as implicit calls to toString() or, in this case, iterator().
You may consider it a bug, but we don't currently have any plans to change
this behavior.

I have seen that the otherwise fantastic Find Usages in IntelliJ
does not find usages of a class that implements Iterable, and is used
in a for-each style loop.

e.g

 Iterable {
> public Iterator iterator() {
> retur new Iterator(){...}
> }
> }]]>

and used like this:

 IterateMe iterMe = ...
> for (Object o : iterMe) {
> ...
> }]]>

This for loop is not listed as a usage in my search result.

Anyone got any ideas on this one, or does it quialify as a bug?


--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"


0
Comment actions Permalink

Ok, too bad. I just wondered, if you have no plans then it is not a bug :-)

Imho it should be a feature, if it is very slow, make it a(nother) check-box in the search field.

Is it possible to find these things in the structural search? I am not very familiar with that part of IntelliJ.

Best regards,
Olve

0

Please sign in to leave a comment.