carlverge / jsonnet-lsp

Jsonnet Language Server and Editor Clients
Apache License 2.0
13 stars 4 forks source link

Use a single TextEdit for document replace on formatting #8

Closed gabrielrussoc closed 1 year ago

gabrielrussoc commented 1 year ago

This was the behaviour before https://github.com/carlverge/jsonnet-lsp/commit/56d735eae06a5fdf3690616c202d361ccd8afb4c where we started to send multiple TextEdits in an attempt to make the formatting work with IntelliJ.

Turns out the problem was just some parsing issue. From the below exception, it seems like it was not happy to accept math.MaxUint32 (probably because under the hood it parses into a Java int, which is always signed). Using math.MaxInt32 seems to work just fine. All I did was to revert to the previous behaviour and change MaxUint32 to MaxInt32.

2023-04-19 20:58:24,244 [1022255]   WARN - o.e.l.j.RemoteEndpoint - Issue found in NotificationMessage: Message could not be parsed.
com.google.gson.JsonSyntaxException: java.lang.NumberFormatException: Expected an int but was 4294967295 at line 1 column 164 path $.params.version
    at com.google.gson.internal.bind.TypeAdapters$7.read(TypeAdapters.java:227)
    at com.google.gson.internal.bind.TypeAdapters$7.read(TypeAdapters.java:217)
    at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:129)
    at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:220)
    at com.google.gson.Gson.fromJson(Gson.java:888)
    at org.eclipse.lsp4j.jsonrpc.json.adapters.MessageTypeAdapter.fromJson(MessageTypeAdapter.java:329)
    at org.eclipse.lsp4j.jsonrpc.json.adapters.MessageTypeAdapter.parseParams(MessageTypeAdapter.java:249)
    at org.eclipse.lsp4j.jsonrpc.json.adapters.MessageTypeAdapter.read(MessageTypeAdapter.java:119)
    at org.eclipse.lsp4j.jsonrpc.json.adapters.MessageTypeAdapter.read(MessageTypeAdapter.java:55)
    at com.google.gson.Gson.fromJson(Gson.java:888)
    at org.eclipse.lsp4j.jsonrpc.json.MessageJsonHandler.parseMessage(MessageJsonHandler.java:119)
    at org.eclipse.lsp4j.jsonrpc.json.MessageJsonHandler.parseMessage(MessageJsonHandler.java:114)
    at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.handleMessage(StreamMessageProducer.java:193)
    at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.listen(StreamMessageProducer.java:94)
    at org.eclipse.lsp4j.jsonrpc.json.ConcurrentMessageProcessor.run(ConcurrentMessageProcessor.java:113)