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
3232import org.jetbrains.kotlin.idea.compiler.configuration.KotlinPluginLayoutModeProvider
3333import org.jetbrains.kotlin.idea.compiler.configuration.isRunningFromSources
3434import java.awt.Toolkit
35+ import java.io.RandomAccessFile
3536import java.lang.invoke.MethodHandles
3637import java.net.URLDecoder
3738import java.nio.file.Path
@@ -125,7 +126,23 @@ private fun initIdeaPaths(systemPath: Path?) {
125126 " fleet" / " native" / " target" / " download" / " filewatcher" )
126127 }
127128 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+
129146 systemProperty(" idea.home.path" , " $path " )
130147 systemProperty(" idea.config.path" , " $path /config" , ifAbsent = true )
131148 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> {
184184
185185 const extractPath = getContext ( ) . asAbsolutePath ( path . join ( 'server' , 'extracted' , 'lib' ) ) ;
186186
187+ const context = getContext ( )
187188 const args : string [ ] = [ ]
188189 args . push ( ...defaultJvmOptions )
189190 args . push ( ...getUserJvmOptions ( ) )
190191 args . push (
191192 '-classpath' , extractPath + path . sep + '*' ,
192193 'com.jetbrains.ls.kotlinLsp.KotlinLspServerKt' , '--client' ,
193- '--system-path' , getContext ( ) . globalStorageUri . fsPath ,
194+ '--system-path' , ( context . storageUri ?? context . globalStorageUri ) . fsPath ,
194195 ) ;
195196 return < ServerOptions > {
196197 command : javaCommand ,
You can’t perform that action at this time.
0 commit comments