emacs-ccls icon indicating copy to clipboard operation
emacs-ccls copied to clipboard

Pass "ccls.xref" command name as a string, not a symbol, to lsp--send-execute-command...

Open ymarkovitch opened this issue 3 years ago • 5 comments

...in the lsp-execute-command method definition.

This fixes error '(wrong-type-argument json-value-p ccls.xref)' on attempt to click on any code lens reference.

It seems that the old elisp-only json serializer did accept a symbol as a JSON value and serialized it as a string; now, when Emacs is built with native JSON support, it is not more valid.

P.S. Maybe (symbol-name command) would have been better, but since this method is explicitly restricted to ccls.xref, it seems passing the command name verbatim is OK?

ymarkovitch avatar Jul 27 '21 18:07 ymarkovitch

Bump. It would be nice if this fix (or other better fix) can be merged.

Maverobot avatar Nov 10 '21 20:11 Maverobot

I'm totally a newbie when coding in emacs lisp but it can be more generic by checking native JSON support ?

(cl-defmethod lsp-execute-command
((_server (eql ccls)) (command (eql ccls.xref)) arguments)
(when-let ((command (if (functionp 'json-serialize)
			  (symbol-name command)
			command))
	         (xrefs (lsp--locations-to-xref-items
                    (lsp--send-execute-command command arguments))))
  (xref--show-xrefs xrefs nil)))

altomcat avatar Jan 19 '22 18:01 altomcat

Any update, pls?

seagle0128 avatar Apr 27 '22 08:04 seagle0128

I get this error also, but ccls.el has:

(cl-defmethod lsp-execute-command
  ((_server (eql ccls)) (command (eql ccls.xref)) arguments)
  (when-let ((xrefs (lsp--locations-to-xref-items
                     (lsp--send-execute-command (symbol-name command) arguments))))
    (xref--show-xrefs xrefs nil)))

ie this PR has been superceeded but the same symptoms still happen.

EDIT: actually strike that, looks like I modified it earlier but forgot to recompile the file..

DanielO avatar Aug 03 '22 01:08 DanielO

Sorry, any update on this, I still getting this error, and from master branch, the ccls.el still remain

(cl-defmethod lsp-execute-command
  ((_server (eql ccls)) (command (eql ccls.xref)) arguments)
  (when-let ((xrefs (lsp--locations-to-xref-items
                     (lsp--send-execute-command command arguments))))
    (xref--show-xrefs xrefs nil)))

thyeun avatar Aug 14 '22 05:08 thyeun

I can confirm that this PR fixes the issue for me for this issue: https://github.com/emacs-lsp/emacs-ccls/issues/109

I have raised a discussion in the discord to see if we can get this merged.

psibi avatar Nov 30 '22 04:11 psibi