summaryrefslogtreecommitdiff
path: root/src/qdoc/cppcodeparser.cpp
diff options
context:
space:
mode:
authorLuca Di Sera <luca.disera@qt.io>2023-03-17 14:00:02 +0100
committerLuca Di Sera <luca.disera@qt.io>2023-03-19 15:04:37 +0000
commit105791ef458d50f84387efbd8526671a8d8fd9a6 (patch)
treef5126af09a5fc4e2b13b6454e1f25757d551917c /src/qdoc/cppcodeparser.cpp
parent8adba40d7c780c7ad2b75b6fdc8105568094907b (diff)
downloadqttools-105791ef458d50f84387efbd8526671a8d8fd9a6.tar.gz
QDoc: Remove `CppCodeParser::topicCommands`
As part of extracting user-provided documentation, QDoc has to parse a variety of source files in a variety of languages. `CodeParser` is the base class of objects that take care of performing this parsing process in QDoc. When extracting the documentation in one of the `CodeParser`s QDoc generally tries to parse the extracted documentation in-place. The documentation has a series of available commands that might depend on the currently used parser. To support this process some of the `CodeParser` child classes provides series of methods to retrieve the required commands for each parser. `CppCodeParser`, the parser that provides the semantic for QDoc's comment-blocks, for example, provides `topicCommands`, to list the available "topic commands" in a commnet-block. `topicCommands` initializes a static member, `topicCommands_` and then returns it, avoiding initialization if the method is called more than once. While this process can be better expressed by the simple use of a `static` there are two probable reason for why it wasn't done in this way. Supposedly, when this code was written, there was no suitable way to initialize a `QSet<QString>`, the type of `topicCommands_`, in-place, as similar patterns can be found in other legacy parts of QDoc that are confirmed to have had this issue due to their age. Additionally, the expansion of the `COMMAND_*` macros, which form the content for `topicCommands_`, were, until recently, dependent on certain data being available in another part of the system, so that expanding them in a static context that would be processed before this data was available would incur into a series of errors. This dependency was removed in a recent patch, so that the issue is no more. Hence, the `topicCommands()` method is removed, along with `topicCommands_`, in favor of a public static, `topic_commands`, that is initialized in-place, to simplify the related code. All usages of `topicCommands` were modified to refer to `CppCodeParser::topic_commands`, keeping an equivalent semantic, as a consequence of the change. Change-Id: I9de2332bf557254e7ffd33290e6af678c2b121aa Reviewed-by: Topi Reiniƶ <topi.reinio@qt.io>
Diffstat (limited to 'src/qdoc/cppcodeparser.cpp')
-rw-r--r--src/qdoc/cppcodeparser.cpp24
1 files changed, 1 insertions, 23 deletions
diff --git a/src/qdoc/cppcodeparser.cpp b/src/qdoc/cppcodeparser.cpp
index 01434f352..7c0cee764 100644
--- a/src/qdoc/cppcodeparser.cpp
+++ b/src/qdoc/cppcodeparser.cpp
@@ -33,7 +33,6 @@ QT_BEGIN_NAMESPACE
QSet<QString> CppCodeParser::m_excludeDirs;
QSet<QString> CppCodeParser::m_excludeFiles;
-static QSet<QString> topicCommands_;
static QSet<QString> metaCommands_;
/*
@@ -63,19 +62,6 @@ static const QMap<QString, NodeTypeTestFunc> s_nodeTypeTestFuncMap{
*/
CppCodeParser::CppCodeParser()
{
- if (topicCommands_.isEmpty()) {
- topicCommands_ << COMMAND_CLASS << COMMAND_DONTDOCUMENT << COMMAND_ENUM << COMMAND_EXAMPLE
- << COMMAND_EXTERNALPAGE << COMMAND_FN << COMMAND_GROUP << COMMAND_HEADERFILE
- << COMMAND_MACRO << COMMAND_MODULE << COMMAND_NAMESPACE << COMMAND_PAGE
- << COMMAND_PROPERTY << COMMAND_TYPEALIAS << COMMAND_TYPEDEF
- << COMMAND_VARIABLE << COMMAND_QMLTYPE << COMMAND_QMLPROPERTY
- << COMMAND_QMLPROPERTYGROUP // mws 13/03/2019
- << COMMAND_QMLATTACHEDPROPERTY << COMMAND_QMLSIGNAL
- << COMMAND_QMLATTACHEDSIGNAL << COMMAND_QMLMETHOD
- << COMMAND_QMLATTACHEDMETHOD << COMMAND_QMLVALUETYPE << COMMAND_QMLBASICTYPE
- << COMMAND_QMLMODULE
- << COMMAND_STRUCT << COMMAND_UNION;
- }
if (metaCommands_.isEmpty()) {
metaCommands_ = CodeParser::common_meta_commands;
metaCommands_ << COMMAND_INHEADERFILE << COMMAND_NEXTPAGE
@@ -138,14 +124,6 @@ QStringList CppCodeParser::sourceFileNameFilter()
}
/*!
- Returns the set of strings representing the topic commands.
- */
-const QSet<QString> &CppCodeParser::topicCommands()
-{
- return topicCommands_;
-}
-
-/*!
Process the topic \a command found in the \a doc with argument \a arg.
*/
Node *CppCodeParser::processTopicCommand(const Doc &doc, const QString &command,
@@ -971,7 +949,7 @@ void CppCodeParser::processMetaCommands(NodeList &nodes, DocList &docs)
*/
bool CppCodeParser::hasTooManyTopics(const Doc &doc) const
{
- const QSet<QString> topicCommandsUsed = topicCommands() & doc.metaCommandsUsed();
+ const QSet<QString> topicCommandsUsed = CppCodeParser::topic_commands & doc.metaCommandsUsed();
if (topicCommandsUsed.empty() || topicCommandsUsed.size() == 1)
return false;