summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuca Di Sera <luca.disera@qt.io>2024-03-24 20:49:56 +0100
committerLuca Di Sera <luca.disera@qt.io>2024-04-12 11:06:48 +0100
commit51118878fd7ebe63654edb59a36dbc539883b807 (patch)
tree06afd63a8f552f5a8bcd0a25a64d9cf370b46688
parent26b308868f75bd4afa072b0a95a3e0a5858796c1 (diff)
QDoc: Remove CodeParser from ClangCodeParser
`CodeParser` is a legacy inheritance-based interface for components that needs to parse a source file. Recent changes to the code-base moved some of those components to a new interface so that `CodeParser` is not required anymore. Hence stop `ClangCodeParser` from inheriting from `CodeParser`. Some unused methods that were inherited from `CodeParser` and are unused were removed. `ClangCodeParser` makes use of a `QDocDatabase` that was previously obtained from its parent class. The dependencies is now made explicit and handled as part of the constructor. Task-number: QTBUG-111686 Change-Id: Ie4174175f669703cc1aa3fc954efe6f9a1314367 Reviewed-by: Topi Reiniƶ <topi.reinio@qt.io>
-rw-r--r--src/qdoc/qdoc/src/qdoc/clangcodeparser.cpp24
-rw-r--r--src/qdoc/qdoc/src/qdoc/clangcodeparser.h10
-rw-r--r--src/qdoc/qdoc/src/qdoc/main.cpp2
3 files changed, 7 insertions, 29 deletions
diff --git a/src/qdoc/qdoc/src/qdoc/clangcodeparser.cpp b/src/qdoc/qdoc/src/qdoc/clangcodeparser.cpp
index 98c6fe44d..56a643541 100644
--- a/src/qdoc/qdoc/src/qdoc/clangcodeparser.cpp
+++ b/src/qdoc/qdoc/src/qdoc/clangcodeparser.cpp
@@ -1427,37 +1427,19 @@ Node *ClangVisitor::nodeForCommentAtLocation(CXSourceLocation loc, CXSourceLocat
}
ClangCodeParser::ClangCodeParser(
+ QDocDatabase* qdb,
Config& config,
const std::vector<QByteArray>& include_paths,
const QList<QByteArray>& defines,
std::optional<std::reference_wrapper<const PCHFile>> pch
-) : m_includePaths{include_paths},
+) : m_qdb{qdb},
+ m_includePaths{include_paths},
m_defines{defines},
m_pch{pch}
{
m_allHeaders = config.getHeaderFiles();
}
-/*!
- */
-QString ClangCodeParser::language()
-{
- return "Clang";
-}
-
-/*!
- Returns a list of extensions for source files, i.e. not
- header files.
- */
-QStringList ClangCodeParser::sourceFileNameFilter()
-{
- return QStringList() << "*.c++"
- << "*.cc"
- << "*.cpp"
- << "*.cxx"
- << "*.mm";
-}
-
static const char *defaultArgs_[] = {
/*
https://bugreports.qt.io/browse/QTBUG-94365
diff --git a/src/qdoc/qdoc/src/qdoc/clangcodeparser.h b/src/qdoc/qdoc/src/qdoc/clangcodeparser.h
index e6d78c719..0ae2bb788 100644
--- a/src/qdoc/qdoc/src/qdoc/clangcodeparser.h
+++ b/src/qdoc/qdoc/src/qdoc/clangcodeparser.h
@@ -64,25 +64,21 @@ private:
std::optional<std::reference_wrapper<const PCHFile>> m_pch;
};
-class ClangCodeParser : public CodeParser
+class ClangCodeParser
{
public:
ClangCodeParser(
+ QDocDatabase* qdb,
Config&,
const std::vector<QByteArray>& include_paths,
const QList<QByteArray>& defines,
std::optional<std::reference_wrapper<const PCHFile>> pch
);
- ~ClangCodeParser() override = default;
- void initializeParser() override {}
- void terminateParser() override {}
- QString language() override;
- QStringList sourceFileNameFilter() override;
- void parseSourceFile(const Location &, const QString &, CppCodeParser&) override {}
ParsedCppFileIR parse_cpp_file(const QString &filePath);
private:
+ QDocDatabase* m_qdb{};
std::set<Config::HeaderFilePath> m_allHeaders {}; // file name->path
const std::vector<QByteArray>& m_includePaths;
QList<QByteArray> m_defines {};
diff --git a/src/qdoc/qdoc/src/qdoc/main.cpp b/src/qdoc/qdoc/src/qdoc/main.cpp
index 7753b9082..9620cb00a 100644
--- a/src/qdoc/qdoc/src/qdoc/main.cpp
+++ b/src/qdoc/qdoc/src/qdoc/main.cpp
@@ -511,7 +511,7 @@ static void processQdocconfFile(const QString &fileName)
);
}
- ClangCodeParser clangParser(Config::instance(), include_paths, clang_defines, pch);
+ ClangCodeParser clangParser(QDocDatabase::qdocDB(), Config::instance(), include_paths, clang_defines, pch);
PureDocParser docParser{config.location()};
/*