1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
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
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
|
/****************************************************************************
**
** Copyright (C) 2019 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:GPL-EXCEPT$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "tree.h"
#include "doc.h"
#include "htmlgenerator.h"
#include "location.h"
#include "node.h"
#include "qdocdatabase.h"
#include "text.h"
#include <QtCore/qdebug.h>
#include <limits.h>
QT_BEGIN_NAMESPACE
/*!
\class Tree
This class constructs and maintains a tree of instances of
the subclasses of Node.
This class is now private. Only class QDocDatabase has access.
Please don't change this. If you must access class Tree, do it
though the pointer to the singleton QDocDatabase.
Tree is being converted to a forest. A static member provides a
map of Tree *values with the module names as the keys. There is
one Tree in the map for each index file read, and there is one
tree that is not in the map for the module whose documentation
is being generated.
*/
/*!
Constructs a Tree. \a qdb is the pointer to the singleton
qdoc database that is constructing the tree. This might not
be necessary, and it might be removed later.
\a camelCaseModuleName is the project name for this tree
as it appears in the qdocconf file.
*/
Tree::Tree(const QString &camelCaseModuleName, QDocDatabase *qdb)
: treeHasBeenAnalyzed_(false),
docsHaveBeenGenerated_(false),
linkCount_(0),
camelCaseModuleName_(camelCaseModuleName),
physicalModuleName_(camelCaseModuleName.toLower()),
qdb_(qdb),
root_(nullptr, QString()),
targetListMap_(nullptr)
{
root_.setPhysicalModuleName(physicalModuleName_);
root_.setTree(this);
const auto &config = Config::instance();
if (config.getBool(CONFIG_WRITEQAPAGES))
targetListMap_ = new TargetListMap;
}
/*!
Destroys the Tree. The root node is a data member
of this object, so its destructor is called. The
destructor of each child node is called, and these
destructors are recursive. Thus the entire tree is
destroyed.
There are two maps of targets, keywords, and contents.
One map is indexed by ref, the other by title. The ref
is just the canonical form of the title. Both maps
use the same set of TargetRec objects as the values,
so the destructor only deletes the values from one of
the maps. Then it clears both maps.
*/
Tree::~Tree()
{
for (auto i = nodesByTargetRef_.begin(); i != nodesByTargetRef_.end(); ++i) {
delete i.value();
}
nodesByTargetRef_.clear();
nodesByTargetTitle_.clear();
const auto &config = Config::instance();
if (config.getBool(CONFIG_WRITEQAPAGES) && targetListMap_) {
for (auto target = targetListMap_->begin(); target != targetListMap_->end(); ++target) {
TargetList *tlist = target.value();
if (tlist) {
for (auto *location : qAsConst(*tlist))
delete location;
}
delete tlist;
}
}
}
/* API members */
/*!
Calls findClassNode() first with \a path and \a start. If
it finds a node, the node is returned. If not, it calls
findNamespaceNode() with the same parameters. The result
is returned.
*/
Node *Tree::findNodeForInclude(const QStringList &path) const
{
Node *n = findClassNode(path);
if (n == nullptr)
n = findNamespaceNode(path);
return n;
}
/*!
This function searches this tree for an Aggregate node with
the specified \a name. It returns the pointer to that node
or nullptr.
We might need to split the name on '::' but we assume the
name is a single word at the moment.
*/
Aggregate *Tree::findAggregate(const QString &name)
{
QStringList path = name.split(QLatin1String("::"));
return static_cast<Aggregate *>(findNodeRecursive(path, 0, const_cast<NamespaceNode *>(root()),
&Node::isFirstClassAggregate));
}
/*!
Find the C++ class node named \a path. Begin the search at the
\a start node. If the \a start node is 0, begin the search
at the root of the tree. Only a C++ class node named \a path is
acceptible. If one is not found, 0 is returned.
*/
ClassNode *Tree::findClassNode(const QStringList &path, const Node *start) const
{
if (start == nullptr)
start = const_cast<NamespaceNode *>(root());
return static_cast<ClassNode *>(findNodeRecursive(path, 0, start, &Node::isClassNode));
}
/*!
Find the Namespace node named \a path. Begin the search at
the root of the tree. Only a Namespace node named \a path
is acceptible. If one is not found, 0 is returned.
*/
NamespaceNode *Tree::findNamespaceNode(const QStringList &path) const
{
Node *start = const_cast<NamespaceNode *>(root());
return static_cast<NamespaceNode *>(findNodeRecursive(path, 0, start, &Node::isNamespace));
}
/*!
Find the Qml type node named \a path. Begin the search at the
\a start node. If the \a start node is 0, begin the search
at the root of the tree. Only a Qml type node named <\a path is
acceptible. If one is not found, 0 is returned.
*/
QmlTypeNode *Tree::findQmlTypeNode(const QStringList &path)
{
/*
If the path contains one or two double colons ("::"),
check first to see if the first two path strings refer
to a QML element. If they do, path[0] will be the QML
module identifier, and path[1] will be the QML type.
If the anser is yes, the reference identifies a QML
class node.
*/
if (path.size() >= 2 && !path[0].isEmpty()) {
QmlTypeNode *qcn = qdb_->findQmlType(path[0], path[1]);
if (qcn != nullptr)
return qcn;
}
return static_cast<QmlTypeNode *>(findNodeRecursive(path, 0, root(), &Node::isQmlType));
}
/*!
This function searches for the node specified by \a path.
The matching node can be one of several different types
including a C++ class, a C++ namespace, or a C++ header
file.
I'm not sure if it can be a QML type, but if that is a
possibility, the code can easily accommodate it.
If a matching node is found, a pointer to it is returned.
Otherwise 0 is returned.
*/
Aggregate *Tree::findRelatesNode(const QStringList &path)
{
Node *n = findNodeRecursive(path, 0, root(), &Node::isRelatableType);
return (((n != nullptr) && n->isAggregate()) ? static_cast<Aggregate *>(n) : nullptr);
}
/*!
Inserts function name \a funcName and function role \a funcRole into
the property function map for the specified \a property.
*/
void Tree::addPropertyFunction(PropertyNode *property, const QString &funcName,
PropertyNode::FunctionRole funcRole)
{
unresolvedPropertyMap[property].insert(funcRole, funcName);
}
/*!
This function resolves C++ inheritance and reimplementation
settings for each C++ class node found in the tree beginning
at \a n. It also calls itself recursively for each C++ class
node or namespace node it encounters.
This function does not resolve QML inheritance.
*/
void Tree::resolveBaseClasses(Aggregate *n)
{
for (auto it = n->constBegin(); it != n->constEnd(); ++it) {
if ((*it)->isClassNode()) {
ClassNode *cn = static_cast<ClassNode *>(*it);
QVector<RelatedClass> &bases = cn->baseClasses();
for (auto &base : bases) {
if (base.node_ == nullptr) {
Node *n = qdb_->findClassNode(base.path_);
/*
If the node for the base class was not found,
the reason might be that the subclass is in a
namespace and the base class is in the same
namespace, but the base class name was not
qualified with the namespace name. That is the
case most of the time. Then restart the search
at the parent of the subclass node (the namespace
node) using the unqualified base class name.
*/
if (n == nullptr) {
Aggregate *parent = cn->parent();
if (parent != nullptr)
// Exclude the root namespace
if (parent->isNamespace() && !parent->name().isEmpty())
n = findClassNode(base.path_, parent);
}
if (n != nullptr) {
ClassNode *bcn = static_cast<ClassNode *>(n);
base.node_ = bcn;
bcn->addDerivedClass(base.access_, cn);
}
}
}
resolveBaseClasses(cn);
} else if ((*it)->isNamespace()) {
resolveBaseClasses(static_cast<NamespaceNode *>(*it));
}
}
}
/*!
*/
void Tree::resolvePropertyOverriddenFromPtrs(Aggregate *n)
{
for (auto node = n->constBegin(); node != n->constEnd(); ++node) {
if ((*node)->isClassNode()) {
ClassNode *cn = static_cast<ClassNode *>(*node);
for (auto property = cn->constBegin(); property != cn->constEnd(); ++property) {
if ((*property)->isProperty())
cn->resolvePropertyOverriddenFromPtrs(static_cast<PropertyNode *>(*property));
}
resolvePropertyOverriddenFromPtrs(cn);
} else if ((*node)->isNamespace()) {
resolvePropertyOverriddenFromPtrs(static_cast<NamespaceNode *>(*node));
}
}
}
/*!
*/
void Tree::resolveProperties()
{
for (auto propEntry = unresolvedPropertyMap.constBegin();
propEntry != unresolvedPropertyMap.constEnd(); ++propEntry) {
PropertyNode *property = propEntry.key();
Aggregate *parent = property->parent();
QString getterName = (*propEntry)[PropertyNode::Getter];
QString setterName = (*propEntry)[PropertyNode::Setter];
QString resetterName = (*propEntry)[PropertyNode::Resetter];
QString notifierName = (*propEntry)[PropertyNode::Notifier];
for (auto it = parent->constBegin(); it != parent->constEnd(); ++it) {
if ((*it)->isFunction()) {
FunctionNode *function = static_cast<FunctionNode *>(*it);
if (function->access() == property->access()
&& (function->status() == property->status() || function->doc().isEmpty())) {
if (function->name() == getterName) {
property->addFunction(function, PropertyNode::Getter);
} else if (function->name() == setterName) {
property->addFunction(function, PropertyNode::Setter);
} else if (function->name() == resetterName) {
property->addFunction(function, PropertyNode::Resetter);
} else if (function->name() == notifierName) {
property->addSignal(function, PropertyNode::Notifier);
}
}
}
}
}
for (auto propEntry = unresolvedPropertyMap.constBegin();
propEntry != unresolvedPropertyMap.constEnd(); ++propEntry) {
PropertyNode *property = propEntry.key();
// redo it to set the property functions
if (property->overriddenFrom())
property->setOverriddenFrom(property->overriddenFrom());
}
unresolvedPropertyMap.clear();
}
/*!
For each QML class node that points to a C++ class node,
follow its C++ class node pointer and set the C++ class
node's QML class node pointer back to the QML class node.
*/
void Tree::resolveCppToQmlLinks()
{
const NodeList &children = root_.childNodes();
for (auto *child : children) {
if (child->isQmlType() || child->isJsType()) {
QmlTypeNode *qcn = static_cast<QmlTypeNode *>(child);
ClassNode *cn = const_cast<ClassNode *>(qcn->classNode());
if (cn)
cn->setQmlElement(qcn);
}
}
}
/*!
For each C++ class node, resolve any \c using clauses
that appeared in the class declaration.
*/
void Tree::resolveUsingClauses()
{
const NodeList &children = root_.childNodes();
for (auto *child : children) {
if (child->isClassNode()) {
ClassNode *cn = static_cast<ClassNode *>(child);
QVector<UsingClause> &usingClauses = cn->usingClauses();
for (auto &usingClause : usingClauses) {
if (usingClause.node() == nullptr) {
const Node *n = qdb_->findFunctionNode(usingClause.signature(), cn, Node::CPP);
if (n != nullptr)
usingClause.setNode(n);
}
}
}
}
}
/*!
Traverse this Tree and for each ClassNode found, remove
from its list of base classes any that are marked private
or internal. When a class is removed from a base class
list, promote its public pase classes to be base classes
of the class where the base class was removed. This is
done for documentation purposes. The function is recursive
on namespace nodes.
*/
void Tree::removePrivateAndInternalBases(NamespaceNode *rootNode)
{
if (rootNode == nullptr)
rootNode = root();
for (auto node = rootNode->constBegin(); node != rootNode->constEnd(); ++node) {
if ((*node)->isClassNode())
static_cast<ClassNode *>(*node)->removePrivateAndInternalBases();
else if ((*node)->isNamespace())
removePrivateAndInternalBases(static_cast<NamespaceNode *>(*node));
}
}
/*!
*/
ClassList Tree::allBaseClasses(const ClassNode *classNode) const
{
ClassList result;
const auto &baseClasses = classNode->baseClasses();
for (const auto &relatedClass : baseClasses) {
if (relatedClass.node_ != nullptr) {
result += relatedClass.node_;
result += allBaseClasses(relatedClass.node_);
}
}
return result;
}
/*!
Find the node with the specified \a path name that is of
the specified \a type and \a subtype. Begin the search at
the \a start node. If the \a start node is 0, begin the
search at the tree root. \a subtype is not used unless
\a type is \c{Page}.
*/
Node *Tree::findNodeByNameAndType(const QStringList &path, bool (Node::*isMatch)() const) const
{
return findNodeRecursive(path, 0, root(), isMatch);
}
/*!
Recursive search for a node identified by \a path. Each
path element is a name. \a pathIndex specifies the index
of the name in \a path to try to match. \a start is the
node whose children shoulod be searched for one that has
that name. Each time a match is found, increment the
\a pathIndex and call this function recursively.
If the end of the path is reached (i.e. if a matching
node is found for each name in the \a path), the \a type
must match the type of the last matching node, and if the
type is \e{Page}, the \a subtype must match as well.
If the algorithm is successful, the pointer to the final
node is returned. Otherwise 0 is returned.
*/
Node *Tree::findNodeRecursive(const QStringList &path, int pathIndex, const Node *start,
bool (Node::*isMatch)() const) const
{
if (start == nullptr || path.isEmpty())
return nullptr;
Node *node = const_cast<Node *>(start);
if (!node->isAggregate())
return ((pathIndex >= path.size()) ? node : nullptr);
Aggregate *current = static_cast<Aggregate *>(node);
const NodeList &children = current->childNodes();
const QString &name = path.at(pathIndex);
for (auto *node : children) {
if (node == nullptr)
continue;
if (node->name() == name) {
if (pathIndex + 1 >= path.size()) {
if ((node->*(isMatch))())
return node;
continue;
} else { // Search the children of n for the next name in the path.
node = findNodeRecursive(path, pathIndex + 1, node, isMatch);
if (node != nullptr)
return node;
}
}
}
return nullptr;
}
/*!
Searches the tree for a node that matches the \a path plus
the \a target. The search begins at \a start and moves up
the parent chain from there, or, if \a start is 0, the search
begins at the root.
The \a flags can indicate whether to search base classes and/or
the enum values in enum types. \a genus can be a further restriction
on what kind of node is an acceptible match, i.e. CPP or QML.
If a matching node is found, \a ref is an output parameter that
is set to the HTML reference to use for the link.
*/
const Node *Tree::findNodeForTarget(const QStringList &path, const QString &target,
const Node *start, int flags, Node::Genus genus,
QString &ref) const
{
const Node *node = nullptr;
if ((genus == Node::DontCare) || (genus == Node::DOC)) {
node = findPageNodeByTitle(path.at(0));
if (node) {
if (!target.isEmpty()) {
ref = getRef(target, node);
if (ref.isEmpty())
node = nullptr;
}
if (node)
return node;
}
}
node = findUnambiguousTarget(path.join(QLatin1String("::")), genus, ref);
if (node) {
if (!target.isEmpty()) {
ref = getRef(target, node);
if (ref.isEmpty())
node = nullptr;
}
if (node)
return node;
}
const Node *current = start;
if (current == nullptr)
current = root();
/*
If the path contains one or two double colons ("::"),
check first to see if the first two path strings refer
to a QML element. If they do, path[0] will be the QML
module identifier, and path[1] will be the QML type.
If the answer is yes, the reference identifies a QML
type node.
*/
int path_idx = 0;
if (((genus == Node::QML) || (genus == Node::DontCare)) && (path.size() >= 2)
&& !path[0].isEmpty()) {
QmlTypeNode *qcn = lookupQmlType(QString(path[0] + "::" + path[1]));
if (qcn) {
current = qcn;
if (path.size() == 2) {
if (!target.isEmpty()) {
ref = getRef(target, current);
if (!ref.isEmpty())
return current;
return nullptr;
} else
return current;
}
path_idx = 2;
}
}
while (current != nullptr) {
if (current->isAggregate()) { // Should this be isPageNode() ???
const Node *node =
matchPathAndTarget(path, path_idx, target, current, flags, genus, ref);
if (node)
return node;
}
current = current->parent();
path_idx = 0;
}
return nullptr;
}
/*!
First, the \a path is used to find a node. The \a path
matches some part of the node's fully quallified name.
If the \a target is not empty, it must match a target
in the matching node. If the matching of the \a path
and the \a target (if present) is successful, \a ref
is set from the \a target, and the pointer to the
matching node is returned. \a idx is the index into the
\a path where to begin the matching. The function is
recursive with idx being incremented for each recursive
call.
The matching node must be of the correct \a genus, i.e.
either QML or C++, but \a genus can be set to \c DontCare.
\a flags indicates whether to search base classes and
whether to search for an enum value. \a node points to
the node where the search should begin, assuming the
\a path is a not a fully-qualified name. \a node is
most often the root of this Tree.
*/
const Node *Tree::matchPathAndTarget(const QStringList &path, int idx, const QString &target,
const Node *node, int flags, Node::Genus genus,
QString &ref) const
{
/*
If the path has been matched, then if there is a target,
try to match the target. If there is a target, but you
can't match it at the end of the path, give up; return 0.
*/
if (idx == path.size()) {
if (!target.isEmpty()) {
ref = getRef(target, node);
if (ref.isEmpty())
return nullptr;
}
if (node->isFunction() && node->name() == node->parent()->name())
node = node->parent();
return node;
}
QString name = path.at(idx);
if (node->isAggregate()) {
NodeVector nodes;
static_cast<const Aggregate *>(node)->findChildren(name, nodes);
for (const auto *node : qAsConst(nodes)) {
if (genus != Node::DontCare && node->genus() != genus)
continue;
const Node *t = matchPathAndTarget(path, idx + 1, target, node, flags, genus, ref);
if (t && !t->isPrivate())
return t;
}
}
if (target.isEmpty()) {
if ((idx) == (path.size() - 1) && node->isAggregate() && (flags & SearchEnumValues)) {
const Node *t =
static_cast<const Aggregate *>(node)->findEnumNodeForValue(path.at(idx));
if (t)
return t;
}
}
if (((genus == Node::CPP) || (genus == Node::DontCare)) && node->isClassNode()
&& (flags & SearchBaseClasses)) {
const ClassList bases = allBaseClasses(static_cast<const ClassNode *>(node));
for (const auto *base : bases) {
const Node *t = matchPathAndTarget(path, idx, target, base, flags, genus, ref);
if (t && !t->isPrivate())
return t;
if (target.isEmpty()) {
if ((idx) == (path.size() - 1) && (flags & SearchEnumValues)) {
t = base->findEnumNodeForValue(path.at(idx));
if (t)
return t;
}
}
}
}
return nullptr;
}
/*!
Searches the tree for a node that matches the \a path. The
search begins at \a start but can move up the parent chain
recursively if no match is found. The \a flags are used to
restrict the search.
*/
const Node *Tree::findNode(const QStringList &path, const Node *start, int flags,
Node::Genus genus) const
{
const Node *current = start;
if (current == nullptr)
current = root();
do {
const Node *node = current;
int i;
int start_idx = 0;
/*
If the path contains one or two double colons ("::"),
check first to see if the first two path strings refer
to a QML element. If they do, path[0] will be the QML
module identifier, and path[1] will be the QML type.
If the answer is yes, the reference identifies a QML
type node.
*/
if (((genus == Node::QML) || (genus == Node::DontCare)) && (path.size() >= 2)
&& !path[0].isEmpty()) {
QmlTypeNode *qcn = lookupQmlType(QString(path[0] + "::" + path[1]));
if (qcn != nullptr) {
node = qcn;
if (path.size() == 2)
return node;
start_idx = 2;
}
}
for (i = start_idx; i < path.size(); ++i) {
if (node == nullptr || !node->isAggregate())
break;
// Clear the TypesOnly flag until the last path segment, as e.g. namespaces are not
// types. We also ignore module nodes as they are not aggregates and thus have no
// children.
int tmpFlags = (i < path.size() - 1) ? (flags & ~TypesOnly) | IgnoreModules : flags;
const Node *next = static_cast<const Aggregate *>(node)->findChildNode(path.at(i),
genus, tmpFlags);
if ((next == nullptr) && (flags & SearchEnumValues) && i == path.size() - 1) {
next = static_cast<const Aggregate *>(node)->findEnumNodeForValue(path.at(i));
}
if ((next == nullptr) && ((genus == Node::CPP) || (genus == Node::DontCare))
&& node->isClassNode() && (flags & SearchBaseClasses)) {
const ClassList bases = allBaseClasses(static_cast<const ClassNode *>(node));
for (const auto *base : bases) {
next = base->findChildNode(path.at(i), genus, tmpFlags);
if ((next == nullptr) && (flags & SearchEnumValues) && i == path.size() - 1)
next = base->findEnumNodeForValue(path.at(i));
if (next != nullptr)
break;
}
}
node = next;
}
if ((node != nullptr) && i == path.size())
return node;
current = current->parent();
} while (current != nullptr);
return nullptr;
}
/*!
This function searches for a node with a canonical title
constructed from \a target. If the node it finds is \a node,
it returns the ref from that node. Otherwise it returns an
empty string.
*/
QString Tree::getRef(const QString &target, const Node *node) const
{
auto it = nodesByTargetTitle_.constFind(target);
if (it != nodesByTargetTitle_.constEnd()) {
do {
if (it.value()->node_ == node)
return it.value()->ref_;
++it;
} while (it != nodesByTargetTitle_.constEnd() && it.key() == target);
}
QString key = Doc::canonicalTitle(target);
it = nodesByTargetRef_.constFind(key);
if (it != nodesByTargetRef_.constEnd()) {
do {
if (it.value()->node_ == node)
return it.value()->ref_;
++it;
} while (it != nodesByTargetRef_.constEnd() && it.key() == key);
}
return QString();
}
/*!
Inserts a new target into the target table. \a name is the
key. The target record contains the \a type, a pointer to
the \a node, the \a priority. and a canonicalized form of
the \a name, which is later used.
*/
void Tree::insertTarget(const QString &name, const QString &title, TargetRec::TargetType type,
Node *node, int priority)
{
TargetRec *target = new TargetRec(name, title, type, node, priority);
nodesByTargetRef_.insert(name, target);
nodesByTargetTitle_.insert(title, target);
}
/*!
*/
void Tree::resolveTargets(Aggregate *root)
{
for (auto *child : root->childNodes()) {
if (child->isTextPageNode()) {
PageNode *node = static_cast<PageNode *>(child);
QString key = node->title();
if (!key.isEmpty()) {
if (key.contains(QChar(' ')))
key = Doc::canonicalTitle(key);
QList<PageNode *> nodes = pageNodesByTitle_.values(key);
bool alreadyThere = false;
if (!nodes.empty()) {
for (const auto &node_ : nodes) {
if (node_->isExternalPage()) {
if (node->name() == node_->name()) {
alreadyThere = true;
break;
}
}
}
}
if (!alreadyThere)
pageNodesByTitle_.insert(key, node);
}
}
if (child->doc().hasTableOfContents()) {
const QVector<Atom *> &toc = child->doc().tableOfContents();
for (int i = 0; i < toc.size(); ++i) {
QString ref = refForAtom(toc.at(i));
QString title = Text::sectionHeading(toc.at(i)).toString();
if (!ref.isEmpty() && !title.isEmpty()) {
QString key = Doc::canonicalTitle(title);
TargetRec *target = new TargetRec(ref, title, TargetRec::Contents, child, 3);
nodesByTargetRef_.insert(key, target);
nodesByTargetTitle_.insert(title, target);
}
}
}
if (child->doc().hasKeywords()) {
const QVector<Atom *> &keywords = child->doc().keywords();
for (int i = 0; i < keywords.size(); ++i) {
QString ref = refForAtom(keywords.at(i));
QString title = keywords.at(i)->string();
if (!ref.isEmpty() && !title.isEmpty()) {
TargetRec *target = new TargetRec(ref, title, TargetRec::Keyword, child, 1);
nodesByTargetRef_.insert(Doc::canonicalTitle(title), target);
nodesByTargetTitle_.insert(title, target);
}
}
}
if (child->doc().hasTargets()) {
const QVector<Atom *> &targets = child->doc().targets();
for (int i = 0; i < targets.size(); ++i) {
QString ref = refForAtom(targets.at(i));
QString title = targets.at(i)->string();
if (!ref.isEmpty() && !title.isEmpty()) {
QString key = Doc::canonicalTitle(title);
TargetRec *target = new TargetRec(ref, title, TargetRec::Target, child, 2);
nodesByTargetRef_.insert(key, target);
nodesByTargetTitle_.insert(title, target);
}
}
}
if (child->isAggregate())
resolveTargets(static_cast<Aggregate *>(child));
}
}
/*!
This function searches for a \a target anchor node. If it
finds one, it sets \a ref and returns the found node.
*/
const Node *Tree::findUnambiguousTarget(const QString &target, Node::Genus genus,
QString &ref) const
{
int numBestTargets = 0;
TargetRec *bestTarget = nullptr;
QVector<TargetRec *> bestTargetList;
QString key = target;
for (auto it = nodesByTargetTitle_.find(key); it != nodesByTargetTitle_.constEnd(); ++it) {
if (it.key() != key)
break;
TargetRec *candidate = it.value();
if ((genus == Node::DontCare) || (genus == candidate->genus())) {
if (!bestTarget || (candidate->priority_ < bestTarget->priority_)) {
bestTarget = candidate;
bestTargetList.clear();
bestTargetList.append(candidate);
numBestTargets = 1;
} else if (candidate->priority_ == bestTarget->priority_) {
bestTargetList.append(candidate);
++numBestTargets;
}
}
}
if (bestTarget) {
ref = bestTarget->ref_;
return bestTarget->node_;
}
numBestTargets = 0;
bestTarget = nullptr;
key = Doc::canonicalTitle(target);
for (auto it = nodesByTargetRef_.find(key); it != nodesByTargetRef_.constEnd(); ++it) {
if (it.key() != key)
break;
TargetRec *candidate = it.value();
if ((genus == Node::DontCare) || (genus == candidate->genus())) {
if (!bestTarget || (candidate->priority_ < bestTarget->priority_)) {
bestTarget = candidate;
bestTargetList.clear();
bestTargetList.append(candidate);
numBestTargets = 1;
} else if (candidate->priority_ == bestTarget->priority_) {
bestTargetList.append(candidate);
++numBestTargets;
}
}
}
if (bestTarget) {
ref = bestTarget->ref_;
return bestTarget->node_;
}
ref.clear();
return nullptr;
}
/*!
This function searches for a node with the specified \a title.
*/
const PageNode *Tree::findPageNodeByTitle(const QString &title) const
{
PageNodeMultiMap::const_iterator it;
if (title.contains(QChar(' ')))
it = pageNodesByTitle_.constFind(Doc::canonicalTitle(title));
else
it = pageNodesByTitle_.constFind(title);
if (it != pageNodesByTitle_.constEnd()) {
/*
Reporting all these duplicate section titles is probably
overkill. We should report the duplicate file and let
that suffice.
*/
PageNodeMultiMap::const_iterator j = it;
++j;
if (j != pageNodesByTitle_.constEnd() && j.key() == it.key()) {
while (j != pageNodesByTitle_.constEnd()) {
if (j.key() == it.key() && j.value()->url().isEmpty()) {
break; // Just report one duplicate for now.
}
++j;
}
if (j != pageNodesByTitle_.cend()) {
it.value()->location().warning("This page title exists in more than one file: "
+ title);
j.value()->location().warning("[It also exists here]");
}
}
return it.value();
}
return nullptr;
}
/*!
Returns a canonical title for the \a atom, if the \a atom
is a SectionLeft or a Target.
*/
QString Tree::refForAtom(const Atom *atom)
{
if (atom) {
if (atom->type() == Atom::SectionLeft)
return Doc::canonicalTitle(Text::sectionHeading(atom).toString());
if ((atom->type() == Atom::Target) || (atom->type() == Atom::Keyword))
return Doc::canonicalTitle(atom->string());
}
return QString();
}
/*!
\fn const CNMap &Tree::groups() const
Returns a const reference to the collection of all
group nodes.
*/
/*!
\fn const ModuleMap &Tree::modules() const
Returns a const reference to the collection of all
module nodes.
*/
/*!
\fn const QmlModuleMap &Tree::qmlModules() const
Returns a const reference to the collection of all
QML module nodes.
*/
/*!
Returns a pointer to the collection map specified by \a type.
Returns null if \a type is not specified.
*/
CNMap *Tree::getCollectionMap(Node::NodeType type)
{
switch (type) {
case Node::Group:
return &groups_;
case Node::Module:
return &modules_;
case Node::QmlModule:
return &qmlModules_;
case Node::JsModule:
return &jsModules_;
default:
break;
}
return nullptr;
}
/*!
Searches this tree for a collection named \a name with the
specified \a type. If the collection is found, a pointer
to it is returned. If a collection is not found, null is
returned.
*/
CollectionNode *Tree::getCollection(const QString &name, Node::NodeType type)
{
CNMap *map = getCollectionMap(type);
if (map) {
auto it = map->constFind(name);
if (it != map->cend())
return it.value();
}
return nullptr;
}
/*!
Find the group, module, QML module, or JavaScript module
named \a name and return a pointer to that collection node.
\a type specifies which kind of collection node you want.
If a collection node with the specified \a name and \a type
is not found, a new one is created, and the pointer to the
new one is returned.
If a new collection node is created, its parent is the tree
root, and the new collection node is marked \e{not seen}.
\a genus must be specified, i.e. it must not be \c{DontCare}.
If it is \c{DontCare}, 0 is returned, which is a programming
error.
*/
CollectionNode *Tree::findCollection(const QString &name, Node::NodeType type)
{
CNMap *m = getCollectionMap(type);
if (!m) // error
return nullptr;
auto it = m->constFind(name);
if (it != m->cend())
return it.value();
CollectionNode *cn = new CollectionNode(type, root(), name);
cn->markNotSeen();
m->insert(name, cn);
return cn;
}
/*! \fn CollectionNode *Tree::findGroup(const QString &name)
Find the group node named \a name and return a pointer
to it. If the group node is not found, add a new group
node named \a name and return a pointer to the new one.
If a new group node is added, its parent is the tree root,
and the new group node is marked \e{not seen}.
*/
/*! \fn CollectionNode *Tree::findModule(const QString &name)
Find the module node named \a name and return a pointer
to it. If a matching node is not found, add a new module
node named \a name and return a pointer to that one.
If a new module node is added, its parent is the tree root,
and the new module node is marked \e{not seen}.
*/
/*! \fn CollectionNode *Tree::findQmlModule(const QString &name)
Find the QML module node named \a name and return a pointer
to it. If a matching node is not found, add a new QML module
node named \a name and return a pointer to that one.
If a new QML module node is added, its parent is the tree root,
and the new node is marked \e{not seen}.
*/
/*! \fn CollectionNode *Tree::findJsModule(const QString &name)
Find the JavaScript module named \a name and return a pointer
to it. If a matching node is not found, add a new JavaScript
module node named \a name and return a pointer to that one.
If a new JavaScript module node is added, its parent is the
tree root, and the new node is marked \e{not seen}.
*/
/*! \fn CollectionNode *Tree::addGroup(const QString &name)
Looks up the group node named \a name in the collection
of all group nodes. If a match is found, a pointer to the
node is returned. Otherwise, a new group node named \a name
is created and inserted into the collection, and the pointer
to that node is returned.
*/
/*! \fn CollectionNode *Tree::addModule(const QString &name)
Looks up the module node named \a name in the collection
of all module nodes. If a match is found, a pointer to the
node is returned. Otherwise, a new module node named \a name
is created and inserted into the collection, and the pointer
to that node is returned.
*/
/*! \fn CollectionNode *Tree::addQmlModule(const QString &name)
Looks up the QML module node named \a name in the collection
of all QML module nodes. If a match is found, a pointer to the
node is returned. Otherwise, a new QML module node named \a name
is created and inserted into the collection, and the pointer
to that node is returned.
*/
/*! \fn CollectionNode *Tree::addJsModule(const QString &name)
Looks up the JavaScript module node named \a name in the collection
of all JavaScript module nodes. If a match is found, a pointer to the
node is returned. Otherwise, a new JavaScrpt module node named \a name
is created and inserted into the collection, and the pointer
to that node is returned.
*/
/*!
Looks up the group node named \a name in the collection
of all group nodes. If a match is not found, a new group
node named \a name is created and inserted into the collection.
Then append \a node to the group's members list, and append the
group name to the list of group names in \a node. The parent of
\a node is not changed by this function. Returns a pointer to
the group node.
*/
CollectionNode *Tree::addToGroup(const QString &name, Node *node)
{
CollectionNode *cn = findGroup(name);
if (!node->isInternal()) {
cn->addMember(node);
node->appendGroupName(name);
}
return cn;
}
/*!
Looks up the module node named \a name in the collection
of all module nodes. If a match is not found, a new module
node named \a name is created and inserted into the collection.
Then append \a node to the module's members list. The parent of
\a node is not changed by this function. Returns the module node.
*/
CollectionNode *Tree::addToModule(const QString &name, Node *node)
{
CollectionNode *cn = findModule(name);
cn->addMember(node);
node->setPhysicalModuleName(name);
return cn;
}
/*!
Looks up the QML module named \a name. If it isn't there,
create it. Then append \a node to the QML module's member
list. The parent of \a node is not changed by this function.
Returns the pointer to the QML module node.
*/
CollectionNode *Tree::addToQmlModule(const QString &name, Node *node)
{
QStringList qmid;
QStringList dotSplit;
QStringList blankSplit = name.split(QLatin1Char(' '));
qmid.append(blankSplit[0]);
if (blankSplit.size() > 1) {
qmid.append(blankSplit[0] + blankSplit[1]);
dotSplit = blankSplit[1].split(QLatin1Char('.'));
qmid.append(blankSplit[0] + dotSplit[0]);
}
CollectionNode *cn = findQmlModule(blankSplit[0]);
cn->addMember(node);
node->setQmlModule(cn);
if (node->isQmlType()) {
QmlTypeNode *n = static_cast<QmlTypeNode *>(node);
for (int i = 0; i < qmid.size(); ++i) {
QString key = qmid[i] + "::" + node->name();
insertQmlType(key, n);
}
}
return cn;
}
/*!
Looks up the QML module named \a name. If it isn't there,
create it. Then append \a node to the QML module's member
list. The parent of \a node is not changed by this function.
Returns the pointer to the QML module node.
*/
CollectionNode *Tree::addToJsModule(const QString &name, Node *node)
{
QStringList qmid;
QStringList dotSplit;
QStringList blankSplit = name.split(QLatin1Char(' '));
qmid.append(blankSplit[0]);
if (blankSplit.size() > 1) {
qmid.append(blankSplit[0] + blankSplit[1]);
dotSplit = blankSplit[1].split(QLatin1Char('.'));
qmid.append(blankSplit[0] + dotSplit[0]);
}
CollectionNode *cn = findJsModule(blankSplit[0]);
cn->addMember(node);
node->setQmlModule(cn);
if (node->isJsType()) {
QmlTypeNode *n = static_cast<QmlTypeNode *>(node);
for (int i = 0; i < qmid.size(); ++i) {
QString key = qmid[i] + "::" + node->name();
insertQmlType(key, n);
}
}
return cn;
}
/*!
If the QML type map does not contain \a key, insert node
\a n with the specified \a key.
*/
void Tree::insertQmlType(const QString &key, QmlTypeNode *n)
{
if (!qmlTypeMap_.contains(key))
qmlTypeMap_.insert(key, n);
}
/*!
Finds the function node with the specifried name \a path that
also has the specified \a parameters and returns a pointer to
the the first matching function node if one is found.
This function begins searching the tree at \a relative for
the \l {FunctionNode} {function node} identified by \a path
that has the specified \a parameters. The \a flags are
used to restrict the search. If a matching node is found, a
pointer to it is returned. Otherwise, nullis returned. If
\a relative is ull, the search begins at the tree root.
*/
const FunctionNode *Tree::findFunctionNode(const QStringList &path, const Parameters ¶meters,
const Node *relative, Node::Genus genus) const
{
if (path.size() == 3 && !path[0].isEmpty()
&& ((genus == Node::QML) || (genus == Node::DontCare))) {
QmlTypeNode *qcn = lookupQmlType(QString(path[0] + "::" + path[1]));
if (qcn == nullptr) {
QStringList p(path[1]);
Node *n = findNodeByNameAndType(p, &Node::isQmlType);
if ((n != nullptr) && (n->isQmlType() || n->isJsType()))
qcn = static_cast<QmlTypeNode *>(n);
}
if (qcn != nullptr)
return static_cast<const FunctionNode *>(qcn->findFunctionChild(path[2], parameters));
}
if (relative == nullptr)
relative = root();
else if (genus != Node::DontCare) {
if (genus != relative->genus())
relative = root();
}
do {
Node *node = const_cast<Node *>(relative);
int i;
for (i = 0; i < path.size(); ++i) {
if (node == nullptr || !node->isAggregate())
break;
Aggregate *aggregate = static_cast<Aggregate *>(node);
Node *next = nullptr;
if (i == path.size() - 1)
next = aggregate->findFunctionChild(path.at(i), parameters);
else
next = aggregate->findChildNode(path.at(i), genus);
if ((next == nullptr) && aggregate->isClassNode()) {
const ClassList bases = allBaseClasses(static_cast<const ClassNode *>(aggregate));
for (auto *base : bases) {
if (i == path.size() - 1)
next = base->findFunctionChild(path.at(i), parameters);
else
next = base->findChildNode(path.at(i), genus);
if (next != nullptr)
break;
}
}
node = next;
} // for (i = 0; i < path.size(); ++i)
if (node && i == path.size() && node->isFunction()) {
// A function node was found at the end of the path.
// If it is not marked private, return it. If it is
// marked private, then if it overrides a function,
// find that function instead because it might not
// be marked private. If all the overloads are
// marked private, return the original function node.
// This should be replace with findOverriddenFunctionNode().
const FunctionNode *fn = static_cast<const FunctionNode *>(node);
const FunctionNode *FN = fn;
while (FN->isPrivate() && !FN->overridesThis().isEmpty()) {
QStringList path = FN->overridesThis().split("::");
FN = qdb_->findFunctionNode(path, parameters, relative, genus);
if (FN == nullptr)
break;
if (!FN->isPrivate())
return FN;
}
return fn;
}
relative = relative->parent();
} while (relative);
return nullptr;
}
/*!
Generate a target of the form link-nnn, where the nnn is
the current link count for this tree. This target string
is returned. It will be output as an HTML anchor just before
an HTML link to the node \a t.
The node \a t
*/
QString Tree::getNewLinkTarget(const Node *locNode, const Node *t, const QString &fileName,
QString &text, bool broken)
{
QString physicalModuleName;
if (t != nullptr && !broken) {
Tree *tree = t->tree();
if (tree != this)
tree->incrementLinkCount();
physicalModuleName = tree->physicalModuleName();
} else
physicalModuleName = "broken";
incrementLinkCount();
QString target = QString("qa-target-%1").arg(-(linkCount()));
TargetLoc *tloc = new TargetLoc(locNode, target, fileName, text, broken);
TargetList *tList = nullptr;
auto it = targetListMap_->find(physicalModuleName);
if (it == targetListMap_->end()) {
tList = new TargetList;
it = targetListMap_->insert(physicalModuleName, tList);
} else
tList = it.value();
tList->append(tloc);
return target;
}
/*!
Look up the target list for the specified \a module
and return a pointer to it.
*/
TargetList *Tree::getTargetList(const QString &module)
{
return targetListMap_->value(module);
}
/*!
Search this tree recursively from \a parent to find a function
node with the specified \a tag. If no function node is found
with the required \a tag, return 0.
*/
FunctionNode *Tree::findFunctionNodeForTag(const QString &tag, Aggregate *parent)
{
if (parent == nullptr)
parent = root();
const NodeList &children = parent->childNodes();
for (Node *n : children) {
if (n != nullptr && n->isFunction() && n->hasTag(tag))
return static_cast<FunctionNode *>(n);
}
for (Node *n : children) {
if (n != nullptr && n->isAggregate()) {
n = findFunctionNodeForTag(tag, static_cast<Aggregate *>(n));
if (n != nullptr)
return static_cast<FunctionNode *>(n);
}
}
return nullptr;
}
/*!
There should only be one macro node for macro name \a t.
The macro node is not built until the \macro command is seen.
*/
FunctionNode *Tree::findMacroNode(const QString &t, const Aggregate *parent)
{
if (parent == nullptr)
parent = root();
const NodeList &children = parent->childNodes();
for (Node *n : children) {
if (n != nullptr && (n->isMacro() || n->isFunction()) && n->name() == t)
return static_cast<FunctionNode *>(n);
}
for (Node *n : children) {
if (n != nullptr && n->isAggregate()) {
FunctionNode *fn = findMacroNode(t, static_cast<Aggregate *>(n));
if (fn != nullptr)
return fn;
}
}
return nullptr;
}
/*!
Add the class and struct names in \a arg to the \e {don't document}
map.
*/
void Tree::addToDontDocumentMap(QString &arg)
{
arg.remove(QChar('('));
arg.remove(QChar(')'));
QString t = arg.simplified();
QStringList sl = t.split(QChar(' '));
if (sl.isEmpty())
return;
for (const QString &s : sl) {
if (!dontDocumentMap_.contains(s))
dontDocumentMap_.insert(s, nullptr);
}
}
/*!
The \e {don't document} map has been loaded with the names
of classes and structs in the current module that are not
documented and should not be documented. Now traverse the
map, and for each class or struct name, find the class node
that represents that class or struct and mark it with the
\C DontDocument status.
This results in a map of the class and struct nodes in the
module that are in the public API but are not meant to be
used by anyone. They are only used internally, but for one
reason or another, they must have public visibility.
*/
void Tree::markDontDocumentNodes()
{
for (auto it = dontDocumentMap_.begin(); it != dontDocumentMap_.end(); ++it) {
Aggregate *node = findAggregate(it.key());
if (node != nullptr)
node->setStatus(Node::DontDocument);
}
}
QT_END_NAMESPACE
|