Commit 09ea0d23 authored by Erik Verbruggen's avatar Erik Verbruggen Committed by Nikolai Kosjar

C++: moved the CppPreprocessor into its own file.

Change-Id: I399d667a1fccb376fadbd6ab8fbba243e86d8f4b
Reviewed-by: default avatarNikolai Kosjar <nikolai.kosjar@digia.com>
parent 516116c5
......@@ -32,10 +32,10 @@
#include <cplusplus/AST.h>
#include <cplusplus/TranslationUnit.h>
#ifdef DEBUG_AST_PATH
#ifdef WITH_AST_PATH_DUMP
# include <QDebug>
# include <typeinfo>
#endif // DEBUG_AST_PATH
#endif // WITH_AST_PATH_DUMP
using namespace CPlusPlus;
......@@ -53,14 +53,14 @@ QList<AST *> ASTPath::operator()(int line, int column)
return _nodes;
}
#ifdef DEBUG_AST_PATH
#ifdef WITH_AST_PATH_DUMP
void ASTPath::dump(const QList<AST *> nodes)
{
qDebug() << "ASTPath dump," << nodes.size() << "nodes:";
for (int i = 0; i < nodes.size(); ++i)
qDebug() << qPrintable(QString(i + 1, QLatin1Char('-'))) << typeid(*nodes.at(i)).name();
}
#endif // DEBUG_AST_PATH
#endif // WITH_AST_PATH_DUMP
bool ASTPath::preVisit(AST *ast)
{
......
......@@ -38,7 +38,7 @@
#include <QList>
#include <QTextCursor>
#undef DEBUG_AST_PATH
#undef WITH_AST_PATH_DUMP
namespace CPlusPlus {
......@@ -56,7 +56,7 @@ public:
/// line and column are 1-based!
QList<AST *> operator()(int line, int column);
#ifdef DEBUG_AST_PATH
#ifdef WITH_AST_PATH_DUMP
static void dump(const QList<AST *> nodes);
#endif
......
#include "builtinindexingsupport.h"
#include "cppmodelmanager.h"
#include "cpppreprocessor.h"
#include "searchsymbols.h"
#include "cpptoolsconstants.h"
#include "cppprojectfile.h"
......
......@@ -28,8 +28,8 @@
****************************************************************************/
#include "cppcompletionassist.h"
#include "cppmodelmanager.h"
#include "cpptoolsconstants.h"
#include "cppdoxygen.h"
#include <coreplugin/icore.h>
......
This diff is collapsed.
......@@ -31,15 +31,11 @@
#define CPPMODELMANAGER_H
#include "cpptools_global.h"
#include "cpptoolsconstants.h"
#include "cppmodelmanagerinterface.h"
#include <projectexplorer/project.h>
#include <texteditor/basetexteditor.h>
#include <cplusplus/PreprocessorEnvironment.h>
#include <cplusplus/pp-engine.h>
#include <QHash>
#include <QMutex>
......@@ -51,7 +47,6 @@ class BaseTextEditorWidget;
namespace CppTools {
class CppCompletionSupportFactory;
class CppEditorSupport;
class CppHighlightingSupportFactory;
......@@ -205,77 +200,6 @@ private:
CppIndexingSupport *m_internalIndexingSupport;
};
class CPPTOOLS_EXPORT CppPreprocessor: public CPlusPlus::Client
{
Q_DISABLE_COPY(CppPreprocessor)
public:
CppPreprocessor(QPointer<CppModelManager> modelManager, bool dumpFileNameWhileParsing = false);
virtual ~CppPreprocessor();
void setRevision(unsigned revision);
void setWorkingCopy(const CppTools::CppModelManagerInterface::WorkingCopy &workingCopy);
void setIncludePaths(const QStringList &includePaths);
void setFrameworkPaths(const QStringList &frameworkPaths);
void addFrameworkPath(const QString &frameworkPath);
void setProjectFiles(const QStringList &files);
void setTodo(const QStringList &files);
void run(const QString &fileName);
void removeFromCache(const QString &fileName);
void resetEnvironment();
static QString cleanPath(const QString &path);
const QSet<QString> &todo() const
{ return m_todo; }
CppModelManager *modelManager() const
{ return m_modelManager.data(); }
protected:
CPlusPlus::Document::Ptr switchDocument(CPlusPlus::Document::Ptr doc);
void getFileContents(const QString &absoluteFilePath, QString *contents, unsigned *revision) const;
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);
virtual void macroAdded(const CPlusPlus::Macro &macro);
virtual void passedMacroDefinitionCheck(unsigned offset, unsigned line,
const CPlusPlus::Macro &macro);
virtual void failedMacroDefinitionCheck(unsigned offset, const CPlusPlus::ByteArrayRef &name);
virtual void notifyMacroReference(unsigned offset, unsigned line,
const CPlusPlus::Macro &macro);
virtual void startExpandingMacro(unsigned offset,
unsigned line,
const CPlusPlus::Macro &macro,
const QVector<CPlusPlus::MacroArgumentReference> &actuals);
virtual void stopExpandingMacro(unsigned offset, const CPlusPlus::Macro &macro);
virtual void markAsIncludeGuard(const QByteArray &macroName);
virtual void startSkippingBlocks(unsigned offset);
virtual void stopSkippingBlocks(unsigned offset);
virtual void sourceNeeded(unsigned line, const QString &fileName, IncludeType type);
private:
CPlusPlus::Snapshot m_snapshot;
QPointer<CppModelManager> m_modelManager;
bool m_dumpFileNameWhileParsing;
CPlusPlus::Environment m_env;
CPlusPlus::Preprocessor m_preprocess;
QStringList m_includePaths;
CppTools::CppModelManagerInterface::WorkingCopy m_workingCopy;
QStringList m_frameworkPaths;
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;
};
} // namespace Internal
} // namespace CppTools
......
......@@ -29,7 +29,7 @@
#include "cpptoolsplugin.h"
#include "cppmodelmanager.h"
#include "cpppreprocessor.h"
#include "modelmanagertesthelper.h"
#include <QtTest>
......
This diff is collapsed.
#ifndef CPPPREPROCESSOR_H
#define CPPPREPROCESSOR_H
#include "cppmodelmanagerinterface.h"
#include <cplusplus/PreprocessorEnvironment.h>
#include <cplusplus/pp-engine.h>
#include <QHash>
#include <QPointer>
namespace CppTools {
namespace Internal {
class CppModelManager;
class CPPTOOLS_EXPORT CppPreprocessor: public CPlusPlus::Client
{
Q_DISABLE_COPY(CppPreprocessor)
public:
CppPreprocessor(QPointer<CppModelManager> modelManager, bool dumpFileNameWhileParsing = false);
virtual ~CppPreprocessor();
void setRevision(unsigned revision);
void setWorkingCopy(const CppTools::CppModelManagerInterface::WorkingCopy &workingCopy);
void setIncludePaths(const QStringList &includePaths);
void setFrameworkPaths(const QStringList &frameworkPaths);
void addFrameworkPath(const QString &frameworkPath);
void setProjectFiles(const QStringList &files);
void setTodo(const QStringList &files);
void run(const QString &fileName);
void removeFromCache(const QString &fileName);
void resetEnvironment();
static QString cleanPath(const QString &path);
const QSet<QString> &todo() const
{ return m_todo; }
CppModelManager *modelManager() const
{ return m_modelManager.data(); }
protected:
CPlusPlus::Document::Ptr switchDocument(CPlusPlus::Document::Ptr doc);
void getFileContents(const QString &absoluteFilePath, QString *contents, unsigned *revision) const;
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);
virtual void macroAdded(const CPlusPlus::Macro &macro);
virtual void passedMacroDefinitionCheck(unsigned offset, unsigned line,
const CPlusPlus::Macro &macro);
virtual void failedMacroDefinitionCheck(unsigned offset, const CPlusPlus::ByteArrayRef &name);
virtual void notifyMacroReference(unsigned offset, unsigned line,
const CPlusPlus::Macro &macro);
virtual void startExpandingMacro(unsigned offset,
unsigned line,
const CPlusPlus::Macro &macro,
const QVector<CPlusPlus::MacroArgumentReference> &actuals);
virtual void stopExpandingMacro(unsigned offset, const CPlusPlus::Macro &macro);
virtual void markAsIncludeGuard(const QByteArray &macroName);
virtual void startSkippingBlocks(unsigned offset);
virtual void stopSkippingBlocks(unsigned offset);
virtual void sourceNeeded(unsigned line, const QString &fileName, IncludeType type);
private:
CPlusPlus::Snapshot m_snapshot;
QPointer<CppModelManager> m_modelManager;
bool m_dumpFileNameWhileParsing;
CPlusPlus::Environment m_env;
CPlusPlus::Preprocessor m_preprocess;
QStringList m_includePaths;
CppTools::CppModelManagerInterface::WorkingCopy m_workingCopy;
QStringList m_frameworkPaths;
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;
};
} // namespace Internal
} // namespace CppTools
#endif // CPPPREPROCESSOR_H
......@@ -44,7 +44,8 @@ HEADERS += completionsettingspage.h \
cppindexingsupport.h \
builtinindexingsupport.h \
cpppointerdeclarationformatter.h \
cppprojectfile.h
cppprojectfile.h \
cpppreprocessor.h
SOURCES += completionsettingspage.cpp \
cppclassesfilter.cpp \
......@@ -87,7 +88,8 @@ SOURCES += completionsettingspage.cpp \
cppindexingsupport.cpp \
builtinindexingsupport.cpp \
cpppointerdeclarationformatter.cpp \
cppprojectfile.cpp
cppprojectfile.cpp \
cpppreprocessor.cpp
FORMS += completionsettingspage.ui \
cppfilesettingspage.ui \
......
......@@ -105,7 +105,9 @@ QtcPlugin {
"uicodecompletionsupport.cpp",
"uicodecompletionsupport.h",
"builtinindexingsupport.cpp",
"builtinindexingsupport.h"
"builtinindexingsupport.h",
"cpppreprocessor.cpp",
"cpppreprocessor.h"
]
Group {
......
......@@ -27,8 +27,8 @@
**
****************************************************************************/
#include "cpptoolsconstants.h"
#include "cpptoolsplugin.h"
#include "cppfilesettingspage.h"
#include "cppcodestylesettingspage.h"
#include "cppclassesfilter.h"
......
......@@ -28,8 +28,8 @@
****************************************************************************/
#include "symbolsfindfilter.h"
#include "cppmodelmanager.h"
#include "cpptoolsconstants.h"
#include <coreplugin/icore.h>
#include <coreplugin/progressmanager/futureprogress.h>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment