namespace
| 22 | REFLECT_STRUCT(CodeAction, title, kind, edit); |
| 23 | } // namespace |
| 24 | void MessageHandler::textDocument_codeAction(CodeActionParam ¶m, 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 | |
| 45 | namespace { |
| 46 | struct Cmd_xref { |
nothing calls this directly
no test coverage detected