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 DOCUMENT_SYMBOL_UTILS_P_H
5#define DOCUMENT_SYMBOL_UTILS_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 <QtQmlDom/private/qqmldom_fwd_p.h>
19#include <qxpfunctional.h>
20
21QT_BEGIN_NAMESPACE
22
23namespace QLspSpecification {
24class DocumentSymbol;
25class Range;
26enum class SymbolKind;
27} // namespace QLspSpecification
28
29namespace DocumentSymbolUtils {
30
31using QQmlJS::Dom::DomItem;
32using SymbolsList = QList<QLspSpecification::DocumentSymbol>;
33using AssemblingFunction =
34 qxp::function_ref<SymbolsList(const QQmlJS::Dom::DomItem &item, SymbolsList &&) const>;
35
36[[nodiscard]] SymbolsList buildSymbolOrReturnChildren(const DomItem &item, SymbolsList &&children);
37
38[[nodiscard]] std::pair<QLspSpecification::Range, QLspSpecification::Range>
39symbolRangesOf(const DomItem &item);
40
41[[nodiscard]] QByteArray symbolNameOf(const DomItem &item);
42
43[[nodiscard]] QLspSpecification::SymbolKind symbolKindOf(const DomItem &item);
44
45[[nodiscard]] std::optional<QByteArray> tryGetDetailOf(const DomItem &item);
46
47[[nodiscard]] SymbolsList
48assembleSymbolsForQmlFile(const DomItem &item,
49 const AssemblingFunction af = buildSymbolOrReturnChildren);
50
51void reorganizeForOutlineView(SymbolsList &symbols);
52} // namespace DocumentSymbolUtils
53
54QT_END_NAMESPACE
55
56#endif // DOCUMENT_SYMBOL_UTILS_P_H
57

source code of qtdeclarative/src/qmlls/documentSymbolSupport/documentsymbolutils_p.h