6#include <QtLanguageServer/private/qlanguageserverspectypes_p.h>
7#include <QtQmlDom/private/qqmldomexternalitems_p.h>
8#include <QtQmlDom/private/qqmldomtop_p.h>
16 :
BaseT(codeModel) { }
20 return u
"QmlFindUsagesSupport"_s;
24 const QLspSpecification::InitializeParams &,
25 QLspSpecification::InitializeResult &serverCapabilities)
30 serverCapabilities.capabilities.referencesProvider =
true;
40 QList<QLspSpecification::Location>
results;
53 QHash<QString, QString> codeCache;
55 for (
const auto &
usage : usages) {
56 QLspSpecification::Location
location;
59 auto cacheEntry = codeCache.find(
usage.filename);
60 if (cacheEntry == codeCache.end()) {
62 .field(QQmlJS::Dom::Fields::currentItem)
65 qDebug() <<
"File" <<
usage.filename <<
"not found in DOM! Available files are"
69 cacheEntry = codeCache.insert(
usage.filename,
file->code());
Implements a server for the language server protocol.
void append(parameter_type t)
void setupCapabilities(const QLspSpecification::InitializeParams &clientInfo, QLspSpecification::InitializeResult &) override
void registerHandlers(QLanguageServer *server, QLanguageServerProtocol *protocol) override
QQmlFindUsagesSupport(QmlLsp::QQmlCodeModel *codeModel)
void process(RequestPointerArgument request) override
QString name() const override
DomItem field(QStringView name) const
A QmlFile, when loaded in a DomEnvironment that has the DomCreationOption::WithSemanticAnalysis,...
static QList< QQmlLSUtilsLocation > findUsagesOf(const DomItem &item)
static QLspSpecification::Range qmlLocationToLspLocation(const QString &code, QQmlJS::SourceLocation qmlLocation)
Converts a QQmlJS::SourceLocation to a LSP Range.
\macro QT_RESTRICTED_CAST_FROM_ASCII
static QUrl fromLocalFile(const QString &localfile)
Returns a QUrl representation of localFile, interpreted as a local file.
Combined button and popup list for selecting options.
GLsizeiptr const void GLenum usage
QNetworkRequest request(url)
decltype(auto) getRequestHandler()
std::variant< QList< QQmlLSUtilsItemLocation >, QQmlLSUtilsErrorMessage > itemsForRequest(const RequestPointer &request)
RequestPointer && RequestPointerArgument
QQmlJS::Dom::DomItem domItem
This class sends a result or an error when going out of scope.
bool setErrorFrom(const std::variant< T... > &variant)