1// Copyright (C) 2024 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QQMLLSHELPUTILS_P_H
5#define QQMLLSHELPUTILS_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtQmlLS/private/qqmllshelpplugininterface_p.h>
19#include <QtQmlLS/private/qqmllsutils_p.h>
20#include <QtQmlDom/private/qqmldomtop_p.h>
21#include <QtQmlLS/private/qdochtmlparser_p.h>
22#include <QtLanguageServer/private/qlanguageserverspectypes_p.h>
23
24#include <vector>
25
26QT_BEGIN_NAMESPACE
27
28Q_DECLARE_LOGGING_CATEGORY(QQmlLSHelpUtilsLog);
29
30using namespace QQmlJS::Dom;
31
32class HelpManager final
33{
34public:
35 HelpManager();
36 void setDocumentationRootPath(const QString &path);
37 [[nodiscard]] QString documentationRootPath() const;
38 [[nodiscard]] std::optional<QByteArray> documentationForItem(
39 const QQmlJS::Dom::DomItem &file, QLspSpecification::Position position);
40
41private:
42 [[nodiscard]] std::optional<QByteArray> extractDocumentationForIdentifiers(const QQmlJS::Dom::DomItem &item,
43 QQmlLSUtils::ExpressionType expr) const;
44 [[nodiscard]] std::optional<QByteArray> extractDocumentationForDomElements(
45 const QQmlJS::Dom::DomItem &item) const;
46 [[nodiscard]] std::optional<QByteArray> extractDocumentation(
47 const QQmlJS::Dom::DomItem &item) const;
48 [[nodiscard]] std::optional<QByteArray> tryExtract(ExtractDocumentation &extractor,
49 const std::vector<QQmlLSHelpProviderBase::DocumentLink> &links,
50 const QString &name) const;
51 [[nodiscard]] std::vector<QQmlLSHelpProviderBase::DocumentLink>
52 collectDocumentationLinks(const QQmlJS::Dom::DomItem &item, const QQmlJSScope::ConstPtr &scope,
53 const QString &name) const;
54 void registerDocumentations(const QStringList &docs) const;
55 std::unique_ptr<QQmlLSHelpProviderBase> m_helpPlugin;
56 QString m_docRootPath;
57 QHash<QString, QString> m_cppTypesToQmlTypes;
58};
59
60QT_END_NAMESPACE
61
62#endif // QQMLLSHELPUTILS_P_H
63

Provided by KDAB

Privacy Policy
Learn Advanced QML with KDAB
Find out more

source code of qtdeclarative/src/qmlls/qqmllshelputils_p.h