Commit eaa2c10a authored by Roberto Raggi's avatar Roberto Raggi

Introduced CppTools::CppModelManagerInterface::updateModifiedFiles().

updateModifiedFiles ckecks the timestamp and reparses all the modified files in the current snapshot.
parent 8d810bd1
...@@ -147,6 +147,16 @@ void Document::setRevision(unsigned revision) ...@@ -147,6 +147,16 @@ void Document::setRevision(unsigned revision)
_revision = revision; _revision = revision;
} }
QDateTime Document::lastModified() const
{
return _lastModified;
}
void Document::setLastModified(const QDateTime &lastModified)
{
_lastModified = lastModified;
}
QString Document::fileName() const QString Document::fileName() const
{ {
return _fileName; return _fileName;
...@@ -447,6 +457,8 @@ Document::Ptr Snapshot::documentFromSource(const QByteArray &preprocessedCode, ...@@ -447,6 +457,8 @@ Document::Ptr Snapshot::documentFromSource(const QByteArray &preprocessedCode,
Document::Ptr newDoc = Document::create(fileName); Document::Ptr newDoc = Document::create(fileName);
if (Document::Ptr thisDocument = value(fileName)) { if (Document::Ptr thisDocument = value(fileName)) {
newDoc->_revision = thisDocument->_revision;
newDoc->_lastModified = thisDocument->_lastModified;
newDoc->_includes = thisDocument->_includes; newDoc->_includes = thisDocument->_includes;
newDoc->_definedMacros = thisDocument->_definedMacros; newDoc->_definedMacros = thisDocument->_definedMacros;
newDoc->_macroUses = thisDocument->_macroUses; newDoc->_macroUses = thisDocument->_macroUses;
......
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
#include <QSharedPointer> #include <QSharedPointer>
#include <QString> #include <QString>
#include <QStringList> #include <QStringList>
#include <QDateTime>
namespace CPlusPlus { namespace CPlusPlus {
...@@ -63,6 +64,9 @@ public: ...@@ -63,6 +64,9 @@ public:
unsigned revision() const; unsigned revision() const;
void setRevision(unsigned revision); void setRevision(unsigned revision);
QDateTime lastModified() const;
void setLastModified(const QDateTime &lastModified);
QString fileName() const; QString fileName() const;
QStringList includedFiles() const; QStringList includedFiles() const;
...@@ -310,6 +314,7 @@ private: ...@@ -310,6 +314,7 @@ private:
QList<MacroUse> _macroUses; QList<MacroUse> _macroUses;
QList<UndefinedMacroUse> _undefinedMacroUses; QList<UndefinedMacroUse> _undefinedMacroUses;
QByteArray _source; QByteArray _source;
QDateTime _lastModified;
unsigned _revision; unsigned _revision;
friend class Snapshot; friend class Snapshot;
......
...@@ -562,6 +562,10 @@ void CppPreprocessor::sourceNeeded(QString &fileName, IncludeType type, ...@@ -562,6 +562,10 @@ void CppPreprocessor::sourceNeeded(QString &fileName, IncludeType type,
doc = Document::create(fileName); doc = Document::create(fileName);
doc->setRevision(m_revision); doc->setRevision(m_revision);
QFileInfo info(fileName);
if (info.exists())
doc->setLastModified(info.lastModified());
Document::Ptr previousDoc = switchDocument(doc); Document::Ptr previousDoc = switchDocument(doc);
const QByteArray preprocessedCode = preprocess(fileName, contents); const QByteArray preprocessedCode = preprocess(fileName, contents);
...@@ -588,6 +592,26 @@ Document::Ptr CppPreprocessor::switchDocument(Document::Ptr doc) ...@@ -588,6 +592,26 @@ Document::Ptr CppPreprocessor::switchDocument(Document::Ptr doc)
} }
void CppTools::CppModelManagerInterface::updateModifiedSourceFiles()
{
const Snapshot snapshot = this->snapshot();
QStringList sourceFiles;
foreach (const Document::Ptr doc, snapshot) {
const QDateTime lastModified = doc->lastModified();
if (! lastModified.isNull()) {
QFileInfo fileInfo(doc->fileName());
if (fileInfo.exists() && fileInfo.lastModified() != lastModified)
sourceFiles.append(doc->fileName());
}
}
updateSourceFiles(sourceFiles);
}
CppTools::CppModelManagerInterface *CppTools::CppModelManagerInterface::instance() CppTools::CppModelManagerInterface *CppTools::CppModelManagerInterface::instance()
{ {
ExtensionSystem::PluginManager *pluginManager = ExtensionSystem::PluginManager::instance(); ExtensionSystem::PluginManager *pluginManager = ExtensionSystem::PluginManager::instance();
......
...@@ -83,9 +83,6 @@ public: ...@@ -83,9 +83,6 @@ public:
static CppModelManagerInterface *instance(); static CppModelManagerInterface *instance();
virtual void GC() = 0;
virtual void updateSourceFiles(const QStringList &sourceFiles) = 0;
virtual QMap<QString, QString> workingCopy() const = 0; virtual QMap<QString, QString> workingCopy() const = 0;
virtual CPlusPlus::Snapshot snapshot() const = 0; virtual CPlusPlus::Snapshot snapshot() const = 0;
...@@ -104,6 +101,11 @@ public: ...@@ -104,6 +101,11 @@ public:
virtual void renameUsages(CPlusPlus::Symbol *symbol) = 0; virtual void renameUsages(CPlusPlus::Symbol *symbol) = 0;
virtual void findUsages(CPlusPlus::Symbol *symbol) = 0; virtual void findUsages(CPlusPlus::Symbol *symbol) = 0;
public Q_SLOTS:
void updateModifiedSourceFiles();
virtual void updateSourceFiles(const QStringList &sourceFiles) = 0;
virtual void GC() = 0;
}; };
class CPPTOOLS_EXPORT AbstractEditorSupport class CPPTOOLS_EXPORT AbstractEditorSupport
......
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