Commit 3f71d62e authored by Mark Nauwelaerts's avatar Mark Nauwelaerts

lspclient: extend and namespace some helpers

parent a8aaef8b
......@@ -189,8 +189,8 @@ public:
: q(_q), m_server(server), m_root(root), m_init(init)
{
// setup async reading
QObject::connect(&m_sproc, &QProcess::readyRead, mem_fun(&self_type::read, this));
QObject::connect(&m_sproc, &QProcess::stateChanged, mem_fun(&self_type::onStateChanged, this));
QObject::connect(&m_sproc, &QProcess::readyRead, utils::mem_fun(&self_type::read, this));
QObject::connect(&m_sproc, &QProcess::stateChanged, utils::mem_fun(&self_type::onStateChanged, this));
}
~LSPClientServerPrivate()
......@@ -435,7 +435,7 @@ private:
};
//
write(init_request(QStringLiteral("initialize"), params),
mem_fun(&self_type::onInitializeReply, this));
utils::mem_fun(&self_type::onInitializeReply, this));
}
void initialized()
......@@ -814,9 +814,6 @@ parseSignatureHelp(const QJsonValue & result)
return ret;
}
// prevent argument deduction
template<typename T> struct identity { typedef T type; };
// generic convert handler
// sprinkle some connection-like context safety
// not so likely relevant/needed due to typical sequence of events,
......@@ -824,7 +821,7 @@ template<typename T> struct identity { typedef T type; };
template<typename ReplyType>
static GenericReplyHandler make_handler(const ReplyHandler<ReplyType> & h,
const QObject *context,
typename identity<std::function<ReplyType(const GenericReplyType&)>>::type c)
typename utils::identity<std::function<ReplyType(const GenericReplyType&)>>::type c)
{
QPointer<const QObject> ctx(context);
return [ctx, h, c] (const GenericReplyType & m) { if (ctx) h(c(m)); };
......
......@@ -32,6 +32,9 @@
#include <functional>
namespace utils
{
// template helper
// function bind helpers
template<typename R, typename T, typename Tp, typename... Args>
......@@ -43,6 +46,11 @@ mem_fun(R (T::*pm)(Args ...), Tp object)
};
}
// prevent argument deduction
template<typename T> struct identity { typedef T type; };
} // namespace utils
template<typename R, typename T, typename Tp, typename... Args>
inline std::function<R(Args...)>
mem_fun(R (T::*pm)(Args ...) const, Tp object)
......
......@@ -286,7 +286,7 @@ public:
auto server = m_serverManager->findServer(view);
if (server) {
server->documentSymbols(view->document()->url(), this,
mem_fun(&self_type::onDocumentSymbols, this));
utils::mem_fun(&self_type::onDocumentSymbols, this));
} else if (m_symbols) {
m_symbols->clear();
QTreeWidgetItem *node = new QTreeWidgetItem(m_symbols);
......
Markdown is supported
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