convert to streams: disable foreachOrdered for pure collections (without filter)

This commit is contained in:
Anna Kozlova
2016-02-09 12:41:01 +01:00
parent e3f5740e07
commit a3d842b104
@@ -132,10 +132,15 @@ public class StreamApiMigrationInspection extends BaseJavaBatchLocalInspectionTo
new ReplaceWithCollectCallFix("Replace with " + (addAll ? "addAll" : "collect")));
}
else if (REPLACE_TRIVIAL_FOREACH || !isTrivial(body, statement.getIterationParameter())) {
final List<LocalQuickFix> fixes = new ArrayList<LocalQuickFix>();
fixes.add(new ReplaceWithForeachCallFix("forEach"));
if (extractIfStatement(body) != null) {
//for .stream()
fixes.add(new ReplaceWithForeachCallFix("forEachOrdered"));
}
holder.registerProblem(iteratedValue, "Can be replaced with foreach call",
ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
new ReplaceWithForeachCallFix("forEach"),
new ReplaceWithForeachCallFix("forEachOrdered"));
ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
fixes.toArray(new LocalQuickFix[fixes.size()]));
}
}
}