2014-05-16 15:51:04 -04:00
|
|
|
#ifndef CPPSOURCEPROCESSOR_H
|
|
|
|
|
#define CPPSOURCEPROCESSOR_H
|
2013-04-23 15:04:36 +02:00
|
|
|
|
|
|
|
|
#include "cppmodelmanagerinterface.h"
|
|
|
|
|
|
|
|
|
|
#include <cplusplus/PreprocessorEnvironment.h>
|
|
|
|
|
#include <cplusplus/pp-engine.h>
|
2014-05-16 16:09:26 -04:00
|
|
|
#include <utils/qtcoverride.h>
|
2013-04-23 15:04:36 +02:00
|
|
|
|
|
|
|
|
#include <QHash>
|
|
|
|
|
#include <QPointer>
|
2014-05-16 16:09:26 -04:00
|
|
|
#include <QSet>
|
|
|
|
|
#include <QStringList>
|
2013-04-23 15:04:36 +02:00
|
|
|
|
2014-06-27 22:11:09 +02:00
|
|
|
#include <functional>
|
|
|
|
|
|
2013-11-14 10:59:46 +01:00
|
|
|
QT_BEGIN_NAMESPACE
|
|
|
|
|
class QTextCodec;
|
|
|
|
|
QT_END_NAMESPACE
|
|
|
|
|
|
2013-04-23 15:04:36 +02:00
|
|
|
namespace CppTools {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
2013-05-26 10:57:41 +04:00
|
|
|
// Documentation inside.
|
2014-05-19 11:17:39 -04:00
|
|
|
class CppSourceProcessor: public CPlusPlus::Client
|
2013-04-23 15:04:36 +02:00
|
|
|
{
|
2014-05-16 15:51:04 -04:00
|
|
|
Q_DISABLE_COPY(CppSourceProcessor)
|
2013-04-23 15:04:36 +02:00
|
|
|
|
2014-06-06 14:41:19 +02:00
|
|
|
public:
|
|
|
|
|
typedef std::function<void (const CPlusPlus::Document::Ptr &)> DocumentCallback;
|
|
|
|
|
|
2013-04-23 15:04:36 +02:00
|
|
|
public:
|
2013-05-26 10:57:41 +04:00
|
|
|
static QString cleanPath(const QString &path);
|
|
|
|
|
|
2014-06-06 14:41:19 +02:00
|
|
|
CppSourceProcessor(const CPlusPlus::Snapshot &snapshot, DocumentCallback documentFinished);
|
2014-05-16 16:09:26 -04:00
|
|
|
~CppSourceProcessor();
|
2013-04-23 15:04:36 +02:00
|
|
|
|
2014-06-06 14:41:19 +02:00
|
|
|
void setDumpFileNameWhileParsing(bool onoff)
|
|
|
|
|
{ m_dumpFileNameWhileParsing = onoff; }
|
|
|
|
|
|
2013-04-23 15:04:36 +02:00
|
|
|
void setRevision(unsigned revision);
|
|
|
|
|
void setWorkingCopy(const CppTools::CppModelManagerInterface::WorkingCopy &workingCopy);
|
2014-06-25 17:23:19 +02:00
|
|
|
void setHeaderPaths(const ProjectPart::HeaderPaths &headerPaths);
|
2013-04-23 15:04:36 +02:00
|
|
|
void setTodo(const QStringList &files);
|
|
|
|
|
|
|
|
|
|
void run(const QString &fileName);
|
|
|
|
|
void removeFromCache(const QString &fileName);
|
|
|
|
|
void resetEnvironment();
|
|
|
|
|
|
2014-05-16 16:09:26 -04:00
|
|
|
CPlusPlus::Snapshot snapshot() const { return m_snapshot; }
|
|
|
|
|
const QSet<QString> &todo() const { return m_todo; }
|
2013-04-23 15:04:36 +02:00
|
|
|
|
2013-08-19 16:05:29 +02:00
|
|
|
void setGlobalSnapshot(const CPlusPlus::Snapshot &snapshot) { m_globalSnapshot = snapshot; }
|
|
|
|
|
|
2014-05-16 16:09:26 -04:00
|
|
|
private:
|
2014-06-25 17:23:19 +02:00
|
|
|
void addFrameworkPath(const ProjectPart::HeaderPath &frameworkPath);
|
2014-05-16 16:09:26 -04:00
|
|
|
|
|
|
|
|
CPlusPlus::Document::Ptr switchCurrentDocument(CPlusPlus::Document::Ptr doc);
|
2013-04-23 15:04:36 +02:00
|
|
|
|
2014-02-19 09:11:59 -03:00
|
|
|
bool getFileContents(const QString &absoluteFilePath, QByteArray *contents,
|
|
|
|
|
unsigned *revision) const;
|
2013-04-23 15:04:36 +02:00
|
|
|
bool checkFile(const QString &absoluteFilePath) const;
|
|
|
|
|
QString resolveFile(const QString &fileName, IncludeType type);
|
|
|
|
|
QString resolveFile_helper(const QString &fileName, IncludeType type);
|
|
|
|
|
|
|
|
|
|
void mergeEnvironment(CPlusPlus::Document::Ptr doc);
|
|
|
|
|
|
2014-05-16 16:09:26 -04:00
|
|
|
// Client interface
|
|
|
|
|
void macroAdded(const CPlusPlus::Macro ¯o) QTC_OVERRIDE;
|
|
|
|
|
void passedMacroDefinitionCheck(unsigned bytesOffset, unsigned utf16charsOffset,
|
|
|
|
|
unsigned line, const CPlusPlus::Macro ¯o) QTC_OVERRIDE;
|
|
|
|
|
void failedMacroDefinitionCheck(unsigned bytesOffset, unsigned utf16charOffset,
|
|
|
|
|
const CPlusPlus::ByteArrayRef &name) QTC_OVERRIDE;
|
|
|
|
|
void notifyMacroReference(unsigned bytesOffset, unsigned utf16charOffset,
|
|
|
|
|
unsigned line, const CPlusPlus::Macro ¯o) QTC_OVERRIDE;
|
|
|
|
|
void startExpandingMacro(unsigned bytesOffset, unsigned utf16charOffset,
|
|
|
|
|
unsigned line, const CPlusPlus::Macro ¯o,
|
|
|
|
|
const QVector<CPlusPlus::MacroArgumentReference> &actuals) QTC_OVERRIDE;
|
|
|
|
|
void stopExpandingMacro(unsigned bytesOffset, const CPlusPlus::Macro ¯o) QTC_OVERRIDE;
|
|
|
|
|
void markAsIncludeGuard(const QByteArray ¯oName) QTC_OVERRIDE;
|
|
|
|
|
void startSkippingBlocks(unsigned utf16charsOffset) QTC_OVERRIDE;
|
|
|
|
|
void stopSkippingBlocks(unsigned utf16charsOffset) QTC_OVERRIDE;
|
|
|
|
|
void sourceNeeded(unsigned line, const QString &fileName, IncludeType type) QTC_OVERRIDE;
|
2013-04-23 15:04:36 +02:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
CPlusPlus::Snapshot m_snapshot;
|
2013-08-19 16:05:29 +02:00
|
|
|
CPlusPlus::Snapshot m_globalSnapshot;
|
2014-06-06 14:41:19 +02:00
|
|
|
DocumentCallback m_documentFinished;
|
2013-04-23 15:04:36 +02:00
|
|
|
bool m_dumpFileNameWhileParsing;
|
|
|
|
|
CPlusPlus::Environment m_env;
|
|
|
|
|
CPlusPlus::Preprocessor m_preprocess;
|
2014-06-25 17:23:19 +02:00
|
|
|
ProjectPart::HeaderPaths m_headerPaths;
|
2013-04-23 15:04:36 +02:00
|
|
|
CppTools::CppModelManagerInterface::WorkingCopy m_workingCopy;
|
|
|
|
|
QSet<QString> m_included;
|
|
|
|
|
CPlusPlus::Document::Ptr m_currentDoc;
|
|
|
|
|
QSet<QString> m_todo;
|
|
|
|
|
QSet<QString> m_processed;
|
|
|
|
|
unsigned m_revision;
|
|
|
|
|
QHash<QString, QString> m_fileNameCache;
|
2013-11-14 10:59:46 +01:00
|
|
|
QTextCodec *m_defaultCodec;
|
2013-04-23 15:04:36 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace CppTools
|
|
|
|
|
|
2014-05-16 15:51:04 -04:00
|
|
|
#endif // CPPSOURCEPROCESSOR_H
|