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
28class HelpManager final
29{
30public:
31 HelpManager();
32 void setDocumentationRootPath(const QString &path);
33 [[nodiscard]] QString documentationRootPath() const;
34 [[nodiscard]] std::optional<QByteArray> documentationForItem(
35 const QQmlJS::Dom::DomItem &file, QLspSpecification::Position position);
36
37private:
38 [[nodiscard]] std::optional<QByteArray> extractDocumentationForIdentifiers(const QQmlJS::Dom::DomItem &item,
39 QQmlLSUtils::ExpressionType expr) const;
40 [[nodiscard]] std::optional<QByteArray> extractDocumentationForDomElements(
41 const QQmlJS::Dom::DomItem &item) const;
42 [[nodiscard]] std::optional<QByteArray> extractDocumentation(
43 const QQmlJS::Dom::DomItem &item) const;
44 [[nodiscard]] std::optional<QByteArray> tryExtract(ExtractDocumentation &extractor,
45 const std::vector<QQmlLSHelpProviderBase::DocumentLink> &links,
46 const QString &name) const;
47 [[nodiscard]] std::vector<QQmlLSHelpProviderBase::DocumentLink>
48 collectDocumentationLinks(const QQmlJS::Dom::DomItem &item, const QQmlJSScope::ConstPtr &scope,
49 const QString &name) const;
50 void registerDocumentations(const QStringList &docs) const;
51 std::unique_ptr<QQmlLSHelpProviderBase> m_helpPlugin;
52 QString m_docRootPath;
53 QHash<QString, QString> m_cppTypesToQmlTypes;
54};
55
56QT_END_NAMESPACE
57
58#endif // QQMLLSHELPUTILS_P_H
59

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