Skip to content

Commit

Permalink
Bump Kotlin to 2.0.0
Browse files Browse the repository at this point in the history
- Bump kotlin version to related gradle files
- Includes some code cleanup and improvements
  • Loading branch information
AlexandrosAlexiou committed Jun 2, 2024
1 parent bdba774 commit 700234f
Show file tree
Hide file tree
Showing 8 changed files with 329 additions and 329 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version=1.3.10
version=1.3.11
javaVersion=11
2 changes: 1 addition & 1 deletion platform/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ javaPlatform {
allowDependencies()
}

val kotlinVersion = "1.9.20"
val kotlinVersion = "2.0.0"
val exposedVersion = "0.37.3"
val lsp4jVersion = "0.21.2"

Expand Down
618 changes: 308 additions & 310 deletions server/src/main/kotlin/org/javacs/kt/compiler/Compiler.kt

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion server/src/test/kotlin/org/javacs/kt/OneFilePerformance.kt
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class OneFilePerformance {
}

internal fun compile(compile: Collection<KtFile>, sourcePath: Collection<KtFile>): BindingTraceContext {
val trace = CliBindingTrace()
val trace = CliBindingTrace(env.projectEnvironment.project)
val container = CompilerFixtures.createContainer(
env.project,
sourcePath,
Expand Down
2 changes: 2 additions & 0 deletions server/src/test/resources/additionalWorkspace/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package additionalWorkspace

plugins {
id 'org.jetbrains.kotlin.jvm' version "$kotlinVersion"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
kotlinVersion=1.9.20
kotlinVersion=2.0.0
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
package org.javacs.kt.classpath

import org.javacs.kt.LOG
import org.javacs.kt.util.findCommandOnPath
import org.javacs.kt.util.tryResolving
import java.io.File
import java.nio.file.Files
import java.nio.file.Path
import java.nio.file.Paths
import java.nio.file.attribute.BasicFileAttributes
import java.util.function.BiPredicate
import org.javacs.kt.util.tryResolving
import org.javacs.kt.util.findCommandOnPath
import org.javacs.kt.LOG
import java.nio.file.Paths

/** Backup classpath that find Kotlin in the user's Maven/Gradle home or kotlinc's libraries folder. */
object BackupClassPathResolver : ClassPathResolver {
override val resolverType: String = "Backup"
override val classpath: Set<ClassPathEntry> get() = findKotlinStdlib()?.let { setOf(it) }.orEmpty().map { ClassPathEntry(it, null) }.toSet()
}

fun findKotlinStdlib(): Path? =
findKotlinCliCompilerLibrary("kotlin-stdlib")
?: findLocalArtifact("org.jetbrains.kotlin", "kotlin-stdlib")
?: findAlternativeLibraryLocation("kotlin-stdlib")
fun findKotlinStdlib(): Path? {
return findKotlinCliCompilerLibrary("kotlin-stdlib")
?: findLocalArtifact("org.jetbrains.kotlin", "kotlin-stdlib")
?: findAlternativeLibraryLocation("kotlin-stdlib")
}

private fun findLocalArtifact(group: String, artifact: String) =
tryResolving("$artifact using Maven") { tryFindingLocalArtifactUsing(group, artifact, findLocalArtifactDirUsingMaven(group, artifact)) }
Expand Down Expand Up @@ -84,10 +85,11 @@ private fun Path.existsOrNull() =
if (Files.exists(this)) this else null

private fun findLocalArtifactDirUsingMaven(group: String, artifact: String) =
LocalArtifactDirectoryResolution(mavenRepository
?.resolve(group.replace('.', File.separatorChar))
?.resolve(artifact)
?.existsOrNull(), "Maven")
LocalArtifactDirectoryResolution(
mavenRepository
.resolve(group.replace('.', File.separatorChar))
.resolve(artifact)
.existsOrNull(), "Maven")

private fun findLocalArtifactDirUsingGradle(group: String, artifact: String) =
LocalArtifactDirectoryResolution(gradleCaches
Expand All @@ -109,7 +111,7 @@ private fun compareVersions(left: Path, right: Path): Int {
val leftVersion = extractVersion(left)
val rightVersion = extractVersion(right)

for (i in 0 until Math.min(leftVersion.size, rightVersion.size)) {
for (i in 0 until leftVersion.size.coerceAtMost(rightVersion.size)) {
val leftRev = leftVersion[i].reversed()
val rightRev = rightVersion[i].reversed()
val compare = leftRev.compareTo(rightRev)
Expand Down
2 changes: 0 additions & 2 deletions shared/src/main/kotlin/org/javacs/kt/util/Debouncer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@ package org.javacs.kt.util

import org.javacs.kt.LOG
import java.time.Duration
import java.util.function.Supplier
import java.util.concurrent.atomic.AtomicReference
import java.util.concurrent.ScheduledExecutorService
import java.util.concurrent.Executors
import java.util.concurrent.TimeUnit
import java.util.concurrent.CompletableFuture
import java.util.concurrent.Future

private var threadCount = 0
Expand Down

0 comments on commit 700234f

Please sign in to comment.