From 950131eb2c23536419b1a06cfbecf156cc851133 Mon Sep 17 00:00:00 2001 From: "seito.tanaka" Date: Sat, 22 Jun 2024 11:06:14 +0900 Subject: [PATCH] Add cache clear --- src/main/kotlin/inga/intellijinga/IngaConfigurable.kt | 5 +++++ src/main/kotlin/inga/intellijinga/IngaService.kt | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/src/main/kotlin/inga/intellijinga/IngaConfigurable.kt b/src/main/kotlin/inga/intellijinga/IngaConfigurable.kt index 4aafd37..adecd11 100644 --- a/src/main/kotlin/inga/intellijinga/IngaConfigurable.kt +++ b/src/main/kotlin/inga/intellijinga/IngaConfigurable.kt @@ -43,6 +43,11 @@ class IngaConfigurable(private val project: Project) : Configurable { cell(mountsTable(bindMounts)).align(AlignX.FILL) } } + row { + button("Clear Caches and Restart") { + project.service().clearCachesAndRestart() + } + } } } diff --git a/src/main/kotlin/inga/intellijinga/IngaService.kt b/src/main/kotlin/inga/intellijinga/IngaService.kt index c2a7baa..212473c 100644 --- a/src/main/kotlin/inga/intellijinga/IngaService.kt +++ b/src/main/kotlin/inga/intellijinga/IngaService.kt @@ -11,6 +11,7 @@ import com.intellij.openapi.application.PathManager import com.intellij.openapi.components.Service import com.intellij.openapi.components.service import com.intellij.openapi.project.Project +import com.redhat.devtools.lsp4ij.LanguageServerManager import kotlinx.coroutines.launch import kotlinx.coroutines.runBlocking import java.net.ServerSocket @@ -67,6 +68,12 @@ class IngaService(private val project: Project) { } } + fun clearCachesAndRestart() { + LanguageServerManager.getInstance(project).stop("ingaLanguageServer"); + Files.walk(ingaTempPath).map { it.toFile() }.forEach { it.delete() } + LanguageServerManager.getInstance(project).start("ingaLanguageServer"); + } + private fun startIngaContainer(state: IngaSettingsState): String { var ingaContainer = client .listContainersCmd()