Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright 2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.openrewrite.scheduling;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.experimental.FieldDefaults;
import org.jspecify.annotations.Nullable;
import org.openrewrite.*;
import org.openrewrite.internal.ExceptionUtils;
import org.openrewrite.internal.FindRecipeRunException;
import org.openrewrite.internal.RecipeRunException;
import org.openrewrite.marker.Generated;
import org.openrewrite.marker.RecipesThatMadeChanges;
import org.openrewrite.table.RecipeRunStats;
import org.openrewrite.table.SourcesFileErrors;
import org.openrewrite.table.SourcesFileResults;
import java.time.Duration;
import java.util.*;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.BiFunction;
import java.util.function.UnaryOperator;
import static java.util.Collections.unmodifiableList;
import static java.util.Objects.requireNonNull;
import static org.openrewrite.Recipe.PANIC;
@RequiredArgsConstructor
@FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE)
public class RecipeRunCycle {
/**
* The root recipe that is running, which may contain a recipe list which will
* also be iterated as part of this cycle.
*/
Recipe recipe;
/**
* The current cycle in the range [1, maxCycles].
*/
@Getter
int cycle;
Cursor rootCursor;
WatchableExecutionContext ctx;
RecipeRunStats recipeRunStats;
SourcesFileResults sourcesFileResults;
SourcesFileErrors errorsTable;
BiFunction, LSS> sourceSetEditor;
RecipeStack allRecipeStack = new RecipeStack();
long cycleStartTime = System.nanoTime();
AtomicBoolean thrownErrorOnTimeout = new AtomicBoolean();
@Getter
Set madeChangesInThisCycle = Collections.newSetFromMap(new IdentityHashMap<>());
public int getRecipePosition() {
return allRecipeStack.getRecipePosition();
}
public LSS scanSources(LSS sourceSet) {
return sourceSetEditor.apply(sourceSet, sourceFile ->
allRecipeStack.reduce(sourceSet, recipe, ctx, (source, recipeStack) -> {
Recipe recipe = recipeStack.peek();
if (source == null) {
return null;
}
SourceFile after = source;
if (recipe instanceof ScanningRecipe) {
try {
//noinspection unchecked
ScanningRecipe