17#include <QtCore/qspan.h>
21using namespace Qt::Literals::StringLiterals;
26
27
30
31
32
33
34
37
38
39
40
41
44 for (
auto &child : m_children) {
47 if (child->parent() !=
this)
49 else if (child->isAggregate())
50 static_cast<Aggregate*>(child)->dropNonRelatedMembers();
55
56
60 if (isNamespace() && name().isEmpty())
61 dropNonRelatedMembers();
63 m_enumChildren.clear();
64 m_nonfunctionMap.clear();
65 m_functionMap.clear();
71
72
73
74
75
76
77
78
79
82 if (genus == Genus::DontCare) {
83 Node *node = m_nonfunctionMap.value(name);
87 const NodeList &nodes = m_nonfunctionMap.values(name);
88 for (
auto *node : nodes) {
89 if (node->isInternal())
91 if (hasCommonGenusType(genus, node->genus())) {
92 if (findFlags & TypesOnly) {
93 if (!node->isTypedef() && !node->isClassNode()
94 && !node->isQmlType() && !node->isEnumType())
96 }
else if (findFlags & IgnoreModules && node->isModule())
102 if (genus != Genus::DontCare && !(hasCommonGenusType(genus,
this->genus())))
108 auto it = m_functionMap.find(name);
109 return it != m_functionMap.end() ? (*(*it).begin()) :
nullptr;
113
114
115
119 const auto &functions = m_functionMap.value(name);
120 nodes.reserve(functions.size() + m_nonfunctionMap.count(name));
121 for (
auto f : functions)
122 nodes.emplace_back(f);
123 auto [it, end] = m_nonfunctionMap.equal_range(name);
125 nodes.emplace_back(*it);
131
132
133
134
135
136
139 const NodeList &nodes = m_nonfunctionMap.values(name);
140 for (
auto *node : nodes) {
141 if ((node->*(isMatch))())
148
149
150
151
152
153
154
155
158 auto map_it = m_functionMap.find(name);
159 if (map_it == m_functionMap.end())
169 for (
auto *fn : *map_it) {
171 if (fn->isPrimaryOverload() && !fn->isInternal())
177 if (!fallback && !fn->isInternal() && !fn->isDeprecated()
178 && !fn->isDeletedAsWritten())
182 if (!lastResort && !fn->isInternal() && !fn->isDeletedAsWritten())
186 if (!deletedFallback && !fn->isInternal())
187 deletedFallback = fn;
197 return deletedFallback;
201 auto match_it =
std::find_if((*map_it).begin(), (*map_it).end(),
207 for (
int i = 0; i < parameters
.count(); ++i)
213 return (match_it != (*map_it).end()) ? *match_it :
nullptr;
217
218
219
220
221
222
225 auto funcs_it = m_functionMap.find(clone->name());
226 if (funcs_it == m_functionMap.end())
229 auto func_it =
std::find_if((*funcs_it).begin(), (*funcs_it).end(),
234 return func_it != (*funcs_it).end() ? *func_it :
nullptr;
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
285 auto &config = Config::instance();
294 if (Config::matchesInternalFilePattern(
296 config.getInternalFilePatternsCompiled()))
301 "No output generated for %1 '%2' because '%3' is undocumented"_L1
302 .arg(child->nodeTypeString(),
303 child->plainFullName(),
304 child->parent()->name()));
309
310
311
314 for (
auto *child : std::as_const(m_children)) {
315 if (!child->hasDoc() && !child->isDontDocument()) {
316 if (!child->docMustBeGenerated()) {
317 if (child->isFunction()) {
318 if (
static_cast<FunctionNode *>(child)->hasAssociatedProperties())
320 }
else if (child->isTypedef() && child->isInAPI()) {
321 if (
static_cast<TypedefNode *>(child)->hasAssociatedEnum())
324 child->setStatus(Status::InternalAuto);
327 warnAboutDocumentedChildInUndocumentedParent(
this, child);
329 if (child->isAggregate()) {
330 static_cast<Aggregate *>(child)->markUndocumentedChildrenInternal();
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
358 "Failed to find \\relates target '%1' for %2"_L1.arg(target, node->fullName()));
364 const NodeList nodes = node->isSharedCommentNode()
365 ?
static_cast<SharedCommentNode *>(node)->collective()
367 if (aggregate->isIndexNode()) {
368 for (
auto *n : nodes)
369 n->tree()->addExternalRelates(n, aggregate->plainFullName());
372 auto &related = aggregate->relatedByProxy();
373 for (
auto *n : nodes) {
374 if (!related.contains(n))
380
381
382
383
384
385
386
387
388
389
390
391
392
402 for (
auto *node : children) {
403 if (node->genus() != Genus::CPP)
406 if (!node->isAggregate()) {
407 const auto &relates_args = node->doc().metaCommandArgs(
"relates"_L1);
408 if (relates_args.isEmpty())
416 if (node->isRelatedNonmember() && node->parent() !=
this)
419 auto *aggregate = database->findRelatesNode(relates_args[0].first.split(
"::"_L1));
421 Location().report(
"Failed to find \\relates target '%1' for %2"_L1
422 .arg(relates_args[0].first, node->fullName()));
424 if (!aggregate || aggregate->isIndexNode())
425 aggregate =
new ProxyNode(
this, relates_args[0].first);
427 if (node->parent() != aggregate) {
428 aggregate->adoptChild(node);
429 node->setRelatedNonmember(
true);
435 for (
const auto &arg : QSpan<
const ArgPair>(relates_args).sliced(1))
436 addToRelatedTarget(node, arg.first);
438 static_cast<Aggregate*>(node)->resolveRelates();
444
445
446
447
448
449
450
451
452
453
454
455
458 for (
auto &map_it : m_functionMap) {
459 if (map_it.size() == 1) {
460 map_it.front()->setOverloadNumber(0);
461 }
else if (map_it.size() > 1) {
463 std::vector<
const FunctionNode*> primaryOverloads;
464 for (
const auto *fn : map_it) {
465 if (!fn->isPrimaryOverload())
469 const auto *currentLocation = &(fn->doc().location());
470 for (
const auto *existingPrimary : primaryOverloads) {
471 const auto *existingLocation = &(existingPrimary->doc().location());
473 if (*currentLocation != *existingLocation) {
474 fn->doc().location().warning(
475 "Multiple primary overloads for '%1'. The previous primary is here: %2"_L1
476 .arg(fn->name(), existingPrimary->doc().location().toString()));
481 primaryOverloads.push_back(fn);
484 std::sort(map_it.begin(), map_it.end(),
485 [](
const FunctionNode *f1,
const FunctionNode *f2) ->
bool {
486 if (f1->isInternal() != f2->isInternal())
487 return f2->isInternal();
489 if (f1->isPrimaryOverload() != f2->isPrimaryOverload())
490 return f1->isPrimaryOverload();
491 if (f1->isOverload() != f2->isOverload())
492 return f2->isOverload();
494 if (f1->hasDoc() != f2->hasDoc())
496 return (compare(f1, f2) < 0);
504 for (
auto *fn : map_it) {
505 if (fn->hasDoc() && fn->parent() ==
this)
506 fn->setOverloadNumber(n++);
511 for (
auto *node : std::as_const(m_children)) {
512 if (node->isAggregate())
513 static_cast<Aggregate *>(node)->normalizeOverloads();
518
519
520
521
522
523
524
529 std::remove_if(result.begin(), result.end(),
530 [](
const Node *node) {
538
539
540
543
544
545
546
547
550 for (
const auto *node : m_enumChildren) {
551 const auto *en =
static_cast<
const EnumNode *>(node);
552 if (en->hasItem(enumValue))
559
560
561
562
563
566 m_nonfunctionMap.insert(title, child);
570
571
572
573
574
575
576
577
578
579
580
581
582
583
588 child->setUrl(QString());
592 m_functionMap[child->name()].emplace_back(
static_cast<FunctionNode *>(child));
593 }
else if (!child->name().isEmpty()) {
594 m_nonfunctionMap.insert(child->name(), child);
596 m_enumChildren.append(child);
601
602
603
604
605
606
607
608
609
610
611
620 m_functionMap[child->name()].emplace_back(
static_cast<FunctionNode *>(child));
621 }
else if (!child->name().isEmpty()) {
622 m_nonfunctionMap.insert(child->name(), child);
624 m_enumChildren.append(child);
627 auto *scn =
static_cast<SharedCommentNode *>(child);
628 for (Node *n : scn->collective())
635
636
637
641 for (
auto *child : std::as_const(m_children)) {
642 if (child->nodeType() == goal) {
643 if (child->name() == n) {
644 if (attached == AnyProperties
645 || (child->isAttached() && attached == AttachedProperties)
646 || (!child->isAttached() && attached == UnattachedProperties))
647 return static_cast<QmlPropertyNode *>(child);
655
656
657
658
659
662 auto it = m_functionMap.find(fn->name());
663 return !(it == m_functionMap.end()) && (it.value().size() > 1);
667
668
669
670
671
672
673
682
683
684
685
686
687
688
691 for (
auto functions : m_functionMap) {
692 std::for_each(functions.begin(), functions.end(),
693 [&functionIndex](FunctionNode *fn) {
695 functionIndex[fn->name()].insert(fn->parent()->fullDocumentName(), fn);
700 for (Node *node : std::as_const(m_children)) {
701 if (node->isAggregate() && !node->isPrivate() && !node->isDontDocument())
702 static_cast<Aggregate *>(node)->findAllFunctions(functionIndex);
707
708
709
710
711
712
713
714
715
716
717
718
719
722 for (
auto *node : std::as_const(m_children)) {
723 if (node->isAggregate() && !node->isPrivate()) {
724 if (node->isNamespace() && !node->name().isEmpty())
725 namespaces.insert(node->name(), node);
726 static_cast<Aggregate *>(node)->findAllNamespaces(namespaces);
732
733
734
737 for (
const auto *node : m_children)
738 if (!node->isPrivate() && node->isDeprecated()) {
739 if (node->isFunction() || node->isProperty() || node->isEnumType() || node->isTypedef()
740 || node->isTypeAlias() || node->isVariable() || node->isQmlProperty())
747
748
749
750
751
754 for (
auto *node : std::as_const(m_children)) {
755 if (!node->isPrivate()) {
756 if (node->isDeprecated()) {
757 if (node->isClassNode())
758 QDocDatabase::obsoleteClasses().insert(node->qualifyCppName(), node);
759 else if (node->isQmlType())
760 QDocDatabase::obsoleteQmlTypes().insert(node->qualifyQmlName(), node);
761 }
else if (node->isClassNode()) {
762 auto *a =
static_cast<Aggregate *>(node);
763 if (a->hasObsoleteMembers())
764 QDocDatabase::classesWithObsoleteMembers().insert(node->qualifyCppName(), node);
765 }
else if (node->isQmlType()) {
766 auto *a =
static_cast<Aggregate *>(node);
767 if (a->hasObsoleteMembers())
768 QDocDatabase::qmlTypesWithObsoleteMembers().insert(node->qualifyQmlName(),
770 }
else if (node->isAggregate()) {
771 static_cast<Aggregate *>(node)->findAllObsoleteThings();
778
779
780
781
784 for (
auto *node : std::as_const(m_children)) {
785 if (!node->isPrivate() && !node->isInternal() && !node->isDontDocument()
786 && node->tree()->camelCaseModuleName() != QString(
"QDoc")) {
787 if (node->isClassNode()) {
788 QDocDatabase::cppClasses().insert(node->qualifyCppName().toLower(), node);
789 }
else if (node->isQmlType()) {
790 QString name = node->name().toLower();
791 QDocDatabase::qmlTypes().insert(name, node);
793 if (node->isQmlBasicType())
794 QDocDatabase::qmlBasicTypes().insert(name, node);
795 }
else if (node->isExample()) {
797 QString title = node->tree()->indexTitle();
798 if (!QDocDatabase::examples().contains(title, node))
799 QDocDatabase::examples().insert(title, node);
800 }
else if (node->isAggregate()) {
801 static_cast<Aggregate *>(node)->findAllClasses();
808
809
810
813 for (
auto *node : std::as_const(m_children)) {
814 if (!node->isPrivate()) {
815 if (node->isPageNode() &&
static_cast<PageNode*>(node)->isAttribution())
816 attributions.insert(node->tree()->indexTitle(), node);
817 else if (node->isAggregate())
818 static_cast<Aggregate *>(node)->findAllAttributions(attributions);
824
825
826
827
828
829
830
833 for (
auto *node : std::as_const(m_children)) {
834 if (node->isRelatedNonmember() && node->parent() !=
this)
836 QString sinceString = node->since();
838 if (node->isInAPI() && !sinceString.isEmpty()) {
841 auto &nsmap = QDocDatabase::newSinceMaps()[sinceString];
842 auto &ncmap = QDocDatabase::newClassMaps()[sinceString];
843 auto &nqcmap = QDocDatabase::newQmlTypeMaps()[sinceString];
845 if (node->isFunction()) {
847 auto *fn =
static_cast<FunctionNode *>(node);
848 if (!fn->isDeprecated() && !fn->isSomeCtor() && !fn->isDtor())
849 nsmap.insert(fn->name(), fn);
850 }
else if (node->isClassNode()) {
852 QString name = node->qualifyWithParentName();
853 nsmap.insert(name, node);
854 ncmap.insert(name, node);
855 }
else if (node->isQmlType()) {
857 QString name = node->qualifyWithParentName();
858 nsmap.insert(name, node);
859 nqcmap.insert(name, node);
860 }
else if (node->isQmlProperty()) {
862 nsmap.insert(node->name(), node);
863 }
else if (node->isConcept()) {
865 nsmap.insert(node->qualifyWithParentName(), node);
868 QString name = node->qualifyWithParentName();
869 nsmap.insert(name, node);
873 if (node->isInAPI() && node->isEnumType()) {
874 for (
const auto &val :
static_cast<EnumNode *>(node)->items()) {
875 sinceString = val.since();
876 if (sinceString.isEmpty())
879 QDocDatabase::newEnumValueMaps()[sinceString].insert(
880 node->name() +
"::" + val.name(), node);
884 QDocDatabase::newSinceMaps()[sinceString].replace(QString(), node);
889 if (node->isAggregate())
890 static_cast<Aggregate *>(node)->findAllSince();
895
896
897
901 for (
auto *child : std::as_const(m_children)) {
902 if (!child->isQmlType())
904 static_cast<QmlTypeNode *>(child)->resolveInheritance(previousSearches);
908 for (
auto *child : std::as_const(m_children)) {
909 if (child->isQmlType())
910 static_cast<QmlTypeNode *>(child)->checkInheritance();
915
916
917
918
923 case NodeType::Class:
925 case NodeType::Struct:
927 case NodeType::Union:
929 case NodeType::Namespace:
930 return "Namespace"_L1;
936 case NodeType::Class:
938 case NodeType::Struct:
940 case NodeType::Union:
942 case NodeType::Namespace:
943 return "namespace"_L1;
952
953
956
957
960
961
964
965
968
969
970
971
972
975
976
977
978
981
982
983
984
985
988
989
990
991
992
993
994
995
static void warnAboutDocumentedChildInUndocumentedParent(const Node *aggregate, const Node *child)
static bool keep(FunctionNode *fn)
static void addToRelatedTarget(Node *node, const QString &target)
NodeList nonFunctionChildren() const
Returns a copy of the child nodes of this aggregate that are not function nodes, in the order they ap...
void resolveRelates()
Adopts each non-aggregate C++ node (function/macro, typedef, enum, variable, or a shared comment node...
void adoptChild(Node *child)
This Aggregate becomes the adoptive parent of child.
QString typeWord(bool cap) const
Returns a word representing the kind of Aggregate this node is.
void resolveQmlInheritance()
Resolves the inheritance information for all QML type children of this aggregate.
void addChildByTitle(Node *child, const QString &title)
Adds the child to this node's child map using title as the key.
bool hasOverloads(const FunctionNode *fn) const
Returns true if this aggregate has multiple function overloads matching the name of fn.
void findAllObsoleteThings()
Finds all the obsolete C++ classes and QML types in this aggregate and all the C++ classes and QML ty...
~Aggregate() override
Destroys this Aggregate; deletes each child.
void findChildren(const QString &name, NodeVector &nodes) const
Find all the child nodes of this node that are named name and return them in nodes.
bool hasObsoleteMembers() const
Returns true if this aggregate contains at least one child that is marked obsolete.
FunctionNode * findFunctionChild(const QString &name, const Parameters ¶meters)
Find a function node that is a child of this node, such that the function node has the specified name...
void findAllSince()
Finds all the nodes in this node where a {since} command appeared in the qdoc comment and sorts them ...
void normalizeOverloads()
Sorts the lists of overloads in the function map and assigns overload numbers.
Node * findNonfunctionChild(const QString &name, bool(Node::*)() const)
This function searches for a child node of this Aggregate, such that the child node has the spacified...
void findAllFunctions(NodeMapMap &functionIndex)
Insert all functions declared in this aggregate into the functionIndex.
void findAllNamespaces(NodeMultiMap &namespaces)
For each child of this node, if the child is a namespace node, insert the child into the namespaces m...
void markUndocumentedChildrenInternal()
Mark all child nodes that have no documentation as having internal status.
QmlPropertyNode * hasQmlProperty(const QString &, PropertySearchType attached=AnyProperties) const
If this node has a child that is a QML property named n and that also matches attached,...
void addChild(Node *child)
Adds the child to this node's child list and sets the child's parent pointer to this Aggregate.
Node * findChildNode(const QString &name, Genus genus, int findFlags=0) const
If genus is {Node::DontCare}, find the first node in this node's child list that has the given name.
FunctionNode * findFunctionChild(const FunctionNode *clone)
Returns the function node that is a child of this node, such that the function described has the same...
void findAllClasses()
Finds all the C++ classes, QML types, QML basic types, and examples in this aggregate and inserts the...
void findAllAttributions(NodeMultiMap &attributions)
Find all the attribution pages in this node and insert them into attributions.
const EnumNode * findEnumNodeForValue(const QString &enumValue) const
Finds the enum type node that has enumValue as one of its enum values and returns a pointer to it.
const Location & location() const
Returns the starting location of a qdoc comment.
bool isAutoGenerated() const
Returns true if this documentation was auto-generated by QDoc rather than written by an author.
This node is used to represent any kind of function being documented.
const Parameters & parameters() const
bool isDeprecated() const override
\reimp
friend int compare(const FunctionNode *f1, const FunctionNode *f2)
Compares FunctionNode f1 with f2, assumed to have identical names.
static bool processInternalDocs(const InclusionPolicy &policy)
The Location class provides a way to mark a location in a file.
Location()
Constructs an empty location.
bool isEmpty() const
Returns true if there is no file name set yet; returns false otherwise.
This class provides exclusive access to the qdoc database, which consists of a forrest of trees and a...
static QDocDatabase * qdocDB()
Creates the singleton.
Status
Specifies the status of the QQmlIncubator.
#define CONFIG_NOLINKERRORS
QList< Node * > NodeVector
QMap< QString, Node * > NodeMap
QMap< QString, NodeMap > NodeMapMap
QMultiMap< QString, Node * > NodeMultiMap
The Node class is the base class for all the nodes in QDoc's parse tree.
bool isDontDocument() const
Returns true if this node's status is DontDocument.
const Doc & doc() const
Returns a reference to the node's Doc data member.
bool isPrivate() const
Returns true if this node's access is Private.
void setIndexNodeFlag(bool isIndexNode=true)
Sets a flag in this Node that indicates the node was created for something in an index file.
bool isNamespace() const
Returns true if the node type is Namespace.
void setDeclarationParent(Aggregate *n)
Sets the node's declaration parent pointer to n, the aggregate in whose C++ scope the node was declar...
bool isSharedCommentNode() const
Returns true if the node type is SharedComment.
virtual bool isInternal() const
Returns true if the node's status is Internal, or if its parent is a class with Internal status.
NodeType nodeType() const override
Returns this node's type.
Genus genus() const override
Returns this node's Genus.
bool isEnumType() const
Returns true if the node type is Enum.
virtual Status status() const
Returns the node's status value.
Aggregate * parent() const
Returns the node's parent pointer, that is, the aggregate under which the node is documented.
bool isProxyNode() const
Returns true if the node type is Proxy.
bool isFunction(Genus g=Genus::DontCare) const
Returns true if this is a FunctionNode and its Genus is set to g.
const Location & declLocation() const
Returns the Location where this node's declaration was seen.
bool hasDoc() const
Returns true if this node is documented, or it represents a documented node read from the index ('had...
void setParent(Aggregate *n)
Sets the node's parent pointer to n.
Aggregate * declarationParent() const
Returns the aggregate in whose C++ scope the node was declared, or null if the node was not adopted b...
bool isIndexNode() const
Returns true if this node was created from something in an index file.
A class for parsing and managing a function parameter list.
const Parameter & at(int i) const