Commit b04e2fa9 authored by Mark Nauwelaerts's avatar Mark Nauwelaerts
Browse files

lspclient: add server support for custom rust-analyzer expand macro request

parent 8336fc71
......@@ -423,4 +423,9 @@ struct LSPSemanticTokensDelta {
std::vector<uint32_t> data;
};
struct LSPExpandedMacro {
QString name;
QString expansion;
};
#endif
......@@ -717,6 +717,15 @@ static QString parseClangdSwitchSourceHeader(const QJsonValue &result)
return result.toString();
}
static LSPExpandedMacro parseExpandedMacro(const QJsonValue &result)
{
LSPExpandedMacro ret;
const QJsonObject ob = result.toObject();
ret.name = ob.value(QStringLiteral("name")).toString();
ret.expansion = ob.value(QStringLiteral("expansion")).toString();
return ret;
}
static LSPTextDocumentEdit parseTextDocumentEdit(const QJsonValue &result)
{
LSPTextDocumentEdit ret;
......@@ -1412,6 +1421,12 @@ public:
return send(init_request(QStringLiteral("$/memoryUsage"), QJsonObject()), h);
}
RequestHandle rustAnalyzerExpandMacro(const QUrl &document, const LSPPosition &pos, const GenericReplyHandler &h)
{
auto params = textDocumentPositionParams(document, pos);
return send(init_request(QStringLiteral("rust-analyzer/expandMacro"), params), h);
}
RequestHandle documentFormatting(const QUrl &document, const LSPFormattingOptions &options, const GenericReplyHandler &h)
{
auto params = documentRangeFormattingParams(document, nullptr, options);
......@@ -1737,6 +1752,12 @@ LSPClientServer::RequestHandle LSPClientServer::clangdMemoryUsage(const QObject
return d->clangdMemoryUsage(make_handler(h, context, identity));
}
LSPClientServer::RequestHandle
LSPClientServer::rustAnalyzerExpandMacro(const QObject *context, const QUrl &document, const LSPPosition &pos, const ExpandMacroHandler &h)
{
return d->rustAnalyzerExpandMacro(document, pos, make_handler(h, context, parseExpandedMacro));
}
LSPClientServer::RequestHandle
LSPClientServer::documentFormatting(const QUrl &document, const LSPFormattingOptions &options, const QObject *context, const FormattingReplyHandler &h)
{
......
......@@ -67,6 +67,7 @@ using ApplyEditReplyHandler = ReplyHandler<LSPApplyWorkspaceEditResponse>;
using WorkspaceFoldersReplyHandler = ReplyHandler<QList<LSPWorkspaceFolder>>;
using SwitchSourceHeaderHandler = ReplyHandler<QString>;
using MemoryUsageHandler = ReplyHandler<QJsonValue>;
using ExpandMacroHandler = ReplyHandler<LSPExpandedMacro>;
using SemanticTokensDeltaReplyHandler = ReplyHandler<LSPSemanticTokensDelta>;
using WorkspaceSymbolsReplyHandler = ReplyHandler<std::vector<LSPSymbolInformation>>;
......@@ -168,6 +169,9 @@ public:
void executeCommand(const QString &command, const QJsonValue &args);
// rust-analyzer specific
RequestHandle rustAnalyzerExpandMacro(const QObject *context, const QUrl &document, const LSPPosition &pos, const ExpandMacroHandler &h);
// sync
void didOpen(const QUrl &document, int version, const QString &langId, const QString &text);
// only 1 of text or changes should be non-empty and is considered
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment