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 Searches the shared comment node's member nodes for function
22 nodes. Each function node's overload flag is set.
23
24 If the shared comment is marked with \\overload primary, only the
25 first function in the collective is marked as the primary overload.
26 */
28{
29 // Check if this is \overload primary
30 const auto &overloadArgs = doc().overloadList();
31 bool isPrimaryOverload = !overloadArgs.isEmpty()
32 && overloadArgs.first().first == "__qdoc_primary_overload__"_L1;
33
34 size_t functionIndex = 0;
35 for (auto *node : m_collective) {
36 if (node->isFunction()) {
37 auto *fn = static_cast<FunctionNode *>(node);
38
39 // Only the FIRST function in a shared comment gets the primary flag
40 if (isPrimaryOverload && functionIndex == 0)
41 fn->setPrimaryOverloadFlag();
42
43 fn->setOverloadFlag();
44 ++functionIndex;
45 }
46 }
47}
48
49/*!
50 Clone this node on the heap and make the clone a child of
51 \a parent.
52
53 Returns the pointer to the clone.
54 */
56{
57 auto *scn = new SharedCommentNode(*this); // shallow copy
58 scn->setParent(nullptr);
59 parent->addChild(scn);
60
61 return scn;
62}
63
64/*!
65 Sets the related nonmember flag in this node and in each
66 node in the shared comment's collective to \a value.
67 */
69{
71 for (auto *node : m_collective)
72 node->setRelatedNonmember(value);
73}
74
75QT_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)
NodeType
Definition genustypes.h:150
@ SharedComment
Definition genustypes.h:173
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:242
virtual void setRelatedNonmember(bool b)
Sets a flag in the node indicating whether this node is a related nonmember of something.
Definition node.h:192
void setParent(Aggregate *n)
Sets the node's parent pointer to n.
Definition node.h:187