Skip to content

Commit b5a976a

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 b5a976a

File tree

13 files changed

+98
-186
lines changed

13 files changed

+98
-186
lines changed

gradle/libs.versions.toml

Lines changed: 2 additions & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,13 @@ application {
1919
mainClass.set(serverMainClassName)
2020
description = "Code completions, diagnostics and more for Kotlin"
2121
applicationDefaultJvmArgs = listOf("-DkotlinLanguageServer.version=$version")
22-
applicationDistribution.into("bin") {
23-
filePermissions { unix("755".toInt(radix = 8)) }
24-
}
22+
applicationDistribution.into("bin") { filePermissions { unix("755".toInt(radix = 8)) } }
2523
}
2624

2725
repositories {
2826
maven(url = "https://repo.gradle.org/gradle/libs-releases")
29-
maven { url = uri("$projectDir/lib") }
30-
maven(uri("$projectDir/lib"))
3127
maven("https://jitpack.io")
28+
maven(url = "https://www.jetbrains.com/intellij-repository/releases")
3229
mavenCentral()
3330
}
3431

@@ -48,7 +45,7 @@ dependencies {
4845
implementation(kotlin("scripting-jvm-host-unshaded"))
4946
implementation(kotlin("sam-with-receiver-compiler-plugin"))
5047
implementation(kotlin("reflect"))
51-
implementation(libs.org.jetbrains.fernflower)
48+
implementation(libs.com.jetbrains.intellij.java.decompiler)
5249
implementation(libs.org.jetbrains.exposed.core)
5350
implementation(libs.org.jetbrains.exposed.dao)
5451
implementation(libs.org.jetbrains.exposed.jdbc)
@@ -79,9 +76,9 @@ tasks.register<Exec>("fixFilePermissions") {
7976

8077
onlyIf { !System.getProperty("os.name").lowercase().contains("windows") }
8178
commandLine(
82-
"chmod",
83-
"+x",
84-
"${tasks.installDist.get().destinationDir}/bin/kotlin-language-server"
79+
"chmod",
80+
"+x",
81+
"${tasks.installDist.get().destinationDir}/bin/kotlin-language-server",
8582
)
8683
}
8784

server/lib/fernflower-license.txt

Lines changed: 0 additions & 11 deletions
This file was deleted.

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

Lines changed: 0 additions & 85 deletions
This file was deleted.
Binary file not shown.

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

Lines changed: 0 additions & 19 deletions
This file was deleted.

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

Lines changed: 6 additions & 3 deletions
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

Lines changed: 12 additions & 3 deletions
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 = ["--tcpDebug"])
27+
var tcpDebug: Boolean = false
28+
29+
@Parameter(names = ["--tracingLog"])
30+
var tracingLog: Boolean = false
2531
}
2632

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

42-
val server = KotlinLanguageServer()
48+
if (args.tracingLog) {
49+
LOG.setTracing()
50+
}
51+
val server = KotlinLanguageServer(tcpDebug = args.tcpDebug)
4352
val threads = Executors.newSingleThreadExecutor { Thread(it, "client") }
4453
val launcher = LSPLauncher.createServerLauncher(server, ExitingInputStream(inStream), outStream, threads) { it }
4554

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

Lines changed: 1 addition & 1 deletion
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)