Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
sharedcommentnode.cpp
Go to the documentation of this file.
1// Copyright (C) 2021 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
3
5
6#include "aggregate.h"
7#include "functionnode.h"
8#include "qmltypenode.h"
9
11
12using namespace Qt::StringLiterals;
13
14SharedCommentNode::SharedCommentNode(QmlTypeNode *parent, int count, QString &group)
15 : Node(NodeType::SharedComment, parent, group)
16{
17 m_collective.reserve(count);
18}
19
20/*!
21 Returns the logical module name of the parent, as for the
22 QML methods and properties that the shared comment documents.
23 */
25{
26 return parent()->logicalModuleName();
27}
28
29/*!
30 Searches the shared comment node's member nodes for function
31 nodes. Each function node's overload flag is set.
32
33 If the shared comment is marked with \\overload primary, only the
34 first function in the collective is marked as the primary overload.
35 */
37{
38 // Check if this is \overload primary
39 const auto &overloadArgs = doc().overloadList();
40 bool isPrimaryOverload = !overloadArgs.isEmpty()
41 && overloadArgs.first().first == "__qdoc_primary_overload__"_L1;
42
43 size_t functionIndex = 0;
44 for (auto *node : m_collective) {
45 if (node->isFunction()) {
46 auto *fn = static_cast<FunctionNode *>(node);
47
48 // Only the FIRST function in a shared comment gets the primary flag
49 if (isPrimaryOverload && functionIndex == 0)
50 fn->setPrimaryOverloadFlag();
51
52 fn->setOverloadFlag();
53 ++functionIndex;
54 }
55 }
56}
57
58/*!
59 Clone this node on the heap and make the clone a child of
60 \a parent.
61
62 Returns the pointer to the clone.
63 */
65{
66 auto *scn = new SharedCommentNode(*this); // shallow copy
67 scn->setParent(nullptr);
68 parent->addChild(scn);
69
70 return scn;
71}
72
73/*!
74 Sets the related nonmember flag in this node and in each
75 node in the shared comment's collective to \a value.
76 */
78{
80 for (auto *node : m_collective)
81 node->setRelatedNonmember(value);
82}
83
84QT_END_NAMESPACE
void addChild(Node *child)
Adds the child to this node's child list and sets the child's parent pointer to this Aggregate.
void setOverloadFlags()
Searches the shared comment node's member nodes for function nodes.
Node * clone(Aggregate *parent) override
Clone this node on the heap and make the clone a child of parent.
void setRelatedNonmember(bool value) override
Sets the related nonmember flag in this node and in each node in the shared comment's collective to v...
SharedCommentNode(QmlTypeNode *parent, int count, QString &group)
QString logicalModuleName() const override
Returns the logical module name of the parent, as for the QML methods and properties that the shared ...
NodeType
Definition genustypes.h:165
@ SharedComment
Definition genustypes.h:188
Combined button and popup list for selecting options.
The Node class is the base class for all the nodes in QDoc's parse tree.
const Doc & doc() const
Returns a reference to the node's Doc data member.
Definition node.h:239
Aggregate * parent() const
Returns the node's parent pointer, that is, the aggregate under which the node is documented.
Definition node.h:211
virtual void setRelatedNonmember(bool b)
Sets a flag in the node indicating whether this node is a related nonmember of something.
Definition node.h:188
void setParent(Aggregate *n)
Sets the node's parent pointer to n.
Definition node.h:182