summaryrefslogtreecommitdiff
path: root/src/qdoc/cppcodemarker.cpp
diff options
context:
space:
mode:
authorPaul Wicking <paul.wicking@qt.io>2021-04-28 13:36:28 +0200
committerPaul Wicking <paul.wicking@qt.io>2021-05-03 10:05:04 +0200
commit6f462ac37916d9fc3fae793e040690741845ef62 (patch)
tree66bc4b997e0b38cd3d2cd86e8787d54672ca38a6 /src/qdoc/cppcodemarker.cpp
parenta1ed48d0d073a8bdd7b5e608982a5bbd9af47af8 (diff)
downloadqttools-6f462ac37916d9fc3fae793e040690741845ef62.tar.gz
QDoc: Code cleanup
* Use multiple arguments for QStrings instead of calling .arg() multiple times. * Define trivial constructor/destructor '= default' instead of adding empty implementations. * Remove unreachable code. * Prefer ranged-based for loops. * Initialize with auto from static_cast<>() and new. * Simplify expressions. * Prefer "QList::empty()" over "QList::size() > 0". * Remove unused method. * Return qsizetype instead of int to avoid narrowing conversion. * Remove unused include. * Remove unreachable return statement. * Prefer raw string literals over escaped regexes. * Initialize struct members. * Make variables used as const refs const refs. * Use std::move instead of passing const ref in ctor. * Drop redundant 'virtual' from methods marked 'override'. * Make local copies that arent ever modified const refs to avoid copying. * Turn for-loop into std::any_of. * Made single-argument constructor explicit. * Don't shadow variable names from outer scope if not necessary. * Remove const at top level that does not improve const correctness. * Update copyright notice for affected classes. Task-number: QTBUG-71176 Change-Id: Ia41e5b947b72f594b60d189b6b0ff68587c3afb9 Reviewed-by: Topi Reiniƶ <topi.reinio@qt.io>
Diffstat (limited to 'src/qdoc/cppcodemarker.cpp')
-rw-r--r--src/qdoc/cppcodemarker.cpp30
1 files changed, 5 insertions, 25 deletions
diff --git a/src/qdoc/cppcodemarker.cpp b/src/qdoc/cppcodemarker.cpp
index 9846a0dd8..0b6b9ab07 100644
--- a/src/qdoc/cppcodemarker.cpp
+++ b/src/qdoc/cppcodemarker.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2019 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
@@ -26,10 +26,6 @@
**
****************************************************************************/
-/*
- cppcodemarker.cpp
-*/
-
#include "cppcodemarker.h"
#include "access.h"
@@ -213,7 +209,7 @@ QString CppCodeMarker::markedUpSynopsis(const Node *node, const Node * /* relati
break;
case Node::TypeAlias:
if (style == Section::Details) {
- QString templateDecl = node->templateDecl();
+ const QString &templateDecl = node->templateDecl();
if (!templateDecl.isEmpty())
synopsis += templateDecl + QLatin1Char(' ');
}
@@ -257,17 +253,17 @@ QString CppCodeMarker::markedUpQmlItem(const Node *node, bool summary)
if (summary) {
name = linkTag(node, name);
} else if (node->isQmlProperty() || node->isJsProperty()) {
- const QmlPropertyNode *pn = static_cast<const QmlPropertyNode *>(node);
+ const auto *pn = static_cast<const QmlPropertyNode *>(node);
if (pn->isAttached())
name.prepend(pn->element() + QLatin1Char('.'));
}
name = "<@name>" + name + "</@name>";
QString synopsis;
if (node->isQmlProperty() || node->isJsProperty()) {
- const QmlPropertyNode *pn = static_cast<const QmlPropertyNode *>(node);
+ const auto *pn = static_cast<const QmlPropertyNode *>(node);
synopsis = name + " : " + typified(pn->dataType());
} else if (node->isFunction(Node::QML) || node->isFunction(Node::JS)) {
- const FunctionNode *func = static_cast<const FunctionNode *>(node);
+ const auto *func = static_cast<const FunctionNode *>(node);
if (!func->returnType().isEmpty())
synopsis = typified(func->returnType(), true) + name;
else
@@ -320,22 +316,6 @@ QString CppCodeMarker::markedUpName(const Node *node)
return name;
}
-QString CppCodeMarker::markedUpFullName(const Node *node, const Node *relative)
-{
- if (node->name().isEmpty())
- return "global";
-
- QString fullName;
- for (;;) {
- fullName.prepend(markedUpName(node));
- if (node->parent() == relative || node->parent()->name().isEmpty())
- break;
- fullName.prepend("<@op>::</@op>");
- node = node->parent();
- }
- return fullName;
-}
-
QString CppCodeMarker::markedUpEnumValue(const QString &enumValue, const Node *relative)
{
if (!relative->isEnumType())