@@ -4,6 +4,7 @@ package com.jetbrains.ls.kotlinLsp
4
4
import com.intellij.openapi.application.ClassPathUtil.addKotlinStdlib
5
5
import com.intellij.openapi.application.PathManager
6
6
import com.intellij.openapi.diagnostic.fileLogger
7
+ import com.intellij.openapi.util.io.FileUtilRt
7
8
import com.jetbrains.analyzer.filewatcher.FileWatcher
8
9
import com.jetbrains.ls.api.core.LSServer
9
10
import com.jetbrains.ls.api.core.LSServerContext
@@ -30,6 +31,7 @@ import org.jetbrains.kotlin.idea.base.plugin.artifacts.KotlinArtifacts
30
31
import org.jetbrains.kotlin.idea.compiler.configuration.KotlinPluginLayoutMode
31
32
import org.jetbrains.kotlin.idea.compiler.configuration.KotlinPluginLayoutModeProvider
32
33
import org.jetbrains.kotlin.idea.compiler.configuration.isRunningFromSources
34
+ import java.io.File
33
35
import java.lang.invoke.MethodHandles
34
36
import java.net.URLDecoder
35
37
import java.nio.file.Path
@@ -134,7 +136,7 @@ private fun initIdeaPaths(systemPath: Path?) {
134
136
135
137
private fun getInstallationPath (): Path {
136
138
val path = MethodHandles .lookup().lookupClass().getProtectionDomain().codeSource.location.path
137
- val jarPath = Paths .get(URLDecoder .decode(path, " UTF-8" ))
139
+ val jarPath = Paths .get(FileUtilRt .toSystemDependentName( URLDecoder .decode(path, " UTF-8" )).removePrefix( " \\ " ))
138
140
check(jarPath.extension == " jar" ) { " Path to jar is expected to end with .jar: $jarPath " }
139
141
val libsDir = jarPath.parent
140
142
check(libsDir.name == " lib" ) { " lib dir is expected to be named `lib`: $libsDir " }
@@ -165,7 +167,8 @@ private fun isRunningFromProductionLsp(): Boolean {
165
167
private fun getIJPathIfRunningFromSources (): String? {
166
168
val serverClass = Class .forName(" com.jetbrains.ls.kotlinLsp.KotlinLspServerKt" )
167
169
val jar = PathManager .getJarForClass(serverClass)?.absolutePathString() ? : return null
168
- val expectedOutDir = " /out/classes/production/language-server.kotlin-lsp"
170
+ val SEP = File .separator
171
+ val expectedOutDir = " ${SEP } out${SEP } classes${SEP } production${SEP } language-server.kotlin-lsp"
169
172
if (! jar.endsWith(expectedOutDir)) return null
170
173
return jar.removeSuffix(expectedOutDir)
171
174
}
0 commit comments