|
Packit |
1c1d7e |
#ifndef CLANGPARSER_H
|
|
Packit |
1c1d7e |
#define CLANGPARSER_H
|
|
Packit |
1c1d7e |
|
|
Packit |
1c1d7e |
#include <qcstring.h>
|
|
Packit |
1c1d7e |
#include <qstrlist.h>
|
|
Packit |
1c1d7e |
|
|
Packit |
1c1d7e |
class CodeOutputInterface;
|
|
Packit |
1c1d7e |
class FileDef;
|
|
Packit |
1c1d7e |
|
|
Packit |
1c1d7e |
/** @brief Wrapper for to let libclang assisted parsing. */
|
|
Packit |
1c1d7e |
class ClangParser
|
|
Packit |
1c1d7e |
{
|
|
Packit |
1c1d7e |
public:
|
|
Packit |
1c1d7e |
/** Returns the one and only instance of the class */
|
|
Packit |
1c1d7e |
static ClangParser *instance();
|
|
Packit |
1c1d7e |
|
|
Packit |
1c1d7e |
/** Start parsing a file.
|
|
Packit |
1c1d7e |
* @param[in] fileName The name of the file to parse.
|
|
Packit |
1c1d7e |
* @param[in,out] filesInTranslationUnit Other files that are
|
|
Packit |
1c1d7e |
* part of the input and included by the file.
|
|
Packit |
1c1d7e |
* The function will return a subset of the files,
|
|
Packit |
1c1d7e |
* only including the onces that were actually found
|
|
Packit |
1c1d7e |
* during parsing.
|
|
Packit |
1c1d7e |
*/
|
|
Packit |
1c1d7e |
void start(const char *fileName,QStrList &filesInTranslationUnit);
|
|
Packit |
1c1d7e |
|
|
Packit |
1c1d7e |
/** Switches to another file within the translation unit started
|
|
Packit |
1c1d7e |
* with start().
|
|
Packit |
1c1d7e |
* @param[in] fileName The name of the file to switch to.
|
|
Packit |
1c1d7e |
*/
|
|
Packit |
1c1d7e |
void switchToFile(const char *fileName);
|
|
Packit |
1c1d7e |
|
|
Packit |
1c1d7e |
/** Finishes parsing a translation unit. Free any resources that
|
|
Packit |
1c1d7e |
* were needed for parsing.
|
|
Packit |
1c1d7e |
*/
|
|
Packit |
1c1d7e |
void finish();
|
|
Packit |
1c1d7e |
|
|
Packit |
1c1d7e |
/** Looks for \a symbol which should be found at \a line and
|
|
Packit |
1c1d7e |
* returns a clang unique reference to the symbol.
|
|
Packit |
1c1d7e |
*/
|
|
Packit |
1c1d7e |
QCString lookup(uint line,const char *symbol);
|
|
Packit |
1c1d7e |
|
|
Packit |
1c1d7e |
/** writes the syntax highlighted source code for a file
|
|
Packit |
1c1d7e |
* @param[out] ol The output generator list to write to.
|
|
Packit |
1c1d7e |
* @param[in] fd The file to write sources for.
|
|
Packit |
1c1d7e |
*/
|
|
Packit |
1c1d7e |
void writeSources(CodeOutputInterface &ol,FileDef *fd);
|
|
Packit |
1c1d7e |
|
|
Packit |
1c1d7e |
private:
|
|
Packit |
1c1d7e |
void linkIdentifier(CodeOutputInterface &ol,FileDef *fd,
|
|
Packit |
1c1d7e |
uint &line,uint &column,
|
|
Packit |
1c1d7e |
const char *text,int tokenIndex);
|
|
Packit |
1c1d7e |
void linkMacro(CodeOutputInterface &ol,FileDef *fd,
|
|
Packit |
1c1d7e |
uint &line,uint &column,
|
|
Packit |
1c1d7e |
const char *text);
|
|
Packit |
1c1d7e |
void linkInclude(CodeOutputInterface &ol,FileDef *fd,
|
|
Packit |
1c1d7e |
uint &line,uint &column,
|
|
Packit |
1c1d7e |
const char *text);
|
|
Packit |
1c1d7e |
void determineInputFilesInSameTu(QStrList &filesInTranslationUnit);
|
|
Packit |
1c1d7e |
class Private;
|
|
Packit |
1c1d7e |
Private *p;
|
|
Packit |
1c1d7e |
ClangParser();
|
|
Packit |
1c1d7e |
virtual ~ClangParser();
|
|
Packit |
1c1d7e |
static ClangParser *s_instance;
|
|
Packit |
1c1d7e |
};
|
|
Packit |
1c1d7e |
|
|
Packit |
1c1d7e |
#endif
|