Open flixil opened 4 years ago
Isn't it a generic feature that does no ccls-specific thing? Why name it ccls.references
?
"Peek references" palete command doesn't shows also the definition and implementation, not only where things are used. So it's not a perfect replacement
It would send the textDocument/references command to ccls with the same behaviour as when we click ref on the editor.
Is there a way to have a keyboard binding without exposing textDocument/references from vscode-ccls?
When you click on ref on the editor we are sending something like
{"jsonrpc":"2.0","id":119,"method":"workspace/executeCommand","params":{"command":"ccls.xref","arguments":["{\"usr\":15001499940446849262,\"kind\":3,\"field\":\"uses\"}"]}}Content-Length: 182
When you send the registerCommand ccls.references you would send something like
{"jsonrpc":"2.0","id":478,"method":"textDocument/references","params":{"position":{"line":830,"character":42},"textDocument":{"uri":"file:///work/main.cpp"}}}Content-Length: 182
The thing is that the current "ccls: Show Cross References" doesn't do the exact same thing as when you click on a ref. button, it just does ccls.call, and I find the button more useful.
Maybe the behaviour of "ccls: Show Cross References" should NOT be just ccls.call as defined now in package.json, but instead "textDocument/references" which would work for all types and move the cursor to the right usage place.
Just adding
Onto the serverContext.ts would immediately make this available from a keyboard shortcut such as
This works for variables, functions, etc. and it's the same implementation as clicking on the ref. button, so one doesn't need to remember ccls.vars, ccls.call, ccls.member keystrokes.
As a bonus, on the Peek window, this shows the exact location where there references are used from on the right hand side, instead of the function that contains the calls for ccls.call so it behaves more intuitively.
Kind regards, flixil