Skip to content

Commit

Permalink
fix: UI freezes, code vision refreshes
Browse files Browse the repository at this point in the history
  • Loading branch information
bastiandoetsch committed Mar 20, 2024
1 parent d233052 commit 09fe662
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
7 changes: 1 addition & 6 deletions src/main/kotlin/io/snyk/plugin/Utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
package io.snyk.plugin

import com.intellij.codeInsight.codeVision.CodeVisionHost
import com.intellij.codeInsight.codeVision.CodeVisionInitializer
import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer
import com.intellij.codeInsight.hints.VcsCodeVisionProvider
import com.intellij.codeInsight.hints.codeVision.CodeVisionFusCollector
import com.intellij.ide.util.PsiNavigationSupport
import com.intellij.openapi.Disposable
import com.intellij.openapi.application.ApplicationManager
Expand Down Expand Up @@ -34,7 +31,6 @@ import com.intellij.psi.PsiManager
import com.intellij.util.Alarm
import com.intellij.util.FileContentUtil
import com.intellij.util.messages.Topic
import com.jetbrains.rd.util.reactive.Signal
import io.snyk.plugin.analytics.AnalyticsScanListener
import io.snyk.plugin.net.ClientException
import io.snyk.plugin.services.SnykAnalyticsService
Expand All @@ -52,7 +48,6 @@ import io.snyk.plugin.ui.SnykBalloonNotificationHelper
import io.snyk.plugin.ui.toolwindow.SnykToolWindowFactory
import io.snyk.plugin.ui.toolwindow.SnykToolWindowPanel
import org.apache.commons.lang3.SystemUtils
import org.jetbrains.kotlin.idea.codeinsight.utils.findExistingEditor
import snyk.advisor.AdvisorService
import snyk.advisor.AdvisorServiceImpl
import snyk.advisor.SnykAdvisorModel
Expand Down Expand Up @@ -309,7 +304,7 @@ fun findPsiFileIgnoringExceptions(virtualFile: VirtualFile, project: Project): P

fun refreshAnnotationsForOpenFiles(project: Project) {
if (project.isDisposed) return
VirtualFileManager.getInstance().asyncRefresh();
VirtualFileManager.getInstance().asyncRefresh()

val openFiles = FileEditorManager.getInstance(project).openFiles

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class SnykCliDownloaderService {

val languageServerWrapper = LanguageServerWrapper.getInstance()
try {
if (languageServerWrapper.ensureLanguageServerInitialized()) {
if (languageServerWrapper.isInitialized) {
try {
languageServerWrapper.shutdown().get(2, TimeUnit.SECONDS)
} catch (e: RuntimeException) {
Expand Down
8 changes: 4 additions & 4 deletions src/main/kotlin/snyk/common/lsp/LanguageServerWrapper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -220,13 +220,13 @@ class LanguageServerWrapper(
}

fun ensureLanguageServerInitialized(): Boolean {
try {
if (!isInitialized) {
if (!isInitialized) {
try {
isInitializing.lock()
initialize()
} finally {
isInitializing.unlock()
}
} finally {
if (isInitializing.isHeldByCurrentThread) isInitializing.unlock()
}
return isInitialized
}
Expand Down

0 comments on commit 09fe662

Please sign in to comment.