emacs-lsp / emacs-ccls

Emacs client for ccls, a C/C++ language server
200 stars 29 forks source link

LSP :: invalid params of textDocument/codeAction: expected array for /context/diagnostics[0]/relatedInformation [6 times] #46

Closed szobov closed 5 years ago

szobov commented 5 years ago

Hi there!

I've tried to use ccls with spacemacs, but everytime I put a cursor on line with error I receive:

LSP :: invalid params of textDocument/codeAction: expected array for /context/diagnostics[0]/relatedInformation [N times] (N is a count of how many times I put a cursor on line with the error).

This is my system env, hope it helps:

#### System Info :computer:
- OS: gnu/linux
- Emacs: 26.1
- Spacemacs: 0.300.0
- Spacemacs branch: develop (rev. 2206095be)
- Graphic display: nil
- Distribution: spacemacs
- Editing style: vim
- Completion: helm
- Layers:
```elisp
(csv systemd ruby multiple-cursors rust helm emacs-lisp neotree graphviz auto-completion syntax-checking version-control spell-checking restclient git github ansible docker nginx sql markdown yaml protobuf shell windows-scripts python erlang elixir
     (c-c++ :variables c-c++-default-mode-for-headers 'c++-mode c-c++-backend 'lsp-ccls c-c++-lsp-executable "/home/szobov/.nix-profile/bin/ccls" c-c++-lsp-sem-highlight-method 'font-lock c-c++-lsp-cache-dir "/home/szobov/.ccls-cache-dir/")
     semantic cmake html javascript typescript react
     (go :variables go-use-gometalinter t go-use-test-args "-race -timeout 30s -v" godoc-at-point-function 'godoc-gogetdoc)
     nixos evernote emoji)
- System configuration features: XPM JPEG TIFF GIF PNG RSVG SOUND DBUS GSETTINGS NOTIFY LIBSELINUX GNUTLS LIBXML2 FREETYPE XFT ZLIB TOOLKIT_SCROLL_BARS GTK3 X11 MODULES THREADS

I can also provide any important information if you need. Thanks!

szobov commented 5 years ago

ping

MaskRay commented 5 years ago

Your lsp-mode may be older than https://github.com/emacs-lsp/lsp-mode/pull/691 . Before that an empty JSON array was (de)serialized as nil. That badly conflicted with the JSON null.

I suspect "relatedInformation":[] (from textDocument/publishDiagnostics) was deserialized as (:relatedInformation nil), and then it was passed around as "relatedInformation": null by lsp-execute-code-action. That was incorrect. The spec says:

relatedInformation?: DiagnosticRelatedInformation[];

relatedInformation can't be a null.