public class IteratorDeclaration extends IterableTraversal
myCollection, myIterable
Modifier and Type | Method and Description |
---|---|
PsiElement |
findOnlyIteratorRef(PsiExpression parent) |
static IteratorDeclaration |
fromLoop(PsiLoopStatement statement)
Creates
IteratorDeclaration if the loop follows one of these patterns: |
PsiLocalVariable |
getIterator() |
PsiVariable |
getNextElementVariable(PsiStatement statement) |
boolean |
isHasNextCall(PsiExpression condition) |
boolean |
isIteratorMethodCall(PsiElement candidate,
java.lang.String method) |
boolean |
isRemoveCall(PsiExpression candidate) |
getIterable, isCollection
public PsiLocalVariable getIterator()
public boolean isHasNextCall(PsiExpression condition)
public PsiElement findOnlyIteratorRef(PsiExpression parent)
public boolean isIteratorMethodCall(PsiElement candidate, java.lang.String method)
public boolean isRemoveCall(PsiExpression candidate)
isRemoveCall
in class IterableTraversal
candidate
- element to checkpublic PsiVariable getNextElementVariable(PsiStatement statement)
public static IteratorDeclaration fromLoop(PsiLoopStatement statement)
IteratorDeclaration
if the loop follows one of these patterns:
Iterator<T> it = iterable.iterator();
while(it.hasNext()) {
...
}
// And iterator is not reused after the loop
or
for(Iterator<T> it = iterable.iterator();it.hasNext();) {
...
}
statement
- loop to create the IteratorDeclaration
from