summaryrefslogtreecommitdiff
path: root/src/plugins/cppeditor
diff options
context:
space:
mode:
authorRoberto Raggi <roberto.raggi@nokia.com>2010-06-22 10:36:28 +0200
committerRoberto Raggi <roberto.raggi@nokia.com>2010-06-22 12:13:30 +0200
commit27f6b2ceb5a3b946a7e6236470295c0ad4891cdf (patch)
tree59f123a66954f343d6deae2e4459f94a22cbc86a /src/plugins/cppeditor
parenteb749ec3a2aca7d3d6fc0ddb9106c6f50ed5aa5e (diff)
downloadqt-creator-27f6b2ceb5a3b946a7e6236470295c0ad4891cdf.tar.gz
Renamed CppRefactoringChanges::parsedDocumentForFile().
Diffstat (limited to 'src/plugins/cppeditor')
-rw-r--r--src/plugins/cppeditor/cppquickfix.cpp3
-rw-r--r--src/plugins/cppeditor/cpprefactoringchanges.cpp25
-rw-r--r--src/plugins/cppeditor/cpprefactoringchanges.h4
3 files changed, 14 insertions, 18 deletions
diff --git a/src/plugins/cppeditor/cppquickfix.cpp b/src/plugins/cppeditor/cppquickfix.cpp
index 89185c64b6..72bc705ed5 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 72ad416d76..6d6e095e62 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 3371ca42c7..9b684772f2 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;