diff options
author | Luca Di Sera <luca.disera@qt.io> | 2023-03-07 13:05:43 +0100 |
---|---|---|
committer | Luca Di Sera <luca.disera@qt.io> | 2023-03-07 13:46:29 +0000 |
commit | dc834493f634416021a2d70c044fffb88efd06da (patch) | |
tree | 3d3a49856f79f762ac8bd46ea06d501246629c0e | |
parent | 571743a268bb404b88ed59232236b47c3a51d992 (diff) | |
download | qttools-dc834493f634416021a2d70c044fffb88efd06da.tar.gz |
QDoc: Remove `CodeParser::m_currentFile`
`CodeParser`, the base class for parsers of input source file in QDoc,
exposed an internal member that stored the path of the file that was
currently being parser by an instance of `CodeParser`.
The member was set when a new file was being parsed, and required to be
handled by all downstream parsers, both in setting and in clearing it at
the correct point.
Nonetheless, the member is generally unrequired and was indeed not used,
as the scope and usages of the path of a parsed file is well-defined and
limited during parsing.
The presence of the member is a source of bugs. Indeed, not all child
classes where correctly handling the lifetime of the member.
Further, it generally adds maintenance cost to the child classes and
hinders the creation of new derived classes as it increases the mental
load and implicit knowledge that is required to implement a
`CodeParser`.
Hence, the member and all references to it were removed in `CodeParser`
and its child classes; to simplify the codebase, remove unnecessary
state, avoid the additional classes of bugs that would exist if the
member was ever read and as the member represented dead code.
`CodeParser::currentFile`, a getter for `m_currentFile`, was removed as
a consequence of the member removal.
Change-Id: If5b5538d038a073d8288a644fe39d3dddc1d89c8
Reviewed-by: Topi Reiniƶ <topi.reinio@qt.io>
-rw-r--r-- | src/qdoc/clangcodeparser.cpp | 1 | ||||
-rw-r--r-- | src/qdoc/codeparser.h | 2 | ||||
-rw-r--r-- | src/qdoc/puredocparser.cpp | 3 | ||||
-rw-r--r-- | src/qdoc/qmlcodeparser.cpp | 3 |
4 files changed, 0 insertions, 9 deletions
diff --git a/src/qdoc/clangcodeparser.cpp b/src/qdoc/clangcodeparser.cpp index ca8027909..163ce20f7 100644 --- a/src/qdoc/clangcodeparser.cpp +++ b/src/qdoc/clangcodeparser.cpp @@ -1538,7 +1538,6 @@ void ClangCodeParser::parseSourceFile(const Location & /*location*/, const QStri each source file. The word "source" here means cpp file. */ m_qdb->clearOpenNamespaces(); - m_currentFile = filePath; flags_ = static_cast<CXTranslationUnit_Flags>(CXTranslationUnit_Incomplete | CXTranslationUnit_SkipFunctionBodies | CXTranslationUnit_KeepGoing); diff --git a/src/qdoc/codeparser.h b/src/qdoc/codeparser.h index 6579daedc..76d9daf10 100644 --- a/src/qdoc/codeparser.h +++ b/src/qdoc/codeparser.h @@ -33,7 +33,6 @@ public: return nullptr; } - [[nodiscard]] const QString ¤tFile() const { return m_currentFile; } [[nodiscard]] const QString &moduleHeader() const { return m_moduleHeader; } void setModuleHeader(const QString &t) { m_moduleHeader = t; } void checkModuleInclusion(Node *n); @@ -51,7 +50,6 @@ protected: static void extractPageLinkAndDesc(QStringView arg, QString *link, QString *desc); static bool showInternal() { return s_showInternal; } QString m_moduleHeader {}; - QString m_currentFile {}; QDocDatabase *m_qdb {}; private: diff --git a/src/qdoc/puredocparser.cpp b/src/qdoc/puredocparser.cpp index b9eb3d8df..ef37ee5a0 100644 --- a/src/qdoc/puredocparser.cpp +++ b/src/qdoc/puredocparser.cpp @@ -31,11 +31,9 @@ QStringList PureDocParser::sourceFileNameFilter() void PureDocParser::parseSourceFile(const Location &location, const QString &filePath) { QFile in(filePath); - m_currentFile = filePath; if (!in.open(QIODevice::ReadOnly)) { location.error( QStringLiteral("Can't open source file '%1' (%2)").arg(filePath, strerror(errno))); - m_currentFile.clear(); return; } @@ -52,7 +50,6 @@ void PureDocParser::parseSourceFile(const Location &location, const QString &fil processQdocComments(); in.close(); - m_currentFile.clear(); } /*! diff --git a/src/qdoc/qmlcodeparser.cpp b/src/qdoc/qmlcodeparser.cpp index 4c0eaf150..1ffdb531e 100644 --- a/src/qdoc/qmlcodeparser.cpp +++ b/src/qdoc/qmlcodeparser.cpp @@ -67,10 +67,8 @@ QStringList QmlCodeParser::sourceFileNameFilter() void QmlCodeParser::parseSourceFile(const Location &location, const QString &filePath) { QFile in(filePath); - m_currentFile = filePath; if (!in.open(QIODevice::ReadOnly)) { location.error(QStringLiteral("Cannot open QML file '%1'").arg(filePath)); - m_currentFile.clear(); return; } @@ -94,7 +92,6 @@ void QmlCodeParser::parseSourceFile(const Location &location, const QString &fil qCDebug(lcQdoc, "%s: %d: %d: QML syntax error: %s", qUtf8Printable(filePath), msg.loc.startLine, msg.loc.startColumn, qUtf8Printable(msg.message)); } - m_currentFile.clear(); } static QSet<QString> topicCommands_; |