Commit 4e285a11 authored by Erik Verbruggen's avatar Erik Verbruggen Committed by Erik Verbruggen

C++: Cleanup: make the snapshot private in CppPreprocessor.

Change-Id: I69e892de34e06a0c95b3218abd8a0bb72966d875
Reviewed-by: default avatarNikolai Kosjar <nikolai.kosjar@digia.com>
parent 600f4438
...@@ -36,7 +36,7 @@ static void parse(QFutureInterface<void> &future, ...@@ -36,7 +36,7 @@ static void parse(QFutureInterface<void> &future,
foreach (const QString &file, files) { foreach (const QString &file, files) {
QFileInfo info(file); QFileInfo info(file);
preproc->m_snapshot.remove(file); preproc->removeFromCache(file);
if (suffixes.contains(info.suffix())) if (suffixes.contains(info.suffix()))
sources.append(file); sources.append(file);
......
...@@ -282,17 +282,14 @@ namespace { ...@@ -282,17 +282,14 @@ namespace {
class Process: public std::unary_function<Document::Ptr, void> class Process: public std::unary_function<Document::Ptr, void>
{ {
QPointer<CppModelManager> _modelManager; QPointer<CppModelManager> _modelManager;
Snapshot _snapshot;
Document::Ptr _doc; Document::Ptr _doc;
Document::CheckMode _mode; Document::CheckMode _mode;
public: public:
Process(QPointer<CppModelManager> modelManager, Process(QPointer<CppModelManager> modelManager,
Document::Ptr doc, Document::Ptr doc,
const Snapshot &snapshot,
const CppModelManager::WorkingCopy &workingCopy) const CppModelManager::WorkingCopy &workingCopy)
: _modelManager(modelManager), : _modelManager(modelManager),
_snapshot(snapshot),
_doc(doc), _doc(doc),
_mode(Document::FastCheck) _mode(Document::FastCheck)
{ {
...@@ -319,6 +316,11 @@ void CppPreprocessor::run(const QString &fileName) ...@@ -319,6 +316,11 @@ void CppPreprocessor::run(const QString &fileName)
sourceNeeded(0, absoluteFilePath, IncludeGlobal); sourceNeeded(0, absoluteFilePath, IncludeGlobal);
} }
void CppPreprocessor::removeFromCache(const QString &fileName)
{
m_snapshot.remove(fileName);
}
void CppPreprocessor::resetEnvironment() void CppPreprocessor::resetEnvironment()
{ {
m_env.reset(); m_env.reset();
...@@ -601,8 +603,7 @@ void CppPreprocessor::sourceNeeded(unsigned line, QString &fileName, IncludeType ...@@ -601,8 +603,7 @@ void CppPreprocessor::sourceNeeded(unsigned line, QString &fileName, IncludeType
m_snapshot.insert(doc); m_snapshot.insert(doc);
m_todo.remove(fileName); m_todo.remove(fileName);
Process process(m_modelManager, doc, m_snapshot, m_workingCopy); Process process(m_modelManager, doc, m_workingCopy);
process(); process();
(void) switchDocument(previousDoc); (void) switchDocument(previousDoc);
......
...@@ -250,6 +250,8 @@ private: ...@@ -250,6 +250,8 @@ private:
class CPPTOOLS_EXPORT CppPreprocessor: public CPlusPlus::Client class CPPTOOLS_EXPORT CppPreprocessor: public CPlusPlus::Client
{ {
Q_DISABLE_COPY(CppPreprocessor)
public: public:
CppPreprocessor(QPointer<CppModelManager> modelManager, bool dumpFileNameWhileParsing = false); CppPreprocessor(QPointer<CppModelManager> modelManager, bool dumpFileNameWhileParsing = false);
virtual ~CppPreprocessor(); virtual ~CppPreprocessor();
...@@ -263,6 +265,7 @@ public: ...@@ -263,6 +265,7 @@ public:
void setTodo(const QStringList &files); void setTodo(const QStringList &files);
void run(const QString &fileName); void run(const QString &fileName);
void removeFromCache(const QString &fileName);
void resetEnvironment(); void resetEnvironment();
static QString cleanPath(const QString &path); static QString cleanPath(const QString &path);
...@@ -273,9 +276,6 @@ public: ...@@ -273,9 +276,6 @@ public:
CppModelManager *modelManager() const CppModelManager *modelManager() const
{ return m_modelManager.data(); } { return m_modelManager.data(); }
public: // attributes
CPlusPlus::Snapshot m_snapshot;
protected: protected:
CPlusPlus::Document::Ptr switchDocument(CPlusPlus::Document::Ptr doc); CPlusPlus::Document::Ptr switchDocument(CPlusPlus::Document::Ptr doc);
...@@ -302,6 +302,7 @@ protected: ...@@ -302,6 +302,7 @@ protected:
virtual void sourceNeeded(unsigned line, QString &fileName, IncludeType type); virtual void sourceNeeded(unsigned line, QString &fileName, IncludeType type);
private: private:
CPlusPlus::Snapshot m_snapshot;
QPointer<CppModelManager> m_modelManager; QPointer<CppModelManager> m_modelManager;
bool m_dumpFileNameWhileParsing; bool m_dumpFileNameWhileParsing;
CPlusPlus::Environment m_env; CPlusPlus::Environment m_env;
......
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