6072208b93d679fa47df33026823c516113fd388
[platform/upstream/doxygen.git] / src / clangparser.h
1 #ifndef CLANGPARSER_H
2 #define CLANGPARSER_H
3
4 #include <qcstring.h>
5 #include <qstrlist.h>
6
7 class CodeOutputInterface;
8 class FileDef;
9
10 /** @brief Wrapper for to let libclang assisted parsing. */
11 class ClangParser
12 {
13   public:
14     /** Returns the one and only instance of the class */
15     static ClangParser *instance();
16     
17     /** Start parsing a file.
18      *  @param[in] fileName The name of the file to parse.
19      *  @param[in,out] filesInTranslationUnit Other files that are
20      *                 part of the input and included by the file.
21      *                 The function will return a subset of the files,
22      *                 only including the onces that were actually found 
23      *                 during parsing.
24      */
25     void start(const char *fileName,QStrList &filesInTranslationUnit);
26
27     /** Switches to another file within the translation unit started
28      *  with start().
29      *  @param[in] fileName The name of the file to switch to.
30      */
31     void switchToFile(const char *fileName);
32
33     /** Finishes parsing a translation unit. Free any resources that
34      *  were needed for parsing.
35      */
36     void finish();
37
38     /** Looks for \a symbol which should be found at \a line and
39      *  returns a clang unique reference to the symbol.
40      */
41     QCString lookup(uint line,const char *symbol);
42
43     /** writes the syntax highlighted source code for a file
44      *  @param[out] ol The output generator list to write to.
45      *  @param[in]  fd The file to write sources for.
46      */
47     void writeSources(CodeOutputInterface &ol,FileDef *fd);
48
49   private:
50     void linkIdentifier(CodeOutputInterface &ol,FileDef *fd,
51                         uint &line,uint &column,
52                         const char *text,int tokenIndex);
53     void linkMacro(CodeOutputInterface &ol,FileDef *fd,
54                    uint &line,uint &column,
55                    const char *text);
56     void linkInclude(CodeOutputInterface &ol,FileDef *fd,
57                    uint &line,uint &column,
58                    const char *text);
59     void determineInputFilesInSameTu(QStrList &filesInTranslationUnit);
60     class Private;
61     Private *p;
62     ClangParser();
63     virtual ~ClangParser();
64     static ClangParser *s_instance;
65 };
66
67 #endif