diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..73f69e0958611ac6e00bde95641f6699030ad235 --- /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 70c51592e86036b7f423ba2b7d8a6783ae001c89..7dfc24dc30730e95391dde72e21e0bee3a5d1a92 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 ab657f7c99974307a9b5b55651ceb8be1b754ac6..c0bfd919209b0175bae1d8fb5746d02798586ea5 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