MCPcopy Create free account
hub / github.com/MaskRay/ccls / textDocument_codeAction

Method textDocument_codeAction

src/messages/textDocument_code.cc:24–43  ·  view source on GitHub ↗

namespace

Source from the content-addressed store, hash-verified

22REFLECT_STRUCT(CodeAction, title, kind, edit);
23} // namespace
24void MessageHandler::textDocument_codeAction(CodeActionParam &param, ReplyOnce &reply) {
25 WorkingFile *wf = findOrFail(param.textDocument.uri.getPath(), reply).second;
26 if (!wf)
27 return;
28 std::vector<CodeAction> result;
29 std::vector<Diagnostic> diagnostics;
30 wfiles->withLock([&]() { diagnostics = wf->diagnostics; });
31 for (Diagnostic &diag : diagnostics)
32 if (diag.fixits_.size() &&
33 (param.range.intersects(diag.range) ||
34 llvm::any_of(diag.fixits_, [&](const TextEdit &edit) { return param.range.intersects(edit.range); }))) {
35 CodeAction &cmd = result.emplace_back();
36 cmd.title = "FixIt: " + diag.message;
37 auto &edit = cmd.edit.documentChanges.emplace_back();
38 edit.textDocument.uri = param.textDocument.uri;
39 edit.textDocument.version = wf->version;
40 edit.edits = diag.fixits_;
41 }
42 reply(result);
43}
44
45namespace {
46struct Cmd_xref {

Callers

nothing calls this directly

Calls 5

replyFunction · 0.85
intersectsMethod · 0.80
getPathMethod · 0.45
withLockMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected