Open siegel opened 2 years ago
We just don't have any actions here to show on C++ class names :-) Or rather, we do in trunk ("declare implicit copy/move members"), but not in the 13 or even 14 release.
Our set of code actions is not very extensive (apart from diagnostic fixes). You can see them here. Some examples to try:
auto bar = new SomeCppClass
, with cursor on auto
switch
statement over an enum, without handling all cases, cursor on switch
To me this reads as though clangd will return no code actions unless a non-empty only list is included; this seems like a bug to me but I'm not sure of what is expected here.
I don't think that's right: KindAllowed evaluates to true if only
is empty (we don't distinguish between empty-list and unset here). This means that code actions will be accepted regardless of their Kind, i.e. no filtering is performed in this case.
We have a test that requests code actions without setting only
.
We just don't have any actions here to show on C++ class names :-)
That's fair. :-) I tried some simple test cases: Objective-C class names, and argument names, and local variables.
I don't think that's right: KindAllowed evaluates to true if only is empty[...]
Great, thanks — I appreciate the explanation.
auto bar = new SomeCppClass, with cursor on auto
This did indeed return a proposed action.
a switch statement over an enum, without handling all cases, cursor on switch
This did not, but I may be missing something obvious.
At the very least I was expecting to see some refactoring options available, as shown in the "Refactoring" section of the Features page, which says:
Most symbols are renameable, such as classes, variables, functions and methods.
Is the documentation wrong there, or am I holding it wrong?
a switch statement over an enum, without handling all cases, cursor on switch
This did not, but I may be missing something obvious.
Try this:
enum X {A, B, C};
void foo(X x) {
switch(x) { } // cursor on 'switch'
}
At the very least I was expecting to see some refactoring options available, as shown in the "Refactoring" section of the Features page
The text there is under a "rename" subheading, this is a separate method textDocument/rename
rather than code actions.
(These docs are out of date, we do have some other minor refactorings as code actions, like extract-variable, but they're not documented there yet).
I'm working out implementation of Code Actions from first principles (and the spec, for as much good as it does), and have gotten to the point where the communications seem to be working, but I'm not getting back expected results from
clangd
. (Which is, in honesty, the server I'm using to test and debug with, since it's proven to be the most reliable by far.)Given this source file (its name ends in
.mm
so it's Objective-C++, but the test case contains only C++ code):If I select the first occurrence of "
SomeCppClass
" or place the insertion point in it and send atextDocument/codeAction
request, I would expectclangd
to respond with some non-empty list of things it can do at that point. (Perhaps "refactor".)I immediately ran into a bug because I wasn't including the
only
parameter. The spec says that this parameter is optional, but looking at the clangd source code I see this:To me this reads as though
clangd
will return no code actions unless a non-emptyonly
list is included; this seems like a bug to me but I'm not sure of what is expected here.Continuing: even after sending a non-empty
only
parameter, I'm finding thatclangd
is continuing to return an empty list of actions.The request I send is:
I can verify that in other cases, my
textDocument/codeAction
requests return expected output; for example, when I have an overlapping diagnostic with an availablequickfix
action, I can request code actions and I'll get back something applicable. That tells me that in general the request I'm sending is well formed; but clearly it's lacking something thatclangd
is expecting to see, or else my expectations are completely out of whack.Logs
clangd-codeaction.txt
System information
Output of
clangd --version
:Editor/LSP plugin: BBEdit 14, engineering build
Operating system: macOS 12.3.1 (21E258), arm64