forked from qt-creator/qt-creator
Introduced CppTools::CppModelManagerInterface::updateModifiedFiles().
updateModifiedFiles ckecks the timestamp and reparses all the modified files in the current snapshot.
This commit is contained in:
@@ -147,6 +147,16 @@ void Document::setRevision(unsigned revision)
|
||||
_revision = revision;
|
||||
}
|
||||
|
||||
QDateTime Document::lastModified() const
|
||||
{
|
||||
return _lastModified;
|
||||
}
|
||||
|
||||
void Document::setLastModified(const QDateTime &lastModified)
|
||||
{
|
||||
_lastModified = lastModified;
|
||||
}
|
||||
|
||||
QString Document::fileName() const
|
||||
{
|
||||
return _fileName;
|
||||
@@ -447,6 +457,8 @@ Document::Ptr Snapshot::documentFromSource(const QByteArray &preprocessedCode,
|
||||
Document::Ptr newDoc = Document::create(fileName);
|
||||
|
||||
if (Document::Ptr thisDocument = value(fileName)) {
|
||||
newDoc->_revision = thisDocument->_revision;
|
||||
newDoc->_lastModified = thisDocument->_lastModified;
|
||||
newDoc->_includes = thisDocument->_includes;
|
||||
newDoc->_definedMacros = thisDocument->_definedMacros;
|
||||
newDoc->_macroUses = thisDocument->_macroUses;
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
#include <QSharedPointer>
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
#include <QDateTime>
|
||||
|
||||
namespace CPlusPlus {
|
||||
|
||||
@@ -63,6 +64,9 @@ public:
|
||||
unsigned revision() const;
|
||||
void setRevision(unsigned revision);
|
||||
|
||||
QDateTime lastModified() const;
|
||||
void setLastModified(const QDateTime &lastModified);
|
||||
|
||||
QString fileName() const;
|
||||
|
||||
QStringList includedFiles() const;
|
||||
@@ -310,6 +314,7 @@ private:
|
||||
QList<MacroUse> _macroUses;
|
||||
QList<UndefinedMacroUse> _undefinedMacroUses;
|
||||
QByteArray _source;
|
||||
QDateTime _lastModified;
|
||||
unsigned _revision;
|
||||
|
||||
friend class Snapshot;
|
||||
|
||||
@@ -562,6 +562,10 @@ void CppPreprocessor::sourceNeeded(QString &fileName, IncludeType type,
|
||||
doc = Document::create(fileName);
|
||||
doc->setRevision(m_revision);
|
||||
|
||||
QFileInfo info(fileName);
|
||||
if (info.exists())
|
||||
doc->setLastModified(info.lastModified());
|
||||
|
||||
Document::Ptr previousDoc = switchDocument(doc);
|
||||
|
||||
const QByteArray preprocessedCode = preprocess(fileName, contents);
|
||||
@@ -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()
|
||||
{
|
||||
ExtensionSystem::PluginManager *pluginManager = ExtensionSystem::PluginManager::instance();
|
||||
|
||||
@@ -83,9 +83,6 @@ public:
|
||||
|
||||
static CppModelManagerInterface *instance();
|
||||
|
||||
virtual void GC() = 0;
|
||||
virtual void updateSourceFiles(const QStringList &sourceFiles) = 0;
|
||||
|
||||
virtual QMap<QString, QString> workingCopy() const = 0;
|
||||
virtual CPlusPlus::Snapshot snapshot() const = 0;
|
||||
|
||||
@@ -104,6 +101,11 @@ public:
|
||||
|
||||
virtual void renameUsages(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
|
||||
|
||||
Reference in New Issue
Block a user