SimplifyForEachContext (@Nullable PsiMethodCallExpression call) { if (call == null) return null; PsiLambdaExpression lambda = extractLambdaFromForEach(call); if (lambda == null) return null; PsiElement lambdaBody = lambda.getBody(); ExistingStreamSource source = ExistingStreamSource.extractSource(call, lambda); if (source == null) return null; TerminalBlock terminalBlock = extractTerminalBlock(lambdaBody, source); if (terminalBlock == null) return null; PsiStatement mainStatement = source.getMainStatement(); BaseStreamApiMigration migration = StreamApiMigrationInspection.findMigration(mainStatement, lambdaBody, terminalBlock, true, true); if (migration instanceof ForEachMigration && STREAM_FOREACH_ORDERED.test(call)) { migration = new ForEachMigration(migration.isShouldWarn(), "forEachOrdered"); } return migration == null ? null : new SimplifyForEachContext(terminalBlock, mainStatement, lambdaBody, migration); }