diff options
author | Luca Di Sera <luca.disera@qt.io> | 2023-03-14 12:57:20 +0100 |
---|---|---|
committer | Luca Di Sera <luca.disera@qt.io> | 2023-03-16 12:34:41 +0100 |
commit | daed3ea8a4e0b454d3f7541ba2f2c306fe220ddb (patch) | |
tree | 46e0d87a83cbdce3989cab9a0bd9f4e1f502fed9 | |
parent | a2bdad8a93e587d7844c6db4ab17ae0edf67dbd6 (diff) | |
download | qttools-daed3ea8a4e0b454d3f7541ba2f2c306fe220ddb.tar.gz |
QDoc: Remove `ClangCodeParser::m_version`
`ClangCodeParser`, the class that takes care of handling and parsing C++
source files to extract the user-provided documentation, will try to
automatically find the element in the code that some documentation block
refers to if that documentation block has no topic command.
Whend doing so and failing, it will generally try to report a warning to
the user.
The warning is emitted based on certain conditions.
In particular, if the documentation block exposes a "\since" command,
a command that specifies from which version of the project the
documented element is available, and the version specified by the
command is a future version of the project, the warning is not emitted.
The current version of the project is provided by the configuration that
QDoc reads when compiling.
`ClangCodeParser` copies that version and keeps it stored in an
instance-scoped member, `m_version`, so that it can compare it to the
one provided by a "\since" command.
As `m_version` is used only for this comparison, which is located in a
single function call, we remove `m_version` and directly access the
value in the config, which is not expected to change at any point in the
execution of QDoc, in-place.
Hence, the `m_version` member was removed. Its initialiazation in
`ClangCodeParser::initializeParser` was removed as a consequence.
Furthermore, its single usage in `ClangCodeParser::parseSourceFile` was
supplanted with a direct access to the configuration stored version.
Change-Id: Ie607fa3b74b4f9c9e3fba82a98a8f2f601018f70
Reviewed-by: Topi Reiniƶ <topi.reinio@qt.io>
-rw-r--r-- | src/qdoc/clangcodeparser.cpp | 4 | ||||
-rw-r--r-- | src/qdoc/clangcodeparser.h | 1 |
2 files changed, 2 insertions, 3 deletions
diff --git a/src/qdoc/clangcodeparser.cpp b/src/qdoc/clangcodeparser.cpp index 3bcc68af9..5bf7a7521 100644 --- a/src/qdoc/clangcodeparser.cpp +++ b/src/qdoc/clangcodeparser.cpp @@ -1182,7 +1182,6 @@ Node *ClangVisitor::nodeForCommentAtLocation(CXSourceLocation loc, CXSourceLocat void ClangCodeParser::initializeParser() { Config &config = Config::instance(); - m_version = config.get(CONFIG_VERSION).asString(); auto args = config.getCanonicalPathList(CONFIG_INCLUDEPATHS, Config::IncludePaths); #ifdef Q_OS_MACOS @@ -1609,7 +1608,8 @@ void ClangCodeParser::parseSourceFile(const Location & /*location*/, const QStri bool future = false; if (doc.metaCommandsUsed().contains(COMMAND_SINCE)) { QString sinceVersion = doc.metaCommandArgs(COMMAND_SINCE).at(0).first; - if (getUnpatchedVersion(sinceVersion) > getUnpatchedVersion(m_version)) + if (getUnpatchedVersion(sinceVersion) > + getUnpatchedVersion(Config::instance().get(CONFIG_VERSION).asString())) future = true; } if (!future) { diff --git a/src/qdoc/clangcodeparser.h b/src/qdoc/clangcodeparser.h index e49ce3de0..988a57cb8 100644 --- a/src/qdoc/clangcodeparser.h +++ b/src/qdoc/clangcodeparser.h @@ -39,7 +39,6 @@ private: void printDiagnostics(const CXTranslationUnit &translationUnit) const; - QString m_version {}; QMultiHash<QString, QString> m_allHeaders {}; // file name->path QList<QByteArray> m_includePaths {}; QScopedPointer<QTemporaryDir> m_pchFileDir {}; |