4#ifndef QQMLBASEMODULE_P_H
5#define QQMLBASEMODULE_P_H
23#include <unordered_map>
25template<
typename ParametersT,
typename ResponseT>
44template<
typename RequestType>
67 std::unordered_multimap<QString, RequestPointer>
m_pending;
71template<
typename Parameters,
typename Response>
77 m_response = std::move(response);
80 qDebug() <<
"Cannot find document in qmlls's codemodel, did you open it before accessing "
92template<
typename RequestType>
94 : m_codeModel(codeModel)
100template<
typename RequestType>
107template<
typename RequestType>
112 requestHandler(parameters, std::move(response));
117template<
typename RequestType>
121 auto req = std::make_unique<RequestType>();
125 if (!req->fillFrom(doc, parameters, std::move(response))) {
126 req->m_response.sendErrorResponse(0,
"Received invalid request", parameters);
129 const int minVersion = req->m_minVersion;
132 m_pending.insert({
QString::fromUtf8(req->m_parameters.textDocument.uri), std::move(req) });
139template<
typename RequestType>
143 std::vector<RequestPointer> toCompl;
149 toCompl.push_back(std::move(
value));
156 for (
auto it = toCompl.rbegin(),
end = toCompl.rend();
it !=
end; ++
it) {
157 process(std::move(*
it));
161template<
typename RequestType>
162std::optional<QList<QQmlLSUtilsItemLocation>>
172 envPtr->clearReferenceCache();
174 qWarning() << u
"Could not find file in Dom Environment from Codemodel :"_s
180 request->m_parameters.position.character);
182 if (itemsFound.isEmpty()) {
183 qWarning() << u
"Could not find any items at given text location."_s;
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
Represents a consistent set of types organized in modules, it is the top level of the DOM.
DomItem fileObject(GoTo option=GoTo::Strict)
static QByteArray lspUriToQmlUrl(const QByteArray &uri)
static QList< QQmlLSUtilsItemLocation > itemsFromTextLocation(QQmlJS::Dom::DomItem file, int line, int character)
Find the DomItem representing the object situated in file at given line and character/column.
iterator erase(const_iterator i)
static QString fromUtf8(QByteArrayView utf8)
This is an overloaded member function, provided for convenience. It differs from the above function o...
std::optional< int > docVersion
QQmlJS::Dom::DomItem validDoc
std::shared_ptr< Utils::TextDocument > textDocument
OpenDocumentSnapshot snapshot
void updatedSnapshot(const QByteArray &url)
QSet< QString >::iterator it
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
QUrl url("example.com")
[constructor-url-reference]
QNetworkRequest request(url)
bool fillFrom(QmlLsp::OpenDocument doc, const Parameters ¶ms, Response &&response)
std::optional< QList< QQmlLSUtilsItemLocation > > itemsForRequest(const RequestPointer &request)
decltype(auto) getRequestHandler()
QQmlBaseModule(QmlLsp::QQmlCodeModel *codeModel)
QmlLsp::QQmlCodeModel * m_codeModel
void updatedSnapshot(const QByteArray &uri)
void requestHandler(const RequestParameters ¶meters, RequestResponse &&response)
RequestPointer && RequestPointerArgument
typename RequestType::Response RequestResponse
virtual void process(RequestPointerArgument toBeProcessed)=0
std::unique_ptr< RequestType > RequestPointer
typename RequestType::Parameters RequestParameters
std::unordered_multimap< QString, RequestPointer > m_pending