Adopt the latest rewrite snapshot
This commit is contained in:
@@ -48,6 +48,7 @@ import org.openrewrite.Validated;
|
||||
import org.openrewrite.config.DeclarativeRecipe;
|
||||
import org.openrewrite.config.RecipeDescriptor;
|
||||
import org.openrewrite.config.YamlResourceLoader;
|
||||
import org.openrewrite.internal.InMemoryLargeSourceSet;
|
||||
import org.openrewrite.java.JavaParser;
|
||||
import org.openrewrite.java.tree.J.CompilationUnit;
|
||||
import org.openrewrite.maven.MavenParser;
|
||||
@@ -427,8 +428,8 @@ public class RewriteRecipeRepository implements ApplicationContextAware {
|
||||
});
|
||||
List<SourceFile> sources = projectParser.parse(absoluteProjectDir, new InMemoryExecutionContext());
|
||||
progressTask.progressEvent("Computing changes...");
|
||||
RecipeRun reciperun = r.run(sources, new InMemoryExecutionContext(e -> log.error("Recipe execution failed", e)));
|
||||
List<Result> results = reciperun.getResults();
|
||||
RecipeRun reciperun = r.run(new InMemoryLargeSourceSet(sources), new InMemoryExecutionContext(e -> log.error("Recipe execution failed", e)));
|
||||
List<Result> results = reciperun.getChangeset().getAllResults();
|
||||
return ORDocUtils.createWorkspaceEdit(absoluteProjectDir, server.getTextDocumentService(), results);
|
||||
}
|
||||
|
||||
|
||||
@@ -27,14 +27,16 @@ import org.eclipse.lsp4j.TextDocumentEdit;
|
||||
import org.eclipse.lsp4j.TextDocumentIdentifier;
|
||||
import org.eclipse.lsp4j.WorkspaceEdit;
|
||||
import org.eclipse.lsp4j.jsonrpc.messages.Either;
|
||||
import org.openrewrite.InMemoryExecutionContext;
|
||||
import org.openrewrite.Parser.Input;
|
||||
import org.openrewrite.Recipe;
|
||||
import org.openrewrite.RecipeRun;
|
||||
import org.openrewrite.Result;
|
||||
import org.openrewrite.SourceFile;
|
||||
import org.openrewrite.config.DeclarativeRecipe;
|
||||
import org.openrewrite.internal.InMemoryLargeSourceSet;
|
||||
import org.openrewrite.internal.RecipeIntrospectionUtils;
|
||||
import org.openrewrite.java.JavaParser;
|
||||
import org.openrewrite.java.tree.J;
|
||||
import org.openrewrite.java.tree.J.CompilationUnit;
|
||||
import org.openrewrite.marker.Range;
|
||||
import org.slf4j.Logger;
|
||||
@@ -121,9 +123,10 @@ public class RewriteRefactorings implements CodeActionResolver, QuickfixHandler
|
||||
return null;
|
||||
}
|
||||
|
||||
private WorkspaceEdit applyRecipe(Recipe r, IJavaProject project, List<J.CompilationUnit> cus) {
|
||||
RecipeRun reciperun = r.run(cus);
|
||||
List<Result> results = reciperun.getResults();
|
||||
private WorkspaceEdit applyRecipe(Recipe r, IJavaProject project, List<CompilationUnit> cus) {
|
||||
List<SourceFile> sources = cus.stream().map(cu -> (SourceFile) cu).collect(Collectors.toList());
|
||||
RecipeRun reciperun = r.run(new InMemoryLargeSourceSet(sources), new InMemoryExecutionContext());
|
||||
List<Result> results = reciperun.getChangeset().getAllResults();
|
||||
List<Either<TextDocumentEdit, ResourceOperation>> edits = results.stream().filter(res -> res.getAfter() != null).map(res -> {
|
||||
URI docUri = res.getAfter().getSourcePath().isAbsolute() ? res.getAfter().getSourcePath().toUri() : project.getLocationUri().resolve(res.getAfter().getSourcePath().toString());
|
||||
TextDocument doc = server.getTextDocumentService().getLatestSnapshot(docUri.toASCIIString());
|
||||
|
||||
@@ -102,8 +102,8 @@ public class SpringBootUpgrade {
|
||||
|
||||
if (version.getMajor() == targetVersion.getMajor() && version.getMinor() == targetVersion.getMinor()) {
|
||||
// patch version upgrade - treat as pom versions only upgrade
|
||||
recipe.doNext(new UpgradeDependencyVersion("org.springframework.boot", "*", version.getMajor() + "." + version.getMinor() + ".x", null, null, null));
|
||||
recipe.doNext(new UpgradeParentVersion("org.springframework.boot", "spring-boot-starter-parent", version.getMajor() + "." + version.getMinor() + ".x", null, null));
|
||||
recipe.getRecipeList().add(new UpgradeDependencyVersion("org.springframework.boot", "*", version.getMajor() + "." + version.getMinor() + ".x", null, null, null));
|
||||
recipe.getRecipeList().add(new UpgradeParentVersion("org.springframework.boot", "spring-boot-starter-parent", version.getMajor() + "." + version.getMinor() + ".x", null, null));
|
||||
} else /*if (version.getMajor() == targetVersion.getMajor())*/ {
|
||||
List<String> recipedIds = createRecipeIdsChain(version.getMajor(), version.getMinor() + 1, targetVersion.getMajor(), targetVersion.getMinor(), versionsToRecipeId);
|
||||
if (!recipedIds.isEmpty()) {
|
||||
@@ -117,7 +117,7 @@ public class SpringBootUpgrade {
|
||||
// getRecipeFromId(recipedIds.get(i)).ifPresent(recipe::doNext);
|
||||
// }
|
||||
// }
|
||||
getRecipeFromId(recipeId).ifPresent(recipe::doNext);
|
||||
getRecipeFromId(recipeId).ifPresent(r -> recipe.getRecipeList().add(r));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user