diff options
author | Luca Di Sera <luca.disera@qt.io> | 2023-03-08 15:58:53 +0100 |
---|---|---|
committer | Luca Di Sera <luca.disera@qt.io> | 2023-03-10 11:15:00 +0100 |
commit | 9668522b2c702ee04abccc5417636f94dec9811a (patch) | |
tree | 843bcadeff745081032a5857d190dd039971155c /src/qdoc/clangcodeparser.cpp | |
parent | e8f777ffa6117b21a2aaa58bcd22ceb294003f6d (diff) | |
download | qttools-9668522b2c702ee04abccc5417636f94dec9811a.tar.gz |
QDoc: Move `CodeParser::parseHeaderFile` to `ClangCodeParser`
QDoc parses a series of source file in different languages and formats
to find the user-provided documentation.
The base parsing interface for elements that perform this process is
given by the `CodeParser` class, with the concrete implementation of the
process for different languages/formats give by its child classes.
`CodeParser`, as part of its interface, provides certain methods that
are only meaningful when processing specific programming languages
source.
For example, it exposes `CodeParser::parseHeaderFile` whose purpose it
to provide an entry point for parsing C++ header files.
The method is only meaningfully implemented and used in the
`ClangCodeParser` child class, the class that actually implements the
processing of C++ source files.
Hence, the method is now removed from `CodeParser`'s interface and
directly exposed as part of the interface of `ClangCodeParser`, to
reduce the surface of the method and to reduce the dependencies between
`ClangCodeParser` and the `CodeParser` interface, which is generally
expected to be removed in the future.
`CodeParser` are, currently and temporarily, mostly initialized
statically and then retrieved through certain methods of the
`CodeParser` interface.
`CodeParser::parserForHeaderFile` is one such method that would retrieve
a `CodeParser` or child class instance that is able to parse an header
file.
Due to the removal of `parseHeaderFile` from `CodeParser` interface and
the fact that only one specific parser is able, and should be able, to
parse header files, `CodeParser::parserForHeaderFile` was removed.
Its only usage in "main.cpp", where it was called to retrieve the
already available `ClangCodeParser`, was modified to make use of
`ClangCodeParser` directly.
An auxiliary method, `CodeParser::headerFileNameFilter`, previously used
only by `CodeParser::parserForHeaderFile`, which provided a list of
extensions to identify what files could be accepted by a certain parser
as header files, is now removed as dead code.
A non-meaningful reimplementation of the `headerFileNameFilter` method
in `CppCodeParser`, a child class of `CodeParser`, was removed as of
consequence.
Similarly, the same method implementation in `ClangCodeParser` was
removed.
The filtering functionality that the method indirectly provided when
used by `CodeParser::parserForHeaderFile`, which is to be retained for
backward compatibility reasons, was moved to
`processQdocconfFile` in "main.cpp", where the header files that should
be parsed are gathered.
Instead of using the `headerFileNameFilter` method, the data that was
provided by it is now exposed as a static member of `ClangCodeParser`
and accessed directly when filtering is necessary.
Change-Id: Iff9a204627675aa7b34232c114945afceb8313ff
Reviewed-by: Topi Reiniƶ <topi.reinio@qt.io>
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
Diffstat (limited to 'src/qdoc/clangcodeparser.cpp')
-rw-r--r-- | src/qdoc/clangcodeparser.cpp | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/src/qdoc/clangcodeparser.cpp b/src/qdoc/clangcodeparser.cpp index d2338ee32..e3984e502 100644 --- a/src/qdoc/clangcodeparser.cpp +++ b/src/qdoc/clangcodeparser.cpp @@ -41,6 +41,10 @@ QT_BEGIN_NAMESPACE +const QStringList ClangCodeParser::accepted_header_file_extensions{ + "ch", "h", "h++", "hh", "hpp", "hxx" +}; + // We're printing diagnostics in ClangCodeParser::printDiagnostics, // so avoid clang itself printing them. static const auto kClangDontDisplayDiagnostics = 0; @@ -1240,19 +1244,6 @@ QString ClangCodeParser::language() } /*! - Returns a list of extensions for header files. - */ -QStringList ClangCodeParser::headerFileNameFilter() -{ - return QStringList() << "*.ch" - << "*.h" - << "*.h++" - << "*.hh" - << "*.hpp" - << "*.hxx"; -} - -/*! Returns a list of extensions for source files, i.e. not header files. */ |