eclipse-lemminx / lemminx

XML Language Server
Eclipse Public License 2.0
272 stars 93 forks source link

Exception because of missing "rangeLength" of didChange notification #1674

Closed techee closed 3 weeks ago

techee commented 3 months ago

The LSP specification defines rangeLength of the textDocument/didChange notification as optional, see

https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_didChange

However, the lemminx server requires this parameter and throws an exception which leads to improper document syncing:

Aug 28, 2024 10:54:55 PM org.eclipse.lemminx.XMLLanguageServer initialize
INFO: Initializing XML Language server
LemMinX Server info:
 - Version : 0.28.0
 - Java : /usr/lib/jvm/java-17-openjdk-arm64
 - VM Version : 17.0.11
 - Git 9c3a0f1 - [maven-release-plugin] prepare release 0.28.0
Aug 28, 2024 10:55:18 PM org.eclipse.lsp4j.jsonrpc.RemoteEndpoint handleNotification
WARNING: Notification threw an exception: {
  "jsonrpc": "2.0",
  "method": "textDocument/didChange",
  "params": {
    "textDocument": {
      "version": 2,
      "uri": "file:///home/parallels/test.xml"
    },
    "contentChanges": [
      {
        "range": {
          "start": {
            "line": 5,
            "character": 7
          },
          "end": {
            "line": 5,
            "character": 7
          }
        },
        "text": "a"
      }
    ]
  }
}
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
    at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.lambda$null$0(GenericEndpoint.java:67)
    at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.notify(GenericEndpoint.java:152)
    at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.handleNotification(RemoteEndpoint.java:220)
    at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.consume(RemoteEndpoint.java:187)
    at org.eclipse.lemminx.commons.ParentProcessWatcher.lambda$apply$0(ParentProcessWatcher.java:143)
    at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.handleMessage(StreamMessageProducer.java:194)
    at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.listen(StreamMessageProducer.java:94)
    at org.eclipse.lsp4j.jsonrpc.json.ConcurrentMessageProcessor.run(ConcurrentMessageProcessor.java:113)
    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
    at java.base/java.lang.Thread.run(Thread.java:840)
Caused by: java.lang.reflect.InvocationTargetException
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.lambda$null$0(GenericEndpoint.java:65)
    ... 12 more
Caused by: java.lang.NullPointerException: Cannot invoke "java.lang.Integer.intValue()" because the return value of "org.eclipse.lsp4j.TextDocumentContentChangeEvent.getRangeLength()" is null
    at org.eclipse.lemminx.commons.TextDocument.update(TextDocument.java:182)
    at org.eclipse.lemminx.commons.TextDocuments.onDidChangeTextDocument(TextDocuments.java:89)
    at org.eclipse.lemminx.XMLTextDocumentService.didChange(XMLTextDocumentService.java:394)
    ... 17 more

Aug 28, 2024 11:14:40 PM org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint getArguments
WARNING: Unexpected params '{"gopls_bug_workarond":"https://github.com/golang/go/issues/57459"}' for 'public abstract void org.eclipse.lsp4j.services.LanguageServer.exit()' is ignored
Aug 28, 2024 11:14:58 PM org.eclipse.lemminx.XMLLanguageServer initialize
INFO: Initializing XML Language server
LemMinX Server info:
 - Version : 0.28.0
 - Java : /usr/lib/jvm/java-17-openjdk-arm64
 - VM Version : 17.0.11
 - Git 9c3a0f1 - [maven-release-plugin] prepare release 0.28.0
Aug 28, 2024 11:22:10 PM org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint getArguments
WARNING: Unexpected params '{"gopls_bug_workarond":"https://github.com/golang/go/issues/57459"}' for 'public abstract void org.eclipse.lsp4j.services.LanguageServer.exit()' is ignored
angelozerr commented 3 months ago

Any contribution are welcome!