Skip to content

Commit 452e04b

Browse files
authored
Call user hook to inspect source file before validation and recipe execution (#5888)
As per #5128 (comment)
1 parent c35c026 commit 452e04b

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

rewrite-test/src/main/java/org/openrewrite/test/RewriteTest.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,10 @@ default void rewriteRun(Consumer<RecipeSpec> spec, SourceSpec<?>... sourceSpecs)
300300
}
301301
sourceFile = sourceFile.withMarkers(markers);
302302

303+
// Call user hook to inspect source file before validation and recipe execution
304+
//noinspection unchecked
305+
SourceFile mapped = ((UnaryOperator<SourceFile>) nextSpec.beforeRecipe).apply(sourceFile);
306+
303307
// Validate before source
304308
TypeValidation beforeValidations = TypeValidation.before(testMethodSpec, testClassSpec);
305309
nextSpec.validateSource.accept(sourceFile, beforeValidations);
@@ -334,8 +338,6 @@ default void rewriteRun(Consumer<RecipeSpec> spec, SourceSpec<?>... sourceSpecs)
334338
}
335339
}
336340

337-
//noinspection unchecked
338-
SourceFile mapped = ((UnaryOperator<SourceFile>) nextSpec.beforeRecipe).apply(sourceFile);
339341
specBySourceFile.put(mapped, nextSpec);
340342
}
341343
}

0 commit comments

Comments
 (0)