File tree Expand file tree Collapse file tree 2 files changed +20
-2
lines changed
kotlin-lsp/src/com/jetbrains/ls/kotlinLsp Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ import org.jetbrains.kotlin.idea.compiler.configuration.KotlinPluginLayoutMode
32
32
import org.jetbrains.kotlin.idea.compiler.configuration.KotlinPluginLayoutModeProvider
33
33
import org.jetbrains.kotlin.idea.compiler.configuration.isRunningFromSources
34
34
import java.awt.Toolkit
35
+ import java.io.RandomAccessFile
35
36
import java.lang.invoke.MethodHandles
36
37
import java.net.URLDecoder
37
38
import java.nio.file.Path
@@ -125,7 +126,23 @@ private fun initIdeaPaths(systemPath: Path?) {
125
126
" fleet" / " native" / " target" / " download" / " filewatcher" )
126
127
}
127
128
else {
128
- val path = systemPath?.createDirectories() ? : createTempDirectory(" idea-system" )
129
+ val path = systemPath
130
+ ?.createDirectories()
131
+ ?.takeIf {
132
+ val lockFile = (it / " .app.lock" ).toFile()
133
+ val channel = RandomAccessFile (lockFile, " rw" ).channel
134
+ val isLockAcquired = channel.tryLock() != null
135
+ if (! isLockAcquired) {
136
+ LOG .info(" The specified workspace data path is already in use: $it " )
137
+ channel.close()
138
+ }
139
+ isLockAcquired
140
+ }
141
+ ? : createTempDirectory(" idea-system" ).also {
142
+ @Suppress(" SSBasedInspection" )
143
+ it.toFile().deleteOnExit()
144
+ }
145
+
129
146
systemProperty(" idea.home.path" , " $path " )
130
147
systemProperty(" idea.config.path" , " $path /config" , ifAbsent = true )
131
148
systemProperty(" idea.system.path" , " $path /system" , ifAbsent = true )
Original file line number Diff line number Diff line change @@ -184,13 +184,14 @@ async function getRunningJavaServerLspOptions(): Promise<ServerOptions | null> {
184
184
185
185
const extractPath = getContext ( ) . asAbsolutePath ( path . join ( 'server' , 'extracted' , 'lib' ) ) ;
186
186
187
+ const context = getContext ( )
187
188
const args : string [ ] = [ ]
188
189
args . push ( ...defaultJvmOptions )
189
190
args . push ( ...getUserJvmOptions ( ) )
190
191
args . push (
191
192
'-classpath' , extractPath + path . sep + '*' ,
192
193
'com.jetbrains.ls.kotlinLsp.KotlinLspServerKt' , '--client' ,
193
- '--system-path' , getContext ( ) . globalStorageUri . fsPath ,
194
+ '--system-path' , ( context . storageUri ?? context . globalStorageUri ) . fsPath ,
194
195
) ;
195
196
return < ServerOptions > {
196
197
command : javaCommand ,
You can’t perform that action at this time.
0 commit comments