Doxygen
Loading...
Searching...
No Matches
clangparser.h
Go to the documentation of this file.
1#ifndef CLANGPARSER_H
2#define CLANGPARSER_H
3
4#include <memory>
5#include <string>
6#include <cstdint>
7
8#include "containers.h"
9#include "types.h"
10#include "construct.h"
11
12class OutputCodeList;
13class FileDef;
14class ClangParser;
15class Definition;
16
17namespace clang { namespace tooling {
18 class CompilationDatabase;
19} }
20
21/** @brief Clang parser object for a single translation unit, which consists of a source file
22 * and the directly or indirectly included headers
23 */
25{
26 public:
27 ClangTUParser(const ClangParser &parser,const FileDef *fd);
29 virtual ~ClangTUParser();
30
31 /** Parse the file given at construction time as a translation unit
32 * This file should already be preprocessed by doxygen preprocessor at the time of calling.
33 */
34 void parse();
35
36 /** Switches to another file within the translation unit started with start().
37 * @param[in] fd The file definition with the name of the file to switch to.
38 */
39 void switchToFile(const FileDef *fd);
40
41 /** Returns the list of files for this translation unit */
43
44 /** Looks for \a symbol which should be found at \a line.
45 * returns a clang unique reference to the symbol.
46 */
47 std::string lookup(uint32_t line,const char *symbol);
48
49 /** writes the syntax highlighted source code for a file
50 * @param[out] ol The output generator list to write to.
51 * @param[in] fd The file to write sources for.
52 */
53 void writeSources(OutputCodeList &ol,const FileDef *fd);
54
55 private:
56 void detectFunctionBody(const char *s);
57 void writeLineNumber(OutputCodeList &ol,const FileDef *fd,uint32_t line,bool writeLineAnchor);
58 void codifyLines(OutputCodeList &ol,const FileDef *fd,const char *text,
59 uint32_t &line,uint32_t &column,const char *fontClass=nullptr);
61 const FileDef *fd,uint32_t &line,uint32_t &column,
62 const Definition *d, const char *text);
64 uint32_t &line,uint32_t &column,
65 const char *text,int tokenIndex);
66 void linkMacro(OutputCodeList &ol,const FileDef *fd,
67 uint32_t &line,uint32_t &column,
68 const char *text);
70 uint32_t &line,uint32_t &column,
71 const char *text);
72 void codeFolding(OutputCodeList &ol,const Definition *d,uint32_t line);
73 void endCodeFold(OutputCodeList &ol,uint32_t line);
74 class Private;
75 std::unique_ptr<Private> p;
76};
77
78/** @brief Wrapper for to let libclang assisted parsing. */
80{
81 friend class ClangTUParser;
82 public:
83 /** Returns the one and only instance of the class */
84 static ClangParser *instance();
85 std::unique_ptr<ClangTUParser> createTUParser(const FileDef *fd) const;
86
87 private:
88 const clang::tooling::CompilationDatabase *database() const;
89 class Private;
90 std::unique_ptr<Private> p;
93 virtual ~ClangParser();
95};
96
97#endif
Wrapper for to let libclang assisted parsing.
Definition clangparser.h:80
static ClangParser * s_instance
Definition clangparser.h:94
std::unique_ptr< ClangTUParser > createTUParser(const FileDef *fd) const
virtual ~ClangParser()
const clang::tooling::CompilationDatabase * database() const
static ClangParser * instance()
Returns the one and only instance of the class.
std::unique_ptr< Private > p
Definition clangparser.h:90
friend class ClangTUParser
Definition clangparser.h:81
StringVector filesInSameTU() const
Returns the list of files for this translation unit.
ClangTUParser(const ClangParser &parser, const FileDef *fd)
void linkIdentifier(OutputCodeList &ol, const FileDef *fd, uint32_t &line, uint32_t &column, const char *text, int tokenIndex)
void linkInclude(OutputCodeList &ol, const FileDef *fd, uint32_t &line, uint32_t &column, const char *text)
void endCodeFold(OutputCodeList &ol, uint32_t line)
void writeLineNumber(OutputCodeList &ol, const FileDef *fd, uint32_t line, bool writeLineAnchor)
void codeFolding(OutputCodeList &ol, const Definition *d, uint32_t line)
void switchToFile(const FileDef *fd)
Switches to another file within the translation unit started with start().
void parse()
Parse the file given at construction time as a translation unit This file should already be preproces...
virtual ~ClangTUParser()
void codifyLines(OutputCodeList &ol, const FileDef *fd, const char *text, uint32_t &line, uint32_t &column, const char *fontClass=nullptr)
void linkMacro(OutputCodeList &ol, const FileDef *fd, uint32_t &line, uint32_t &column, const char *text)
std::string lookup(uint32_t line, const char *symbol)
Looks for symbol which should be found at line.
std::unique_ptr< Private > p
Definition clangparser.h:75
void writeMultiLineCodeLink(OutputCodeList &ol, const FileDef *fd, uint32_t &line, uint32_t &column, const Definition *d, const char *text)
void detectFunctionBody(const char *s)
void writeSources(OutputCodeList &ol, const FileDef *fd)
writes the syntax highlighted source code for a file
The common base class of all entity definitions found in the sources.
Definition definition.h:76
A model of a file symbol.
Definition filedef.h:99
Class representing a list of different code generators.
Definition outputlist.h:164
#define NON_COPYABLE(cls)
Macro to help implementing the rule of 5 for a non-copyable & movable class.
Definition construct.h:37
std::vector< std::string > StringVector
Definition containers.h:33
This file contains a number of basic enums and types.