Description
I am trying to implement the IDidChangeConfigurationHandler interface, for use within a Language Server that we are creating here:
https://github.com/gep13/chocolatey-vscode
For validating the Chocolatey Nuspec file when editing within VSCode. In general, things have been going very well with this implementation thanks to some input from @mholo65. The problem stems from the fact that ideally, I would like to have configuration in the following format:
However, when I try to run the Language Server with this configuration, I get the following error:
Unhandled Exception: Newtonsoft.Json.JsonSerializationException: Unexpected token when deserializing object: String. Path 'params.settings.nuspec.suppressedRules[0]', line 1, position 123.
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateDictionary(IDictionary dictionary, JsonReader reader, JsonDictionaryContract contract, JsonProperty containerProperty, String id)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
at Newtonsoft.Json.Linq.JToken.ToObject(Type objectType, JsonSerializer jsonSerializer)
at OmniSharp.Extensions.LanguageServer.Server.LspRequestRouter.FindDescriptor(String method, JToken params) in /_/src/Server/LspRequestRouter.cs:line 77
at OmniSharp.Extensions.JsonRpc.InputHandler.HandleRequest(String request) in /_/src/JsonRpc/InputHandler.cs:line 198
at OmniSharp.Extensions.JsonRpc.InputHandler.ProcessInputStream() in /_/src/JsonRpc/InputHandler.cs:line 120
at System.Threading.Thread.ThreadMain_ThreadStart()
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
Digging into the tests, it looks like it is expected that the JSON values are only boolean, number and string, rather than the more complex JSON types:
However, the specification for the Language Server Protocol suggests that it should be of type any
:
https://microsoft.github.io/language-server-protocol/specification#workspace_didChangeConfiguration
Is there a reason for not implementing the settings object directly as a JObject, or something similar?
I could work around this using a configuration similar to the following:
However, I was hoping to expand to having a configuration similar to the following extension:
https://marketplace.visualstudio.com/items?itemName=streetsidesoftware.code-spell-checker