Skip to content

Commit eae4b50

Browse files
authored
Merge branch 'openrewrite:main' into main
2 parents 5fbcf3a + 501f54e commit eae4b50

61 files changed

Lines changed: 1534 additions & 683 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.claude/settings.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,12 @@
3838
"mcp__idea__replace_specific_text",
3939
"mcp__idea__replace_text_in_file",
4040
"mcp__idea__search_in_files_by_text",
41-
"mcp__idea__search_in_files_content"
41+
"mcp__idea__search_in_files_content",
42+
"Bash(../../gradlew dependencies --configuration runtimeClasspath)",
43+
"Bash(../../gradlew dependencies --configuration implementation)",
44+
"Bash(../../gradlew dependencies)",
45+
"Bash(../../gradlew dependencies --configuration compileClasspath)"
4246
],
4347
"deny": []
4448
}
45-
}
49+
}

rewrite-core/src/main/java/org/openrewrite/internal/ListUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ public static <T> List<T> insert(@Nullable List<T> ls, @Nullable T t, int index)
265265
* For backwards compatibility; prefer {@link #map(List, Function)}.
266266
*/
267267
@Contract("null, _ -> null; !null, _ -> !null")
268-
public static <T> @Nullable List<T> map(@Nullable List<T> ls, UnaryOperator<@Nullable T> map) {
268+
public static <T> @Nullable List<T> map(@Nullable List<T> ls, UnaryOperator<T> map) {
269269
return map(ls, (Function<T, T>) map);
270270
}
271271

rewrite-core/src/test/java/org/openrewrite/CursorTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import org.junit.jupiter.api.Test;
1919
import org.openrewrite.text.PlainText;
2020

21-
import java.nio.file.Paths;
21+
import java.nio.file.Path;
2222

2323
import static org.assertj.core.api.Assertions.assertThat;
2424

@@ -40,7 +40,7 @@ void peekMessages() {
4040
@Test
4141
void pollMessages() {
4242
var t = PlainText.builder()
43-
.sourcePath(Paths.get("test.txt"))
43+
.sourcePath(Path.of("test.txt"))
4444
.text("test")
4545
.build();
4646
var cursor = new Cursor(null, t);
@@ -57,7 +57,7 @@ void pollMessages() {
5757
@Test
5858
void pathPredicates() {
5959
var t = PlainText.builder()
60-
.sourcePath(Paths.get("test.txt"))
60+
.sourcePath(Path.of("test.txt"))
6161
.text("test")
6262
.build();
6363
var cursor = new Cursor(new Cursor(new Cursor(null, 1), t), 2);
@@ -67,7 +67,7 @@ void pathPredicates() {
6767
@Test
6868
void pathAsStreamPredicates() {
6969
var t = PlainText.builder()
70-
.sourcePath(Paths.get("test.txt"))
70+
.sourcePath(Path.of("test.txt"))
7171
.text("test")
7272
.build();
7373
var cursor = new Cursor(new Cursor(new Cursor(null, 1), t), 2);

rewrite-core/src/test/java/org/openrewrite/MoveFileTest.java

Lines changed: 49 additions & 49 deletions
Large diffs are not rendered by default.

rewrite-core/src/test/java/org/openrewrite/ParserTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import org.openrewrite.tree.ParsingExecutionContextView;
2323

2424
import java.nio.file.Path;
25-
import java.nio.file.Paths;
2625

2726
import static java.nio.charset.StandardCharsets.ISO_8859_1;
2827
import static org.assertj.core.api.Assertions.assertThat;
@@ -69,7 +68,7 @@ void printIdempotentDiffPrint() {
6968
DIFF HERE
7069
line 2
7170
""";
72-
Path path = Paths.get("1.txt");
71+
Path path = Path.of("1.txt");
7372
String expectedDiff = """
7473
--- a/1.txt
7574
+++ b/1.txt

rewrite-core/src/test/java/org/openrewrite/PathUtilsTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import org.junit.jupiter.api.Test;
1919

2020
import java.nio.file.Path;
21-
import java.nio.file.Paths;
2221

2322
import static org.assertj.core.api.Assertions.assertThat;
2423
import static org.openrewrite.PathUtils.matchesGlob;
@@ -140,6 +139,6 @@ void combinedTest() {
140139
}
141140

142141
private static Path path(String path) {
143-
return Paths.get(path);
142+
return Path.of(path);
144143
}
145144
}

rewrite-core/src/test/java/org/openrewrite/RecipeEstimatedEffortTest.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import org.openrewrite.text.*;
2929

3030
import java.nio.file.Path;
31-
import java.nio.file.Paths;
3231
import java.time.Duration;
3332
import java.util.Collection;
3433
import java.util.List;
@@ -224,29 +223,29 @@ public AtomicBoolean getInitialValue(ExecutionContext ctx) {
224223

225224
@Override
226225
public TreeVisitor<?, ExecutionContext> getScanner(AtomicBoolean shouldCreate) {
227-
return new CreateFileVisitor(Paths.get(relativeFileName), shouldCreate);
226+
return new CreateFileVisitor(Path.of(relativeFileName), shouldCreate);
228227
}
229228

230229
@Override
231230
public Collection<SourceFile> generate(AtomicBoolean shouldCreate, ExecutionContext ctx) {
232231
if (shouldCreate.get()) {
233232
return PlainTextParser.builder().build().parse(fileContents)
234-
.map(brandNewFile -> (SourceFile) brandNewFile.withSourcePath(Paths.get(relativeFileName)))
233+
.map(brandNewFile -> (SourceFile) brandNewFile.withSourcePath(Path.of(relativeFileName)))
235234
.collect(toList());
236235
}
237236
return emptyList();
238237
}
239238

240239
@Override
241240
public TreeVisitor<?, ExecutionContext> getVisitor(AtomicBoolean created) {
242-
Path path = Paths.get(relativeFileName);
241+
Path path = Path.of(relativeFileName);
243242
return new TreeVisitor<SourceFile, ExecutionContext>() {
244243
@Override
245244
public SourceFile visit(@Nullable Tree tree, ExecutionContext ctx) {
246245
SourceFile sourceFile = (SourceFile) requireNonNull(tree);
247246
if (Boolean.TRUE.equals(overwriteExisting) && path.equals(sourceFile.getSourcePath())) {
248-
if (sourceFile instanceof PlainText) {
249-
return ((PlainText) sourceFile).withText(fileContents);
247+
if (sourceFile instanceof PlainText text) {
248+
return text.withText(fileContents);
250249
}
251250
PlainText plainText = PlainText.builder()
252251
.id(sourceFile.getId())

rewrite-core/src/test/java/org/openrewrite/RecipeLifecycleTest.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
import java.net.URI;
3636
import java.nio.charset.Charset;
3737
import java.nio.file.Path;
38-
import java.nio.file.Paths;
3938
import java.util.List;
4039
import java.util.Properties;
4140
import java.util.UUID;
@@ -55,7 +54,7 @@ void generateFile() {
5554
rewriteRun(
5655
spec -> spec
5756
.recipe(toRecipe()
58-
.withGenerator(() -> List.of(PlainText.builder().sourcePath(Paths.get("test.txt")).text("test").build()))
57+
.withGenerator(() -> List.of(PlainText.builder().sourcePath(Path.of("test.txt")).text("test").build()))
5958
.withName("test.GeneratingRecipe")
6059
.withMaxCycles(1)
6160
)
@@ -323,7 +322,7 @@ void accurateReportingOfRecipesMakingChanges() {
323322
@Issue("https://github.com/openrewrite/rewrite/issues/389")
324323
@Test
325324
void sourceFilesAcceptOnlyApplicableVisitors() {
326-
var sources = List.of(new FooSource(), PlainText.builder().sourcePath(Paths.get("test.txt")).text("test").build());
325+
var sources = List.of(new FooSource(), PlainText.builder().sourcePath(Path.of("test.txt")).text("test").build());
327326
var fooVisitor = new FooVisitor<ExecutionContext>();
328327
var textVisitor = new PlainTextVisitor<ExecutionContext>();
329328
var ctx = new InMemoryExecutionContext();

rewrite-core/src/test/java/org/openrewrite/TreeVisitorTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import org.openrewrite.marker.Markers;
2121
import org.openrewrite.quark.Quark;
2222

23-
import java.nio.file.Paths;
23+
import java.nio.file.Path;
2424
import java.util.concurrent.atomic.AtomicInteger;
2525

2626
import static org.assertj.core.api.Assertions.assertThat;
@@ -30,7 +30,7 @@ class TreeVisitorTest {
3030

3131
@Test
3232
void scheduleAfterOnVisitWithCursor() {
33-
Quark quark = new Quark(Tree.randomId(), Paths.get("quark"), Markers.EMPTY, null, null);
33+
Quark quark = new Quark(Tree.randomId(), Path.of("quark"), Markers.EMPTY, null, null);
3434
AtomicInteger visited = new AtomicInteger(0);
3535
TreeVisitor<Tree, Integer> scheduled = new TreeVisitor<>() {
3636
@Override

rewrite-core/src/test/java/org/openrewrite/config/DeclarativeRecipeTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
import org.openrewrite.text.PlainTextVisitor;
2929

3030
import java.net.URI;
31-
import java.nio.file.Paths;
31+
import java.nio.file.Path;
3232
import java.util.List;
3333
import java.util.Map;
3434
import java.util.concurrent.atomic.AtomicInteger;
@@ -256,7 +256,7 @@ void yamlPreconditionWithScanningRecipe() {
256256
s -> {
257257
//noinspection DataFlowIssue
258258
assertThat(s.getAfter()).isNotNull();
259-
assertThat(s.getAfter().getSourcePath()).isEqualTo(Paths.get("test.txt"));
259+
assertThat(s.getAfter().getSourcePath()).isEqualTo(Path.of("test.txt"));
260260
}
261261
))
262262
.expectedCyclesThatMakeChanges(1),

0 commit comments

Comments
 (0)