Package org.openrewrite
Interface LargeSourceSet
- All Known Implementing Classes:
InMemoryLargeSourceSet
public interface LargeSourceSet
A source set that may be too large to be materialized in memory.
It contains operations for filtering and mapping that are optimized
for large repositories, though the same operations work on small repositories.
A large source set must always track of its initial state to be
able to produce getChangeset()
from that initial state
through any number of transformations to some end state.
-
Method Summary
Modifier and TypeMethodDescriptiondefault void
afterCycle
(boolean lastCycle) Called byRecipeScheduler
at the conclusion of a scan/generate/edit cycle.default void
Deprecated.default void
beforeCycle
(boolean definitelyLastCycle) Called byRecipeScheduler
at the beginning of a scan/generate/edit cycle.edit
(UnaryOperator<SourceFile> map) Execute a transformation on all items.generate
(@Nullable Collection<? extends SourceFile> ls) Concatenate new items.@Nullable SourceFile
Get the original source file, before any edits.void
Maintain context about what recipe is performing an edit or generating code.
-
Method Details
-
beforeCycle
Deprecated.OverridebeforeCycle(boolean)
insteadCalled byRecipeScheduler
at the beginning of a scan/generate/edit cycle. -
beforeCycle
default void beforeCycle(boolean definitelyLastCycle) Called byRecipeScheduler
at the beginning of a scan/generate/edit cycle.- Parameters:
definitelyLastCycle
-true
if this is definitely the last cycle of a recipe; when called with a value offalse
the next call toafterCycle(boolean)
could still be called withtrue
. This depends on whether any of the recipes requested an additional cycle.
-
setRecipe
Maintain context about what recipe is performing an edit or generating code.- Parameters:
recipeStack
- A stack rooted at the currently operating recipe and extending up its containing recipes to top-level recipe that a developer is running directly.
-
edit
Execute a transformation on all items.- Parameters:
map
- A transformation on T- Returns:
- A new source set if the map function results in any changes, otherwise this source set is returned.
-
generate
Concatenate new items. Where possible, implementations should not iterate the entire source set in order to accomplish this, since the ordering ofSourceFile
is not significant.- Parameters:
ls
- The new item to insert- Returns:
- A new source set with the new item inserted.
-
afterCycle
default void afterCycle(boolean lastCycle) Called byRecipeScheduler
at the conclusion of a scan/generate/edit cycle. -
getChangeset
Changeset getChangeset()- Returns:
- The set of changes (encompassing adds, edits, and deletions) to the initial state.
-
getBefore
Get the original source file, before any edits. Returns null if it is not present.- Parameters:
sourcePath
- The path of the source file to retrieve.- Returns:
- The original source file. Null if not present.
-
beforeCycle(boolean)
instead