-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: handle new downloads and ls restarts correctly
- Loading branch information
1 parent
43be63e
commit 595cbcf
Showing
7 changed files
with
65 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
src/main/kotlin/snyk/common/lsp/LanguageServerRestartListener.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package snyk.common.lsp | ||
|
||
import com.intellij.openapi.Disposable | ||
import com.intellij.openapi.application.ApplicationManager | ||
import com.intellij.openapi.components.Service | ||
import com.intellij.openapi.components.service | ||
import com.intellij.openapi.util.Disposer | ||
import io.snyk.plugin.events.SnykCliDownloadListener | ||
import io.snyk.plugin.ui.toolwindow.SnykPluginDisposable | ||
|
||
@Service(Service.Level.APP) | ||
class LanguageServerRestartListener : Disposable { | ||
private var disposed = false | ||
|
||
fun isDisposed() = disposed | ||
override fun dispose() { | ||
this.disposed = true | ||
} | ||
|
||
companion object { | ||
@JvmStatic | ||
fun getInstance(): LanguageServerRestartListener = service() | ||
} | ||
|
||
init { | ||
Disposer.register(SnykPluginDisposable.getInstance(), this) | ||
ApplicationManager.getApplication().messageBus.connect() | ||
.subscribe(SnykCliDownloadListener.CLI_DOWNLOAD_TOPIC, object : SnykCliDownloadListener { | ||
override fun cliDownloadFinished(succeed: Boolean) { | ||
if (succeed && !disposed) { | ||
LanguageServerWrapper.getInstance().restart() | ||
} | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters