From 27f6b2ceb5a3b946a7e6236470295c0ad4891cdf Mon Sep 17 00:00:00 2001
From: Roberto Raggi <roberto.raggi@nokia.com>
Date: Tue, 22 Jun 2010 10:36:28 +0200
Subject: [PATCH] Renamed CppRefactoringChanges::parsedDocumentForFile().

---
 src/plugins/cppeditor/cppquickfix.cpp         |  3 +--
 .../cppeditor/cpprefactoringchanges.cpp       | 25 ++++++++-----------
 src/plugins/cppeditor/cpprefactoringchanges.h |  4 +--
 src/plugins/texteditor/refactoringchanges.cpp |  2 +-
 src/plugins/texteditor/refactoringchanges.h   |  2 +-
 5 files changed, 16 insertions(+), 20 deletions(-)

diff --git a/src/plugins/cppeditor/cppquickfix.cpp b/src/plugins/cppeditor/cppquickfix.cpp
index 89185c64b6b..72bc705ed50 100644
--- a/src/plugins/cppeditor/cppquickfix.cpp
+++ b/src/plugins/cppeditor/cppquickfix.cpp
@@ -933,8 +933,7 @@ int CppQuickFixOperation::match(TextEditor::QuickFixState *state)
     _document = s->info.doc;
     if (_refactoringChanges)
         delete _refactoringChanges;
-    CPPEditor *cppEditor = qobject_cast<CPPEditor*>(editor());
-    _refactoringChanges = new CppRefactoringChanges(s->info.snapshot, cppEditor->modelManager());
+    _refactoringChanges = new CppRefactoringChanges(s->info.snapshot);
     return match(s->path);
 }
 
diff --git a/src/plugins/cppeditor/cpprefactoringchanges.cpp b/src/plugins/cppeditor/cpprefactoringchanges.cpp
index 72ad416d767..6d6e095e62d 100644
--- a/src/plugins/cppeditor/cpprefactoringchanges.cpp
+++ b/src/plugins/cppeditor/cpprefactoringchanges.cpp
@@ -34,13 +34,12 @@ using namespace CppTools;
 using namespace TextEditor;
 using namespace CppEditor;
 
-CppRefactoringChanges::CppRefactoringChanges(const Snapshot &snapshot,
-                                             CppModelManagerInterface *modelManager)
+CppRefactoringChanges::CppRefactoringChanges(const Snapshot &snapshot)
     : m_snapshot(snapshot)
-    , m_modelManager(modelManager)
-    , m_workingCopy(modelManager->workingCopy())
+    , m_modelManager(CppTools::CppModelManagerInterface::instance())
 {
-    Q_ASSERT(modelManager);
+    Q_ASSERT(m_modelManager);
+    m_workingCopy = m_modelManager->workingCopy();
 }
 
 QStringList CppRefactoringChanges::apply()
@@ -50,17 +49,14 @@ QStringList CppRefactoringChanges::apply()
     return changedFiles;
 }
 
-Document::Ptr CppRefactoringChanges::parsedDocumentForFile(const QString &fileName) const
+Document::Ptr CppRefactoringChanges::document(const QString &fileName) const
 {
-    Document::Ptr doc = m_snapshot.document(fileName);
-
     QString source;
+    unsigned editorRevision = 0;
     if (m_workingCopy.contains(fileName)) {
-        QPair<QString, unsigned> workingCopy = m_workingCopy.get(fileName);
-        if (doc && doc->editorRevision() == workingCopy.second)
-            return doc;
-        else
-            source = workingCopy.first;
+        const QPair<QString, unsigned> workingCopy = m_workingCopy.get(fileName);
+        source = workingCopy.first;
+        editorRevision = workingCopy.second;
     } else {
         QFile file(fileName);
         if (! file.open(QFile::ReadOnly))
@@ -71,7 +67,8 @@ Document::Ptr CppRefactoringChanges::parsedDocumentForFile(const QString &fileNa
     }
 
     const QByteArray contents = m_snapshot.preprocessedCode(source, fileName);
-    doc = m_snapshot.documentFromSource(contents, fileName);
+    Document::Ptr doc = m_snapshot.documentFromSource(contents, fileName);
+    doc->setEditorRevision(editorRevision);
     doc->check();
     return doc;
 }
diff --git a/src/plugins/cppeditor/cpprefactoringchanges.h b/src/plugins/cppeditor/cpprefactoringchanges.h
index 3371ca42c73..9b684772f20 100644
--- a/src/plugins/cppeditor/cpprefactoringchanges.h
+++ b/src/plugins/cppeditor/cpprefactoringchanges.h
@@ -42,14 +42,14 @@ namespace CppEditor {
 class CPPEDITOR_EXPORT CppRefactoringChanges: public TextEditor::RefactoringChanges
 {
 public:
-    CppRefactoringChanges(const CPlusPlus::Snapshot &snapshot, CppTools::CppModelManagerInterface *modelManager);
+    CppRefactoringChanges(const CPlusPlus::Snapshot &snapshot);
 
     virtual QStringList apply();
 
     const CPlusPlus::Snapshot &snapshot() const
     { return m_snapshot; }
 
-    CPlusPlus::Document::Ptr parsedDocumentForFile(const QString &fileName) const;
+    CPlusPlus::Document::Ptr document(const QString &fileName) const;
 
 private:
     CPlusPlus::Snapshot m_snapshot;
diff --git a/src/plugins/texteditor/refactoringchanges.cpp b/src/plugins/texteditor/refactoringchanges.cpp
index 7aa2491ff6c..45eec47a32d 100644
--- a/src/plugins/texteditor/refactoringchanges.cpp
+++ b/src/plugins/texteditor/refactoringchanges.cpp
@@ -103,7 +103,7 @@ QStringList RefactoringChanges::apply()
             }
 
             QTextCursor changeSetCursor = editor->textCursor();
-            Utils::ChangeSet changeSet = m_changesByFile[fileName];
+            Utils::ChangeSet changeSet = m_changesByFile.value(fileName);
             changeSet.apply(&changeSetCursor);
 
             foreach (const CursorPair &cursorPair, cursorPairs) {
diff --git a/src/plugins/texteditor/refactoringchanges.h b/src/plugins/texteditor/refactoringchanges.h
index 51c55af383e..93b576496c4 100644
--- a/src/plugins/texteditor/refactoringchanges.h
+++ b/src/plugins/texteditor/refactoringchanges.h
@@ -57,7 +57,7 @@ public:
 
     virtual QStringList apply();
 
-    int positionInFile(const QString &fileName, int line, int column = 0) const;
+    Q_DECL_DEPRECATED int positionInFile(const QString &fileName, int line, int column = 0) const;
 
     static BaseTextEditor *editorForFile(const QString &fileName,
                                          bool openIfClosed = false);
-- 
GitLab