From edbc77783085ac2fc8790da8e123f1daf4997321 Mon Sep 17 00:00:00 2001 From: SeeBasTStick <sebastian.stock@hhu.de> Date: Sat, 8 Aug 2020 17:47:19 +0200 Subject: [PATCH] will no react to enabling/disabling debugging options properly --- .idea/.gitignore | 8 +++++ .../b/language/server/BWorkspaceService.kt | 5 +++ src/main/kotlin/b/language/server/Server.kt | 35 +++++++------------ 3 files changed, 26 insertions(+), 22 deletions(-) create mode 100644 .idea/.gitignore diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..73f69e0 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/src/main/kotlin/b/language/server/BWorkspaceService.kt b/src/main/kotlin/b/language/server/BWorkspaceService.kt index 70c5159..7dfc24d 100644 --- a/src/main/kotlin/b/language/server/BWorkspaceService.kt +++ b/src/main/kotlin/b/language/server/BWorkspaceService.kt @@ -1,10 +1,12 @@ package b.language.server +import b.language.server.communication.Communicator import b.language.server.dataStorage.Settings import com.google.gson.Gson import com.google.gson.JsonObject import org.eclipse.lsp4j.DidChangeConfigurationParams import org.eclipse.lsp4j.DidChangeWatchedFilesParams +import org.eclipse.lsp4j.MessageType import org.eclipse.lsp4j.services.WorkspaceService import java.io.File @@ -14,6 +16,8 @@ class BWorkspaceService(private val server : Server) : WorkspaceService { * the client detects changes to file watched by the language client. */ override fun didChangeWatchedFiles(params: DidChangeWatchedFilesParams?) { + Communicator.sendDebugMessage("----------changed watched files", MessageType.Info) + // Not needed } @@ -22,6 +26,7 @@ class BWorkspaceService(private val server : Server) : WorkspaceService { * configuration settings. */ override fun didChangeConfiguration(params: DidChangeConfigurationParams?) { + Communicator.sendDebugMessage("received change in configuration settings", MessageType.Info) if(server.configurationAbility) { server.documentSettings.clear() }else{ diff --git a/src/main/kotlin/b/language/server/Server.kt b/src/main/kotlin/b/language/server/Server.kt index ab657f7..c0bfd91 100644 --- a/src/main/kotlin/b/language/server/Server.kt +++ b/src/main/kotlin/b/language/server/Server.kt @@ -10,34 +10,28 @@ import org.eclipse.lsp4j.services.* import java.util.concurrent.CompletableFuture import kotlin.collections.HashMap import kotlin.system.exitProcess - +import org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint class Server : LanguageServer{ - private val textDocumentService : TextDocumentService - private val bWorkspaceService : WorkspaceService + private val textDocumentService : TextDocumentService = BDocumentService(this, Communicator) + private val bWorkspaceService : WorkspaceService = BWorkspaceService(this) lateinit var languageClient : LanguageClient var globalSettings : Settings = Settings() val documentSettings : HashMap<String, CompletableFuture<Settings>> = HashMap() var configurationAbility : Boolean = true - init { - textDocumentService = BDocumentService(this, Communicator) - bWorkspaceService = BWorkspaceService(this) - - } - - override fun initialize(params: InitializeParams?): CompletableFuture<InitializeResult> { val res = InitializeResult(ServerCapabilities()) res.capabilities.textDocumentSync = Either.forLeft(TextDocumentSyncKind.Full) + res.capabilities.workspace = WorkspaceServerCapabilities(WorkspaceFoldersOptions()) + res.capabilities.workspace.workspaceFolders.supported = true - return CompletableFuture.supplyAsync { res } - } + // languageClient.registerCapability( + // RegistrationParams(listOf(Registration("all_config_changes", "didChangeConfiguration" , bWorkspaceService)))) - override fun initialized(params: InitializedParams?) { - //languageClient.registerCapability(DidChangeConfigurationCapabilities()) + return CompletableFuture.supplyAsync { res } } /** @@ -79,6 +73,9 @@ class Server : LanguageServer{ } + + + /** * Get the settings for the current document - will fallback to global settings eventually; If setting not cached * method will try to get setting from the client @@ -87,17 +84,11 @@ class Server : LanguageServer{ */ fun getDocumentSettings(uri : String) : CompletableFuture<Settings> { Communicator.sendDebugMessage("received configuration Data of the document $uri", MessageType.Info) - if(!configurationAbility){ + return if(!configurationAbility){ val returnValue = CompletableFuture<Settings>() returnValue.complete(globalSettings) - return returnValue - } - - // if client has configuration abilities - return if(documentSettings.containsKey(uri)) - { - documentSettings[uri]!! + returnValue }else{ val configurationItem = ConfigurationItem() configurationItem.scopeUri = uri -- GitLab