Skip to content

Commit 9035968

Browse files
fwcdDecodetalkers
authored andcommitted
Merge pull request #628 from AlexandrosAlexiou/refactor/dependecies/decompiler
refactor: use JetBrains release repository for FernFlower decompiler
2 parents b7bc79a + 6cf3dac commit 9035968

File tree

13 files changed

+114
-187
lines changed

13 files changed

+114
-187
lines changed

gradle/libs.versions.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ lsp4jVersion = "0.21.2"
44
exposedVersion = "0.37.3"
55
jmhVersion = "1.37"
66
guavaVersion = "33.4.0-jre"
7+
fernFlowerVersion = "243.22562.218"
78

89
[libraries]
910
org-jetbrains-kotlin-stdlib = { module = "org.jetbrains.kotlin:kotlin-stdlib", version.ref = "kotlinVersion" }
@@ -28,7 +29,7 @@ org-jetbrains-exposed-core = { module = "org.jetbrains.exposed:exposed-core", ve
2829
org-jetbrains-exposed-dao = { module = "org.jetbrains.exposed:exposed-dao", version.ref = "exposedVersion" }
2930
org-jetbrains-exposed-jdbc = { module = "org.jetbrains.exposed:exposed-jdbc", version.ref = "exposedVersion" }
3031

31-
org-jetbrains-fernflower = { module = "org.jetbrains:fernflower", version = "1.0" }
32+
com-jetbrains-intellij-java-decompiler = { module = "com.jetbrains.intellij.java:java-decompiler-engine", version.ref = "fernFlowerVersion" }
3233

3334
com-github-fwcd-ktfmt = { module = "com.github.fwcd.ktfmt:ktfmt", version = "b5d31d1" }
3435

platform/build.gradle.kts

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ dependencies {
1515
api(libs.org.jetbrains.kotlin.sam.with.receiver.compiler.plugin)
1616
api(libs.org.jetbrains.kotlin.reflect)
1717
api(libs.org.jetbrains.kotlin.jvm)
18-
api(libs.org.jetbrains.fernflower)
18+
api(libs.com.jetbrains.intellij.java.decompiler)
1919
api(libs.org.jetbrains.exposed.core)
2020
api(libs.org.jetbrains.exposed.dao)
2121
api(libs.org.jetbrains.exposed.jdbc)

server/build.gradle.kts

+10-10
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ plugins {
99
id("kotlin-language-server.kotlin-conventions")
1010
}
1111

12+
val serverDebugPort = 4000
1213
val debugPort = 8000
13-
val debugArgs = "-agentlib:jdwp=transport=dt_socket,server=y,address=8000,suspend=n,quiet=y"
14+
val debugArgs = "-agentlib:jdwp=transport=dt_socket,server=y,address=$debugPort,suspend=n,quiet=y"
1415

1516
val serverMainClassName = "org.javacs.kt.MainKt"
1617
val applicationName = "kotlin-language-server"
@@ -19,16 +20,13 @@ application {
1920
mainClass.set(serverMainClassName)
2021
description = "Code completions, diagnostics and more for Kotlin"
2122
applicationDefaultJvmArgs = listOf("-DkotlinLanguageServer.version=$version")
22-
applicationDistribution.into("bin") {
23-
filePermissions { unix("755".toInt(radix = 8)) }
24-
}
23+
applicationDistribution.into("bin") { filePermissions { unix("755".toInt(radix = 8)) } }
2524
}
2625

2726
repositories {
2827
maven(url = "https://repo.gradle.org/gradle/libs-releases")
29-
maven { url = uri("$projectDir/lib") }
30-
maven(uri("$projectDir/lib"))
3128
maven("https://jitpack.io")
29+
maven(url = "https://www.jetbrains.com/intellij-repository/releases")
3230
mavenCentral()
3331
}
3432

@@ -48,7 +46,7 @@ dependencies {
4846
implementation(kotlin("scripting-jvm-host-unshaded"))
4947
implementation(kotlin("sam-with-receiver-compiler-plugin"))
5048
implementation(kotlin("reflect"))
51-
implementation(libs.org.jetbrains.fernflower)
49+
implementation(libs.com.jetbrains.intellij.java.decompiler)
5250
implementation(libs.org.jetbrains.exposed.core)
5351
implementation(libs.org.jetbrains.exposed.dao)
5452
implementation(libs.org.jetbrains.exposed.jdbc)
@@ -79,9 +77,9 @@ tasks.register<Exec>("fixFilePermissions") {
7977

8078
onlyIf { !System.getProperty("os.name").lowercase().contains("windows") }
8179
commandLine(
82-
"chmod",
83-
"+x",
84-
"${tasks.installDist.get().destinationDir}/bin/kotlin-language-server"
80+
"chmod",
81+
"+x",
82+
"${tasks.installDist.get().destinationDir}/bin/kotlin-language-server",
8583
)
8684
}
8785

@@ -91,6 +89,8 @@ tasks.register<JavaExec>("debugRun") {
9189
standardInput = System.`in`
9290

9391
jvmArgs(debugArgs)
92+
args(listOf("--tcpServerPort", serverDebugPort, "--level", "trace", "--tcpDebug"))
93+
9494
doLast { println("Using debug port $debugPort") }
9595
}
9696

server/lib/fernflower-license.txt

-11
This file was deleted.

server/lib/gradle-kotlin-dsl-tooling-models-0.11.0-license.txt

-85
This file was deleted.
Binary file not shown.

server/lib/org/jetbrains/fernflower/1.0/fernflower-1.0.pom

-19
This file was deleted.

server/src/main/kotlin/org/javacs/kt/KotlinLanguageServer.kt

+6-3
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,10 @@ import java.util.concurrent.CompletableFuture
2323
import java.util.concurrent.CompletableFuture.completedFuture
2424

2525
class KotlinLanguageServer(
26-
val config: Configuration = Configuration()
26+
val config: Configuration = Configuration(),
27+
private val tcpDebug: Boolean = false
2728
) : LanguageServer, LanguageClientAware, Closeable {
28-
val databaseService = DatabaseService()
29+
private val databaseService = DatabaseService()
2930
val classPath = CompilerClassPath(config.compiler, config.scripts, config.codegen, databaseService)
3031

3132
private val tempDirectory = TemporaryDirectory()
@@ -56,7 +57,9 @@ class KotlinLanguageServer(
5657

5758
override fun connect(client: LanguageClient) {
5859
this.client = client
59-
connectLoggingBackend()
60+
if (!tcpDebug) {
61+
connectLoggingBackend()
62+
}
6063

6164
workspaces.connect(client)
6265
textDocuments.connect(client)

server/src/main/kotlin/org/javacs/kt/Main.kt

+10-3
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,27 @@ import org.eclipse.lsp4j.launch.LSPLauncher
77
import org.javacs.kt.util.ExitingInputStream
88
import org.javacs.kt.util.tcpStartServer
99
import org.javacs.kt.util.tcpConnectToClient
10-
1110
class Args {
1211
/*
1312
* The language server can currently be launched in three modes:
1413
* - Stdio, in which case no argument should be specified (used by default)
1514
* - TCP Server, in which case the client has to connect to the specified tcpServerPort (used by the Docker image)
1615
* - TCP Client, in which case the server will connect to the specified tcpClientPort/tcpClientHost (optionally used by VSCode)
1716
*/
18-
1917
@Parameter(names = ["--tcpServerPort", "-sp"])
2018
var tcpServerPort: Int? = null
19+
2120
@Parameter(names = ["--tcpClientPort", "-p"])
2221
var tcpClientPort: Int? = null
22+
2323
@Parameter(names = ["--tcpClientHost", "-h"])
2424
var tcpClientHost: String = "localhost"
25+
26+
@Parameter(names = ["--level"])
27+
var logLevel: String = "info"
28+
29+
@Parameter(names = ["--tcpDebug"])
30+
var tcpDebug: Boolean = false
2531
}
2632

2733
fun main(argv: Array<String>) {
@@ -39,7 +45,8 @@ fun main(argv: Array<String>) {
3945
tcpStartServer(it)
4046
} ?: Pair(System.`in`, System.out)
4147

42-
val server = KotlinLanguageServer()
48+
LOG.setLogLevel(args.logLevel)
49+
val server = KotlinLanguageServer(tcpDebug = args.tcpDebug)
4350
val threads = Executors.newSingleThreadExecutor { Thread(it, "client") }
4451
val launcher = LSPLauncher.createServerLauncher(server, ExitingInputStream(inStream), outStream, threads) { it }
4552

server/src/main/kotlin/org/javacs/kt/externalsources/ClassContentProvider.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class ClassContentProvider(
2121
private val cp: CompilerClassPath,
2222
private val tempDir: TemporaryDirectory,
2323
private val sourceArchiveProvider: SourceArchiveProvider,
24-
private val decompiler: Decompiler = FernflowerDecompiler()
24+
private val decompiler: Decompiler = FernFlowerDecompiler()
2525
) {
2626
/** Maps recently used (source-)KLS-URIs to their source contents (e.g. decompiled code) and the file extension. */
2727
private val cachedContents = object : LinkedHashMap<String, Pair<String, String>>() {

0 commit comments

Comments
 (0)