diff options
-rw-r--r-- | src/qdoc/clangcodeparser.cpp | 6 | ||||
-rw-r--r-- | src/qdoc/cppcodeparser.cpp | 31 | ||||
-rw-r--r-- | src/qdoc/doc.cpp | 4 | ||||
-rw-r--r-- | src/qdoc/generator.cpp | 10 | ||||
-rw-r--r-- | src/qdoc/helpprojectwriter.cpp | 2 | ||||
-rw-r--r-- | src/qdoc/htmlgenerator.cpp | 16 | ||||
-rw-r--r-- | src/qdoc/node.cpp | 20 | ||||
-rw-r--r-- | src/qdoc/qdocdatabase.cpp | 12 | ||||
-rw-r--r-- | src/qdoc/qdocindexfiles.cpp | 6 | ||||
-rw-r--r-- | src/qdoc/qdoctagfiles.cpp | 4 | ||||
-rw-r--r-- | src/qdoc/qmlvisitor.cpp | 7 | ||||
-rw-r--r-- | src/qdoc/sections.cpp | 2 | ||||
-rw-r--r-- | src/qdoc/tree.cpp | 126 |
13 files changed, 101 insertions, 145 deletions
diff --git a/src/qdoc/clangcodeparser.cpp b/src/qdoc/clangcodeparser.cpp index 298669764..b8774b4a7 100644 --- a/src/qdoc/clangcodeparser.cpp +++ b/src/qdoc/clangcodeparser.cpp @@ -224,7 +224,7 @@ static Node *findNodeForCursor(QDocDatabase* qdb, CXCursor cur) { return qdb->primaryTreeRoot(); Node *p = findNodeForCursor(qdb, clang_getCursorSemanticParent(cur)); - if (!p) + if (p == nullptr) return nullptr; if (!p->isAggregate()) return nullptr; @@ -313,7 +313,7 @@ static Node *findFunctionNodeForCursor(QDocDatabase* qdb, CXCursor cur) { return qdb->primaryTreeRoot(); Node *p = findNodeForCursor(qdb, clang_getCursorSemanticParent(cur)); - if (!p || !p->isAggregate()) + if (p == nullptr || !p->isAggregate()) return nullptr; auto parent = static_cast<Aggregate *>(p); @@ -617,7 +617,7 @@ CXChildVisitResult ClangVisitor::visitHeader(CXCursor cursor, CXSourceLocation l auto baseCursor = clang_getTypeDeclaration(type); auto baseNode = findNodeForCursor(qdb_, baseCursor); auto classe = static_cast<ClassNode*>(parent_); - if (!baseNode || !baseNode->isClassNode()) { + if (baseNode == nullptr || !baseNode->isClassNode()) { QString bcName = fromCXString(clang_getCursorSpelling(baseCursor)); classe->addUnresolvedBaseClass(access, QStringList(bcName), bcName); return CXChildVisit_Continue; diff --git a/src/qdoc/cppcodeparser.cpp b/src/qdoc/cppcodeparser.cpp index cd0c9e952..0a1ee6461 100644 --- a/src/qdoc/cppcodeparser.cpp +++ b/src/qdoc/cppcodeparser.cpp @@ -336,11 +336,21 @@ Node* CppCodeParser::processTopicCommand(const Doc& doc, pn->setLocation(doc.startLocation()); return pn; } else if (command == COMMAND_QMLTYPE) { - QmlTypeNode* qcn = new QmlTypeNode(qdb_->primaryTreeRoot(), arg.first); + QmlTypeNode *qcn = nullptr; + Node *candidate = qdb_->primaryTreeRoot()->findChildNode(arg.first, Node::QML); + if (candidate != nullptr) + qcn = static_cast<QmlTypeNode*>(candidate); + else + qcn = new QmlTypeNode(qdb_->primaryTreeRoot(), arg.first); qcn->setLocation(doc.startLocation()); return qcn; } else if (command == COMMAND_JSTYPE) { - QmlTypeNode* qcn = new QmlTypeNode(qdb_->primaryTreeRoot(), arg.first, Node::JsType); + QmlTypeNode *qcn = nullptr; + Node *candidate = qdb_->primaryTreeRoot()->findChildNode(arg.first, Node::JS); + if (candidate != nullptr) + qcn = static_cast<QmlTypeNode*>(candidate); + else + qcn = new QmlTypeNode(qdb_->primaryTreeRoot(), arg.first, Node::JsType); qcn->setLocation(doc.startLocation()); return qcn; } else if (command == COMMAND_QMLBASICTYPE) { @@ -442,15 +452,8 @@ void CppCodeParser::processQmlProperties(const Doc &doc, NodeList &nodes, DocLis } QmlTypeNode* qmlType = qdb_->findQmlType(module, qmlTypeName); - if (qmlType == nullptr) { - QString msg; - if (topics.size() > 1 && !group.isEmpty()) - msg = tr("QML/JS type '%1' not found for property group '%2'").arg(qmlTypeName).arg(group); - else - msg = tr("QML/JS type '%1' not found for property '%2'").arg(qmlTypeName).arg(property); - doc.startLocation().warning(msg); - return; - } + if (qmlType == nullptr) + qmlType = new QmlTypeNode(qdb_->primaryTreeRoot(), qmlTypeName); SharedCommentNode* scn = nullptr; if (topics.size() > 1) { @@ -565,7 +568,7 @@ void CppCodeParser::processMetaCommand(const Doc &doc, else if (command == COMMAND_RELATES) { QStringList path = arg.split("::"); Aggregate *aggregate = qdb_->findRelatesNode(path); - if (!aggregate) + if (aggregate == nullptr) aggregate = new ProxyNode(node->root(), arg); if (node->parent() == aggregate) { // node is already a child of aggregate @@ -751,9 +754,9 @@ FunctionNode *CppCodeParser::parseOtherFuncArg(const QString &topic, const Locat funcName = colonSplit.last(); Aggregate *aggregate = qdb_->findQmlType(moduleName, elementName); - if (!aggregate) + if (aggregate == nullptr) aggregate = qdb_->findQmlBasicType(moduleName, elementName); - if (!aggregate) + if (aggregate == nullptr) return nullptr; QString params; diff --git a/src/qdoc/doc.cpp b/src/qdoc/doc.cpp index 979bf9f2a..e460b2865 100644 --- a/src/qdoc/doc.cpp +++ b/src/qdoc/doc.cpp @@ -2577,7 +2577,7 @@ QString DocParser::getCode(int cmd, CodeMarker *marker, const QString &argStr) int indent = indentLevel(code); code = unindent(indent, code); - if (!marker) + if (marker == nullptr) marker = CodeMarker::markerForCode(code); return marker->markedUpCode(code, nullptr, location()); } @@ -3389,7 +3389,7 @@ QString Doc::canonicalTitle(const QString &title) void Doc::detach() { - if (!priv) { + if (priv == nullptr) { priv = new DocPrivate; return; } diff --git a/src/qdoc/generator.cpp b/src/qdoc/generator.cpp index 144f20704..e5720d5fb 100644 --- a/src/qdoc/generator.cpp +++ b/src/qdoc/generator.cpp @@ -423,7 +423,7 @@ QString Generator::fileBase(const Node *node) const forever { const Node *pp = p->parent(); base.prepend(p->name()); - if (!pp || pp->name().isEmpty() || pp->isTextPageNode()) + if (pp == nullptr || pp->name().isEmpty() || pp->isTextPageNode()) break; base.prepend(QLatin1Char('-')); p = pp; @@ -546,7 +546,7 @@ QMap<QString, QString>& Generator::formattingRightMap() */ QString Generator::fullDocumentLocation(const Node *node, bool useSubdir) { - if (!node) + if (node == nullptr) return QString(); if (!node->url().isEmpty()) return node->url(); @@ -721,7 +721,7 @@ const Atom *Generator::generateAtomList(const Atom *atom, bool generate, int &numAtoms) { - while (atom) { + while (atom != nullptr) { if (atom->type() == Atom::FormatIf) { int numAtoms0 = numAtoms; bool rightFormat = canHandleFormat(atom->string()); @@ -730,7 +730,7 @@ const Atom *Generator::generateAtomList(const Atom *atom, marker, generate && rightFormat, numAtoms); - if (!atom) + if (atom == nullptr) return nullptr; if (atom->type() == Atom::FormatElse) { @@ -740,7 +740,7 @@ const Atom *Generator::generateAtomList(const Atom *atom, marker, generate && !rightFormat, numAtoms); - if (!atom) + if (atom == nullptr) return nullptr; } diff --git a/src/qdoc/helpprojectwriter.cpp b/src/qdoc/helpprojectwriter.cpp index 06e19af7f..500052eb6 100644 --- a/src/qdoc/helpprojectwriter.cpp +++ b/src/qdoc/helpprojectwriter.cpp @@ -650,7 +650,7 @@ void HelpProjectWriter::generateProject(HelpProject &project) else rootNode = qdb_->primaryTreeRoot(); - if (!rootNode) + if (rootNode == nullptr) return; project.files.clear(); diff --git a/src/qdoc/htmlgenerator.cpp b/src/qdoc/htmlgenerator.cpp index 0b4c0758c..ec96d3dd4 100644 --- a/src/qdoc/htmlgenerator.cpp +++ b/src/qdoc/htmlgenerator.cpp @@ -2181,9 +2181,9 @@ void HtmlGenerator::generateHeader(const QString& title, if (node->links().contains(Node::PreviousLink)) { linkPair = node->links()[Node::PreviousLink]; linkNode = qdb_->findNodeForTarget(linkPair.first, node); - if (!linkNode) + if (linkNode == nullptr) node->doc().location().warning(tr("Cannot link to '%1'").arg(linkPair.first)); - if (!linkNode || linkNode == node) + if (linkNode == nullptr || linkNode == node) anchorPair = linkPair; else anchorPair = anchorForNode(linkNode); @@ -2202,9 +2202,9 @@ void HtmlGenerator::generateHeader(const QString& title, if (node->links().contains(Node::NextLink)) { linkPair = node->links()[Node::NextLink]; linkNode = qdb_->findNodeForTarget(linkPair.first, node); - if (!linkNode) + if (linkNode == nullptr) node->doc().location().warning(tr("Cannot link to '%1'").arg(linkPair.first)); - if (!linkNode || linkNode == node) + if (linkNode == nullptr || linkNode == node) anchorPair = linkPair; else anchorPair = anchorForNode(linkNode); @@ -2225,9 +2225,9 @@ void HtmlGenerator::generateHeader(const QString& title, if (node->links().contains(Node::StartLink)) { linkPair = node->links()[Node::StartLink]; linkNode = qdb_->findNodeForTarget(linkPair.first, node); - if (!linkNode) + if (linkNode == nullptr) node->doc().location().warning(tr("Cannot link to '%1'").arg(linkPair.first)); - if (!linkNode || linkNode == node) + if (linkNode == nullptr || linkNode == node) anchorPair = linkPair; else anchorPair = anchorForNode(linkNode); @@ -2412,7 +2412,7 @@ The number of rows is known. */ void HtmlGenerator::generateQmlRequisites(QmlTypeNode *qcn, CodeMarker *marker) { - if (!qcn) + if (qcn == nullptr) return; QMap<QString, Text> requisites; Text text; @@ -2434,7 +2434,7 @@ void HtmlGenerator::generateQmlRequisites(QmlTypeNode *qcn, CodeMarker *marker) //add the module name and version to the map QString logicalModuleVersion; const CollectionNode* collection = qdb_->getCollectionNode(qcn->logicalModuleName(), qcn->nodeType()); - if (collection) + if (collection != nullptr) logicalModuleVersion = collection->logicalModuleVersion(); else logicalModuleVersion = qcn->logicalModuleVersion(); diff --git a/src/qdoc/node.cpp b/src/qdoc/node.cpp index 5f6f6925a..630991db3 100644 --- a/src/qdoc/node.cpp +++ b/src/qdoc/node.cpp @@ -1709,9 +1709,9 @@ void ClassNode::fixBaseClasses() // Remove private and duplicate base classes. while (i < bases_.size()) { ClassNode* bc = bases_.at(i).node_; - if (!bc) + if (bc == nullptr) bc = QDocDatabase::qdocDB()->findClassNode(bases_.at(i).path_); - if (bc && (bc->access() == Node::Private || found.contains(bc))) { + if (bc != nullptr && (bc->access() == Node::Private || found.contains(bc))) { RelatedClass rc = bases_.at(i); bases_.removeAt(i); ignoredBases_.append(rc); @@ -1728,7 +1728,7 @@ void ClassNode::fixBaseClasses() i = 0; while (i < derived_.size()) { ClassNode* dc = derived_.at(i).node_; - if (dc && dc->access() == Node::Private) { + if (dc != nullptr && dc->access() == Node::Private) { derived_.removeAt(i); const QList<RelatedClass> &dd = dc->derivedClasses(); for (int j = dd.size() - 1; j >= 0; --j) @@ -1847,16 +1847,16 @@ FunctionNode* ClassNode::findOverriddenFunction(const FunctionNode* fn) QList<RelatedClass>::Iterator bc = bases_.begin(); while (bc != bases_.end()) { ClassNode *cn = bc->node_; - if (!cn) { + if (cn == nullptr) { cn = QDocDatabase::qdocDB()->findClassNode(bc->path_); bc->node_ = cn; } - if (cn) { + if (cn != nullptr) { FunctionNode *result = cn->findFunctionChild(fn); - if (result && !result->isNonvirtual()) + if (result != nullptr && !result->isNonvirtual()) return result; result = cn->findOverriddenFunction(fn); - if (result && !result->isNonvirtual()) + if (result != nullptr && !result->isNonvirtual()) return result; } ++bc; @@ -2528,7 +2528,7 @@ void FunctionNode::debug() const */ bool FunctionNode::compare(const FunctionNode *fn) const { - if (!fn) + if (fn == nullptr) return false; if (metaness() != fn->metaness()) return false; @@ -3362,12 +3362,12 @@ void Aggregate::resolveQmlInheritance() base = QDocDatabase::qdocDB()->findQmlType(imports[i], type->qmlBaseName()); if (base && (base != type)) { if (base->logicalModuleVersion()[0] != imports[i].version_[0]) - base = 0; // Safeguard for QTBUG-53529 + base = nullptr; // Safeguard for QTBUG-53529 break; } } } - if (base == 0) { + if (base == nullptr) { base = QDocDatabase::qdocDB()->findQmlType(QString(), type->qmlBaseName()); } if (base && (base != type)) { diff --git a/src/qdoc/qdocdatabase.cpp b/src/qdoc/qdocdatabase.cpp index ab1d44f46..d7bf16ea1 100644 --- a/src/qdoc/qdocdatabase.cpp +++ b/src/qdoc/qdocdatabase.cpp @@ -159,7 +159,7 @@ void QDocForest::setPrimaryTree(const QString& t) QString T = t.toLower(); primaryTree_ = findTree(T); forest_.remove(T); - if (!primaryTree_) + if (primaryTree_ == nullptr) qDebug() << "ERROR: Could not set primary tree to:" << t; } @@ -477,7 +477,7 @@ QDocDatabase::~QDocDatabase() */ QDocDatabase* QDocDatabase::qdocDB() { - if (!qdocDB_) { + if (qdocDB_ == nullptr) { qdocDB_ = new QDocDatabase; initializeDB(); } @@ -489,7 +489,7 @@ QDocDatabase* QDocDatabase::qdocDB() */ void QDocDatabase::destroyQdocDB() { - if (qdocDB_) { + if (qdocDB_ != nullptr) { delete qdocDB_; qdocDB_ = nullptr; } @@ -1555,7 +1555,7 @@ const Node* QDocDatabase::findNodeForAtom(const Atom* a, const Node* relative, Q QStringList path = function.split("::"); node = domain->findFunctionNode(path, Parameters(signature), nullptr, genus); } - if (!node) { + if (node == nullptr) { int flags = SearchBaseClasses | SearchEnumValues; QStringList nodePath = first.split("::"); QString target; @@ -1572,11 +1572,11 @@ const Node* QDocDatabase::findNodeForAtom(const Atom* a, const Node* relative, Q node = findNodeByNameAndType(QStringList(first), &Node::isPageNode); else if (first.endsWith(QChar(')'))) node = findFunctionNode(first, relative, genus); - if (!node) + if (node == nullptr) return findNodeForTarget(targetPath, relative, genus, ref); } - if (node && ref.isEmpty()) { + if (node != nullptr && ref.isEmpty()) { if (!node->url().isEmpty()) return node; targetPath.removeFirst(); diff --git a/src/qdoc/qdocindexfiles.cpp b/src/qdoc/qdocindexfiles.cpp index 7302149a3..617c132f2 100644 --- a/src/qdoc/qdocindexfiles.cpp +++ b/src/qdoc/qdocindexfiles.cpp @@ -85,7 +85,7 @@ QDocIndexFiles::~QDocIndexFiles() */ QDocIndexFiles* QDocIndexFiles::qdocIndexFiles() { - if (!qdocIndexFiles_) + if (qdocIndexFiles_ == nullptr) qdocIndexFiles_ = new QDocIndexFiles; return qdocIndexFiles_; } @@ -95,7 +95,7 @@ QDocIndexFiles* QDocIndexFiles::qdocIndexFiles() */ void QDocIndexFiles::destroyQDocIndexFiles() { - if (qdocIndexFiles_) { + if (qdocIndexFiles_ != nullptr) { delete qdocIndexFiles_; qdocIndexFiles_ = nullptr; } @@ -762,7 +762,7 @@ static const QString getThreadSafenessString(Node::ThreadSafeness t) */ bool QDocIndexFiles::generateIndexSection(QXmlStreamWriter &writer, Node *node, IndexSectionWriter *post) { - if (!gen_) + if (gen_ == nullptr) gen_ = Generator::currentGenerator(); Q_ASSERT(gen_); diff --git a/src/qdoc/qdoctagfiles.cpp b/src/qdoc/qdoctagfiles.cpp index 2c934193b..e04f684a3 100644 --- a/src/qdoc/qdoctagfiles.cpp +++ b/src/qdoc/qdoctagfiles.cpp @@ -73,7 +73,7 @@ QDocTagFiles::~QDocTagFiles() */ QDocTagFiles* QDocTagFiles::qdocTagFiles() { - if (!qdocTagFiles_) + if (qdocTagFiles_ == nullptr) qdocTagFiles_ = new QDocTagFiles; return qdocTagFiles_; } @@ -83,7 +83,7 @@ QDocTagFiles* QDocTagFiles::qdocTagFiles() */ void QDocTagFiles::destroyQDocTagFiles() { - if (qdocTagFiles_) { + if (qdocTagFiles_ != nullptr) { delete qdocTagFiles_; qdocTagFiles_ = nullptr; } diff --git a/src/qdoc/qmlvisitor.cpp b/src/qdoc/qmlvisitor.cpp index c52081847..e41a544f2 100644 --- a/src/qdoc/qmlvisitor.cpp +++ b/src/qdoc/qmlvisitor.cpp @@ -550,7 +550,12 @@ bool QmlDocVisitor::visit(QQmlJS::AST::UiObjectDefinition *definition) nestingLevel++; if (current->isNamespace()) { - QmlTypeNode *component = new QmlTypeNode(current, name); + QmlTypeNode *component = nullptr; + Node *candidate = current ->findChildNode(name, Node::QML); + if (candidate != nullptr) + component = static_cast<QmlTypeNode*>(candidate); + else + component = new QmlTypeNode(current, name); component->setTitle(name); component->setImportList(importList); importList.clear(); diff --git a/src/qdoc/sections.cpp b/src/qdoc/sections.cpp index 5ba7ea09f..14bf96191 100644 --- a/src/qdoc/sections.cpp +++ b/src/qdoc/sections.cpp @@ -35,7 +35,7 @@ QT_BEGIN_NAMESPACE -//Aggregate *Sections::aggregate_ = 0; +//Aggregate *Sections::aggregate_ = nullptr; static bool sectionsInitialized = false; QVector<Section> Sections::stdSummarySections_(7, Section(Section::Summary, Section::Active)); diff --git a/src/qdoc/tree.cpp b/src/qdoc/tree.cpp index b63bec4cf..dff42d095 100644 --- a/src/qdoc/tree.cpp +++ b/src/qdoc/tree.cpp @@ -129,7 +129,7 @@ Tree::~Tree() Node* Tree::findNodeForInclude(const QStringList& path) const { Node* n = findClassNode(path); - if (!n) + if (n == nullptr) n = findNamespaceNode(path); return n; } @@ -157,7 +157,7 @@ Aggregate *Tree::findAggregate(const QString &name) */ ClassNode* Tree::findClassNode(const QStringList& path, const Node* start) const { - if (!start) + if (start == nullptr) start = const_cast<NamespaceNode*>(root()); return static_cast<ClassNode*>(findNodeRecursive(path, 0, start, &Node::isClassNode)); } @@ -191,7 +191,7 @@ QmlTypeNode* Tree::findQmlTypeNode(const QStringList& path) */ if (path.size() >= 2 && !path[0].isEmpty()) { QmlTypeNode* qcn = qdb_->findQmlType(path[0], path[1]); - if (qcn) + if (qcn != nullptr) return qcn; } return static_cast<QmlTypeNode*>(findNodeRecursive(path, 0, root(), &Node::isQmlType)); @@ -212,7 +212,7 @@ QmlTypeNode* Tree::findQmlTypeNode(const QStringList& path) Aggregate *Tree::findRelatesNode(const QStringList &path) { Node* n = findNodeRecursive(path, 0, root(), &Node::isRelatableType); - return ((n && n->isAggregate()) ? static_cast<Aggregate*>(n) : nullptr); + return (((n != nullptr) && n->isAggregate()) ? static_cast<Aggregate*>(n) : nullptr); } /*! @@ -272,7 +272,7 @@ void Tree::resolveInheritanceHelper(int pass, ClassNode* cn) QList<RelatedClass>& bases = cn->baseClasses(); QList<RelatedClass>::iterator b = bases.begin(); while (b != bases.end()) { - if (!(*b).node_) { + if ((*b).node_ == nullptr) { Node* n = qdb_->findClassNode((*b).path_); /* If the node for the base class was not found, @@ -284,14 +284,14 @@ void Tree::resolveInheritanceHelper(int pass, ClassNode* cn) at the parent of the subclass node (the namespace node) using the unqualified base class name. */ - if (!n) { + if (n == nullptr) { Aggregate* parent = cn->parent(); - if (parent) + if (parent != nullptr) // Exclude the root namespace if (parent->isNamespace() && !parent->name().isEmpty()) n = findClassNode((*b).path_, parent); } - if (n) { + if (n != nullptr) { ClassNode* bcn = static_cast<ClassNode*>(n); (*b).node_ = bcn; bcn->addDerivedClass((*b).access_, cn); @@ -395,9 +395,9 @@ void Tree::resolveUsingClauses() QList<UsingClause>& usingClauses = cn->usingClauses(); QList<UsingClause>::iterator uc = usingClauses.begin(); while (uc != usingClauses.end()) { - if (!(*uc).node()) { + if ((*uc).node() == nullptr) { const Node* n = qdb_->findFunctionNode((*uc).signature(), cn, Node::CPP); - if (n) + if (n != nullptr) (*uc).setNode(n); } ++uc; @@ -410,7 +410,7 @@ void Tree::resolveUsingClauses() */ void Tree::fixInheritance(NamespaceNode* rootNode) { - if (!rootNode) + if (rootNode == nullptr) rootNode = root(); NodeList::ConstIterator c = rootNode->constBegin(); @@ -429,7 +429,7 @@ ClassList Tree::allBaseClasses(const ClassNode *classNode) const { ClassList result; foreach (const RelatedClass& r, classNode->baseClasses()) { - if (r.node_) { + if (r.node_ != nullptr) { result += r.node_; result += allBaseClasses(r.node_); } @@ -483,7 +483,7 @@ Node* Tree::findNodeRecursive(const QStringList& path, const NodeList& children = current->childNodes(); const QString& name = path.at(pathIndex); foreach (Node *n, children) { - if (!n) + if (n == nullptr) continue; if (n->name() == name) { if (pathIndex+1 >= path.size()) { @@ -493,66 +493,14 @@ Node* Tree::findNodeRecursive(const QStringList& path, } else { // Search the children of n for the next name in the path. n = findNodeRecursive(path, pathIndex+1, n, isMatch); - if (n) + if (n != nullptr) return n; } } } return nullptr; } -#if 0 -/*! - 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, - Node::NodeType type) const -{ - if (!start || path.isEmpty()) - return 0; // no place to start, or nothing to search for. - Node* node = const_cast<Node*>(start); - if (!start->isAggregate()) { - if (pathIndex >= path.size()) - return node; // found a match. - return 0; // premature leaf - } - Aggregate* current = static_cast<Aggregate*>(node); - const NodeList& children = current->childNodes(); - const QString& name = path.at(pathIndex); - foreach (Node *n, children) { - if (!n) - continue; - if (n->name() == name) { - if (pathIndex+1 >= path.size()) { - if ((n->nodeType() == type) || (type == Node::NoType)) - return n; - continue; - } - else { // Search the children of n for the next name in the path. - n = findNodeRecursive(path, pathIndex+1, n, type); - if (n) - return n; - } - } - } - return nullptr; -} -#endif /*! Searches the tree for a node that matches the \a path plus the \a target. The search begins at \a start and moves up @@ -599,7 +547,7 @@ const Node* Tree::findNodeForTarget(const QStringList& path, } const Node* current = start; - if (!current) + if (current == nullptr) current = root(); /* @@ -630,7 +578,7 @@ const Node* Tree::findNodeForTarget(const QStringList& path, } } - while (current) { + while (current != nullptr) { if (current->isAggregate()) { // Should this be isPageNode() ??? const Node* node = matchPathAndTarget(path, path_idx, target, current, flags, genus, ref); if (node) @@ -736,7 +684,7 @@ const Node* Tree::findNode(const QStringList& path, Node::Genus genus) const { const Node* current = start; - if (!current) + if (current == nullptr) current = root(); do { @@ -755,7 +703,7 @@ const Node* Tree::findNode(const QStringList& path, if (((genus == Node::QML) || (genus == Node::DontCare)) && (path.size() >= 2) && !path[0].isEmpty()) { QmlTypeNode* qcn = lookupQmlType(QString(path[0] + "::" + path[1])); - if (qcn) { + if (qcn != nullptr) { node = qcn; if (path.size() == 2) return node; @@ -772,26 +720,26 @@ const Node* Tree::findNode(const QStringList& path, 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 && (flags & SearchEnumValues) && i == path.size()-1) { + if ((next == nullptr) && (flags & SearchEnumValues) && i == path.size()-1) { next = static_cast<const Aggregate*>(node)->findEnumNodeForValue(path.at(i)); } - if (!next && ((genus == Node::CPP) || (genus == Node::DontCare)) && + if ((next == nullptr) && ((genus == Node::CPP) || (genus == Node::DontCare)) && node->isClassNode() && (flags & SearchBaseClasses)) { ClassList bases = allBaseClasses(static_cast<const ClassNode*>(node)); foreach (const ClassNode *base, bases) { next = base->findChildNode(path.at(i), genus, tmpFlags); - if (!next && (flags & SearchEnumValues) && i == path.size() - 1) + if ((next == nullptr) && (flags & SearchEnumValues) && i == path.size() - 1) next = base->findEnumNodeForValue(path.at(i)); - if (next) + if (next != nullptr) break; } } node = next; } - if (node && i == path.size()) + if ((node != nullptr) && i == path.size()) return node; current = current->parent(); - } while (current); + } while (current != nullptr); return nullptr; } @@ -1308,13 +1256,13 @@ const FunctionNode *Tree::findFunctionNode(const QStringList &path, if (path.size() == 3 && !path[0].isEmpty() && ((genus == Node::QML) || (genus == Node::DontCare))) { QmlTypeNode *qcn = lookupQmlType(QString(path[0] + "::" + path[1])); - if (!qcn) { + if (qcn == nullptr) { QStringList p(path[1]); Node* n = findNodeByNameAndType(p, &Node::isQmlType); - if (n && (n->isQmlType() || n->isJsType())) + if ((n != nullptr) && (n->isQmlType() || n->isJsType())) qcn = static_cast<QmlTypeNode*>(n); } - if (qcn) + if (qcn != nullptr) return static_cast<const FunctionNode*>(qcn->findFunctionChild(path[2], parameters)); } @@ -1340,7 +1288,7 @@ const FunctionNode *Tree::findFunctionNode(const QStringList &path, else next = aggregate->findChildNode(path.at(i), genus); - if (!next && aggregate->isClassNode()) { + if ((next == nullptr) && aggregate->isClassNode()) { ClassList bases = allBaseClasses(static_cast<const ClassNode*>(aggregate)); foreach (ClassNode *base, bases) { if (i == path.size() - 1) @@ -1396,7 +1344,7 @@ QString Tree::getNewLinkTarget(const Node* locNode, bool broken) { QString physicalModuleName; - if (t && !broken) { + if (t != nullptr && !broken) { Tree* tree = t->tree(); if (tree != this) tree->incrementLinkCount(); @@ -1435,17 +1383,17 @@ TargetList* Tree::getTargetList(const QString& module) */ FunctionNode *Tree::findFunctionNodeForTag(const QString &tag, Aggregate *parent) { - if (!parent) + if (parent == nullptr) parent = root(); const NodeList& children = parent->childNodes(); for (Node *n : children) { - if (n && n->isFunction() && n->hasTag(tag)) + if (n != nullptr && n->isFunction() && n->hasTag(tag)) return static_cast<FunctionNode*>(n); } for (Node *n : children) { - if (n && n->isAggregate()) { + if (n != nullptr && n->isAggregate()) { n = findFunctionNodeForTag(tag, static_cast<Aggregate*>(n)); - if (n) + if (n != nullptr) return static_cast<FunctionNode*>(n); } } @@ -1458,17 +1406,17 @@ FunctionNode *Tree::findFunctionNodeForTag(const QString &tag, Aggregate *parent */ FunctionNode *Tree::findMacroNode(const QString &t, const Aggregate *parent) { - if (!parent) + if (parent == nullptr) parent = root(); const NodeList &children = parent->childNodes(); for (Node *n : children) { - if (n && (n->isMacro() || n->isFunction()) && n->name() == t) + if (n != nullptr && (n->isMacro() || n->isFunction()) && n->name() == t) return static_cast<FunctionNode*>(n); } for (Node *n : children) { - if (n && n->isAggregate()) { + if (n != nullptr && n->isAggregate()) { FunctionNode *fn = findMacroNode(t, static_cast<Aggregate*>(n)); - if (fn) + if (fn != nullptr) return fn; } } |