boolean (@NotNull PsiExpression expression) { if (!(expression.getParent() instanceof PsiForeachStatementBase parentForEach)) return false; PsiExpression iteratedValue = parentForEach.getIteratedValue(); if (iteratedValue != expression) return false; // Ignore if the type of the value which is being iterated over is not resolved yet PsiType iteratedValueType = iteratedValue.getType(); return iteratedValueType == null || !PsiTypesUtil.hasUnresolvedComponents(iteratedValueType); }