Skip to content
Snippets Groups Projects
Commit 0344b728 authored by Roberto Raggi's avatar Roberto Raggi
Browse files

Store the time stamp if necessary.

parent e0d7e7c5
No related branches found
No related tags found
No related merge requests found
...@@ -42,6 +42,12 @@ CppRefactoringChanges::CppRefactoringChanges(const Snapshot &snapshot) ...@@ -42,6 +42,12 @@ CppRefactoringChanges::CppRefactoringChanges(const Snapshot &snapshot)
m_workingCopy = m_modelManager->workingCopy(); m_workingCopy = m_modelManager->workingCopy();
} }
const CPlusPlus::Snapshot &CppRefactoringChanges::snapshot() const
{
return m_snapshot;
}
QStringList CppRefactoringChanges::apply() QStringList CppRefactoringChanges::apply()
{ {
const QStringList changedFiles = TextEditor::RefactoringChanges::apply(); const QStringList changedFiles = TextEditor::RefactoringChanges::apply();
...@@ -53,6 +59,8 @@ Document::Ptr CppRefactoringChanges::document(const QString &fileName) const ...@@ -53,6 +59,8 @@ Document::Ptr CppRefactoringChanges::document(const QString &fileName) const
{ {
QString source; QString source;
unsigned editorRevision = 0; unsigned editorRevision = 0;
QDateTime lastModified;
if (m_workingCopy.contains(fileName)) { if (m_workingCopy.contains(fileName)) {
const QPair<QString, unsigned> workingCopy = m_workingCopy.get(fileName); const QPair<QString, unsigned> workingCopy = m_workingCopy.get(fileName);
source = workingCopy.first; source = workingCopy.first;
...@@ -62,13 +70,19 @@ Document::Ptr CppRefactoringChanges::document(const QString &fileName) const ...@@ -62,13 +70,19 @@ Document::Ptr CppRefactoringChanges::document(const QString &fileName) const
if (! file.open(QFile::ReadOnly)) if (! file.open(QFile::ReadOnly))
return Document::Ptr(); return Document::Ptr();
lastModified = QFileInfo(file).lastModified();
source = QTextStream(&file).readAll(); // ### FIXME read bytes, and remove the convert below source = QTextStream(&file).readAll(); // ### FIXME read bytes, and remove the convert below
file.close(); file.close();
} }
const QByteArray contents = m_snapshot.preprocessedCode(source, fileName); const QByteArray contents = m_snapshot.preprocessedCode(source, fileName);
Document::Ptr doc = m_snapshot.documentFromSource(contents, fileName); Document::Ptr doc = m_snapshot.documentFromSource(contents, fileName);
doc->setEditorRevision(editorRevision);
if (lastModified.isValid())
doc->setLastModified(lastModified);
else
doc->setEditorRevision(editorRevision);
doc->check(); doc->check();
return doc; return doc;
} }
...@@ -46,9 +46,7 @@ public: ...@@ -46,9 +46,7 @@ public:
virtual QStringList apply(); virtual QStringList apply();
const CPlusPlus::Snapshot &snapshot() const const CPlusPlus::Snapshot &snapshot() const;
{ return m_snapshot; }
CPlusPlus::Document::Ptr document(const QString &fileName) const; CPlusPlus::Document::Ptr document(const QString &fileName) const;
private: private:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment