summaryrefslogtreecommitdiff
path: root/plugins/IntentionPowerPak/src/com/siyeh/ipp/forloop/IterableForEachLoopPredicate.java
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/IntentionPowerPak/src/com/siyeh/ipp/forloop/IterableForEachLoopPredicate.java')
-rw-r--r--plugins/IntentionPowerPak/src/com/siyeh/ipp/forloop/IterableForEachLoopPredicate.java11
1 files changed, 7 insertions, 4 deletions
diff --git a/plugins/IntentionPowerPak/src/com/siyeh/ipp/forloop/IterableForEachLoopPredicate.java b/plugins/IntentionPowerPak/src/com/siyeh/ipp/forloop/IterableForEachLoopPredicate.java
index c9780104203c..e925b5c0ba67 100644
--- a/plugins/IntentionPowerPak/src/com/siyeh/ipp/forloop/IterableForEachLoopPredicate.java
+++ b/plugins/IntentionPowerPak/src/com/siyeh/ipp/forloop/IterableForEachLoopPredicate.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2006 Dave Griffith, Bas Leijdekkers
+ * Copyright 2003-2013 Dave Griffith, Bas Leijdekkers
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,6 +17,7 @@ package com.siyeh.ipp.forloop;
import com.intellij.psi.*;
import com.intellij.psi.tree.IElementType;
+import com.intellij.psi.util.InheritanceUtil;
import com.siyeh.ipp.base.PsiElementPredicate;
import com.siyeh.ipp.psiutils.ErrorUtil;
@@ -35,13 +36,15 @@ class IterableForEachLoopPredicate implements PsiElementPredicate {
if (!(parent instanceof PsiForeachStatement)) {
return false;
}
- final PsiForeachStatement foreachStatement =
- (PsiForeachStatement)parent;
+ final PsiForeachStatement foreachStatement = (PsiForeachStatement)parent;
final PsiExpression iteratedValue = foreachStatement.getIteratedValue();
if (iteratedValue == null) {
return false;
}
final PsiType type = iteratedValue.getType();
- return type instanceof PsiClassType && !ErrorUtil.containsError(parent);
+ if (!InheritanceUtil.isInheritor(type, CommonClassNames.JAVA_LANG_ITERABLE)) {
+ return false;
+ }
+ return !ErrorUtil.containsError(foreachStatement);
}
} \ No newline at end of file