2
2
package com.jetbrains.ls.kotlinLsp
3
3
4
4
import com.intellij.openapi.application.PathManager
5
+ import com.intellij.openapi.diagnostic.fileLogger
5
6
import com.jetbrains.ls.api.core.LSServer
6
7
import com.jetbrains.ls.api.core.LSServerContext
7
8
import com.jetbrains.ls.api.features.LSConfiguration
@@ -27,7 +28,9 @@ import org.jetbrains.kotlin.idea.base.plugin.artifacts.KotlinArtifacts
27
28
import org.jetbrains.kotlin.idea.compiler.configuration.KotlinPluginLayoutMode
28
29
import org.jetbrains.kotlin.idea.compiler.configuration.KotlinPluginLayoutModeProvider
29
30
import org.jetbrains.kotlin.idea.compiler.configuration.isRunningFromSources
31
+ import java.nio.file.Path
30
32
import kotlin.io.path.absolutePathString
33
+ import kotlin.io.path.createDirectories
31
34
import kotlin.io.path.createTempDirectory
32
35
import kotlin.system.exitProcess
33
36
@@ -45,10 +48,13 @@ fun main(args: Array<String>) {
45
48
}
46
49
}
47
50
51
+ // use after `initKotlinLspLogger` call
52
+ private val LOG by lazy { fileLogger() }
53
+
48
54
private fun run (runConfig : KotlinLspServerRunConfig ) {
49
55
val mode = runConfig.mode
50
56
initKotlinLspLogger(writeToStdOut = mode != KotlinLspServerMode .Stdio )
51
- initIdeaPaths()
57
+ initIdeaPaths(runConfig.systemPath )
52
58
setLspKotlinPluginModeIfRunningFromProductionLsp()
53
59
val config = createConfiguration()
54
60
@@ -112,17 +118,21 @@ private suspend fun handleRequests(connection: LspConnection, runConfig: KotlinL
112
118
}
113
119
}
114
120
115
- private fun initIdeaPaths () {
121
+ private fun initIdeaPaths (systemPath : Path ? ) {
116
122
val fromSources = getIJPathIfRunningFromSources()
117
123
if (fromSources != null ) {
118
124
System .setProperty(" idea.home.path" , fromSources)
119
125
System .setProperty(" idea.config.path" , " $fromSources /config/idea" )
120
126
System .setProperty(" idea.system.path" , " $fromSources /system/idea" )
121
127
}
122
128
else {
123
- val tmp = createTempDirectory(" idea-home" ).absolutePathString()
124
- System .setProperty(" idea.home.path" , tmp)
129
+ val path = systemPath?.createDirectories() ? : createTempDirectory(" idea-system" )
130
+ System .setProperty(" idea.home.path" , " $path " )
131
+ System .setProperty(" idea.config.path" , " $path /config" )
132
+ System .setProperty(" idea.system.path" , " $path /system" )
125
133
}
134
+ LOG .info(" idea.config.path=${System .getProperty(" idea.config.path" )} " )
135
+ LOG .info(" idea.system.path=${System .getProperty(" idea.system.path" )} " )
126
136
}
127
137
128
138
private fun setLspKotlinPluginModeIfRunningFromProductionLsp () {
0 commit comments