Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions rewrite-core/src/main/java/org/openrewrite/Parser.java
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,10 @@ public Input(Path path, Supplier<InputStream> source) {
this(path, FileAttributes.fromPath(path), source, false);
}

public Input(Path path, Supplier<InputStream> source, boolean synthetic) {
this(path, FileAttributes.fromPath(path), source, synthetic);
}

public Input(Path path, @Nullable FileAttributes fileAttributes, Supplier<InputStream> source) {
this(path, fileAttributes, source, false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,8 @@ public J.MethodInvocation visitMethodInvocation(J.MethodInvocation method, Execu
("\n" +
"configurations.all {\n" +
" resolutionStrategy.eachDependency { details ->}\n" +
"}").getBytes(StandardCharsets.UTF_8)))
"}").getBytes(StandardCharsets.UTF_8)),
true)
), null, ctx)
.map(K.CompilationUnit.class::cast)
.map(k -> (J.Block) k.getStatements().get(0))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ private static Optional<JavaSourceFile> parseAsGradle(String snippet, boolean is
.computeIfAbsent(snippet, s -> GradleParser.builder().build().parseInputs(singleton(
new Parser.Input(
Paths.get("build.gradle" + (isKotlinDsl ? ".kts" : "")),
() -> new ByteArrayInputStream(snippet.getBytes(StandardCharsets.UTF_8))
() -> new ByteArrayInputStream(snippet.getBytes(StandardCharsets.UTF_8)),
true
)), null, ctx)
.findFirst()
.map(maybeCu -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ private J.MethodInvocation dependenciesDeclaration(ExecutionContext ctx) {
J.MethodInvocation dependencies;
ctx.putMessage(ExecutionContext.REQUIRE_PRINT_EQUALS_INPUT, false);
if (isKotlinDsl) {
dependencies = (J.MethodInvocation) ((J.Block) GRADLE_PARSER.parseInputs(singletonList(new GradleParser.Input(Paths.get("build.gradle.kts"), () -> new ByteArrayInputStream(template.getBytes(StandardCharsets.UTF_8)))), null, ctx)
dependencies = (J.MethodInvocation) ((J.Block) GRADLE_PARSER.parseInputs(singletonList(new GradleParser.Input(Paths.get("build.gradle.kts"), () -> new ByteArrayInputStream(template.getBytes(StandardCharsets.UTF_8)), true)), null, ctx)
.findFirst()
.map(K.CompilationUnit.class::cast)
.orElseThrow(() -> new IllegalArgumentException("Could not parse as Gradle"))
Expand All @@ -367,7 +367,7 @@ private J.MethodInvocation dependencyDeclaration(J.Block body, ExecutionContext
J.MethodInvocation dependency;
ctx.putMessage(ExecutionContext.REQUIRE_PRINT_EQUALS_INPUT, false);
if (isKotlinDsl) {
dependency = (J.MethodInvocation) ((J.Block) GRADLE_PARSER.parseInputs(singletonList(new GradleParser.Input(Paths.get("build.gradle.kts"), () -> new ByteArrayInputStream(template.getBytes(StandardCharsets.UTF_8)))), null, ctx)
dependency = (J.MethodInvocation) ((J.Block) GRADLE_PARSER.parseInputs(singletonList(new GradleParser.Input(Paths.get("build.gradle.kts"), () -> new ByteArrayInputStream(template.getBytes(StandardCharsets.UTF_8)), true)), null, ctx)
.findFirst()
.map(K.CompilationUnit.class::cast)
.orElseThrow(() -> new IllegalArgumentException("Could not parse as Gradle"))
Expand Down
6 changes: 3 additions & 3 deletions rewrite-kotlin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ plugins {
kotlin("jvm") version "2.2.21"
}

val kotlinVersion = "1.9.25"
val kotlinVersion = "2.2.21"

dependencies {
compileOnly(project(":rewrite-core"))
Expand Down Expand Up @@ -37,8 +37,8 @@ java {

tasks.withType<KotlinCompile>().configureEach {
compilerOptions {
apiVersion = KotlinVersion.KOTLIN_1_9
languageVersion = KotlinVersion.KOTLIN_1_9
apiVersion = KotlinVersion.KOTLIN_2_2
languageVersion = KotlinVersion.KOTLIN_2_2
jvmTarget.set(if (name.contains("Test")) JvmTarget.JVM_21 else JvmTarget.JVM_1_8)
}
}
Loading