summaryrefslogtreecommitdiff
path: root/plugins/IntentionPowerPak/src/com/siyeh/ipp/forloop/IterableForEachLoopPredicate.java
diff options
context:
space:
mode:
authorJean-Baptiste Queru <jbq@google.com>2013-04-01 14:41:51 -0700
committerJean-Baptiste Queru <jbq@google.com>2013-04-01 14:41:51 -0700
commit2bd2b7c2623d4266384e890271869efc044aabff (patch)
tree0b31f50e55975b6354ed458314e17b4441bb4e17 /plugins/IntentionPowerPak/src/com/siyeh/ipp/forloop/IterableForEachLoopPredicate.java
parent1d526b16d476792ca7ce47616d55833115e8d6ab (diff)
downloadidea-2bd2b7c2623d4266384e890271869efc044aabff.tar.gz
Snapshot ee98b298267d0e09d2cd2f0731b6480a56dd48e7 from master branch of git://git.jetbrains.org/idea/community.git
Change-Id: I4515f72af131fdea9fc6905a4dc0fe9532409a81
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