summaryrefslogtreecommitdiffstats
path: root/src/clangparser.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/clangparser.h')
-rw-r--r--src/clangparser.h80
1 files changed, 75 insertions, 5 deletions
diff --git a/src/clangparser.h b/src/clangparser.h
index 8bb9aba..07907a6 100644
--- a/src/clangparser.h
+++ b/src/clangparser.h
@@ -3,9 +3,73 @@
#include <qcstring.h>
#include <qstrlist.h>
+#include "containers.h"
+#include <memory>
class CodeOutputInterface;
class FileDef;
+class ClangParser;
+class Definition;
+
+namespace clang { namespace tooling {
+ class CompilationDatabase;
+} }
+
+/** @brief Clang parser object for a single translation unit, which consists of a source file
+ * and the directly or indirectly included headers
+ */
+class ClangTUParser
+{
+ public:
+ ClangTUParser(const ClangParser &parser,const FileDef *fd);
+ virtual ~ClangTUParser();
+
+ /** Parse the file given at construction time as a translation unit
+ * This file should already be preprocessed by doxygen preprocessor at the time of calling.
+ */
+ void parse();
+
+ /** Switches to another file within the translation unit started with start().
+ * @param[in] fileName The name of the file to switch to.
+ */
+ void switchToFile(FileDef *fd);
+
+ /** Returns the list of files for this translation unit */
+ StringVector filesInSameTU() const;
+
+ /** Looks for \a symbol which should be found at \a line.
+ * returns a clang unique reference to the symbol.
+ */
+ QCString lookup(uint line,const char *symbol);
+
+ /** writes the syntax highlighted source code for a file
+ * @param[out] ol The output generator list to write to.
+ * @param[in] fd The file to write sources for.
+ */
+ void writeSources(CodeOutputInterface &ol,FileDef *fd);
+
+ private:
+ void detectFunctionBody(const char *s);
+ void writeLineNumber(CodeOutputInterface &ol,FileDef *fd,uint line);
+ void codifyLines(CodeOutputInterface &ol,FileDef *fd,const char *text,
+ uint &line,uint &column,const char *fontClass=0);
+ void writeMultiLineCodeLink(CodeOutputInterface &ol,
+ FileDef *fd,uint &line,uint &column,
+ Definition *d, const char *text);
+ void linkIdentifier(CodeOutputInterface &ol,FileDef *fd,
+ uint &line,uint &column,
+ const char *text,int tokenIndex);
+ void linkMacro(CodeOutputInterface &ol,FileDef *fd,
+ uint &line,uint &column,
+ const char *text);
+ void linkInclude(CodeOutputInterface &ol,FileDef *fd,
+ uint &line,uint &column,
+ const char *text);
+ ClangTUParser(const ClangTUParser &) = delete;
+ ClangTUParser &operator=(const ClangTUParser &) = delete;
+ class Private;
+ std::unique_ptr<Private> p;
+};
/** @brief Wrapper for to let libclang assisted parsing. */
class ClangParser
@@ -13,16 +77,20 @@ class ClangParser
public:
/** Returns the one and only instance of the class */
static ClangParser *instance();
-
+
+ std::unique_ptr<ClangTUParser> createTUParser(const FileDef *fd) const;
+ const clang::tooling::CompilationDatabase *database() const;
+
+#if 0
/** Start parsing a file.
* @param[in] fileName The name of the file to parse.
* @param[in,out] filesInTranslationUnit Other files that are
* part of the input and included by the file.
* The function will return a subset of the files,
- * only including the ones that were actually found
+ * only including the ones that were actually found
* during parsing.
*/
- void start(const char *fileName,QStrList &filesInTranslationUnit);
+ void start(const char *fileName,StringVector &filesInTranslationUnit);
/** Switches to another file within the translation unit started
* with start().
@@ -45,8 +113,10 @@ class ClangParser
* @param[in] fd The file to write sources for.
*/
void writeSources(CodeOutputInterface &ol,FileDef *fd);
+#endif
private:
+#if 0
void linkIdentifier(CodeOutputInterface &ol,FileDef *fd,
uint &line,uint &column,
const char *text,int tokenIndex);
@@ -56,9 +126,9 @@ class ClangParser
void linkInclude(CodeOutputInterface &ol,FileDef *fd,
uint &line,uint &column,
const char *text);
- void determineInputFilesInSameTu(QStrList &filesInTranslationUnit);
+#endif
class Private;
- Private *p;
+ std::unique_ptr<Private> p;
ClangParser();
virtual ~ClangParser();
static ClangParser *s_instance;